Category "sql-server"

Convert implicit varchar max

When I use the CONVERT(VARCHAR(200), Field) to extract the first 200 characters of a varchar(max) field, SQL show me a warning on the select operator on the exe

Convert column value to Ascii using division and mod in sQL SERVER

I have a table in SQL SERVER as below with many columns like below | D401 | D402 | |----------------------------

Find corresponding id values for records from different table

I have 2 tables with entries as: Transition table: From_Status_Id To_Status_Id PU_Id 5 1 868 5

How to Create and Insert Unique Id's Based on another column values in single table?

I have data like this Id Revision_Id A_Id A_Name A_Info ================================================ 1 0 111 A1 A

Select rows with a duplicate ID but different value in another column

I have a table like this I would like to select the Itemid that occurs more than once with a different Rate with group by Masterid The output should be somethi

String or binary data would be truncated when input data from winforms

I'm trying to insert record into my database through a form made by Winforms. At first I try to insert it directly in SQL Server: INSERT INTO item (name, price,

Convert getdate to format 22nd APR, 2022

Can anyone please help me with this, How can I convert getdate() to format 22nd APR, 2022, 21st APR, 2022, 23rd APR,2022, 24th APR, 2022, nd or th or rd is impo

Could not find server 'server name' in sys.servers - sql server 2017 v14.0.3436.1

We're having trouble with running SQL 'exec' but if we run 'select' we don't have a problem. We had Win 2012 Servers with SQL Server 2014 - We are upgrading Win

How to deny INSERT permission to all users SQL Server

We are currently transitioning from using sa credentials in our applications (which is stupid). But I'm breaking my head over the permission system in SQL Serve

SSIS Execute SQL Task continue execution after completion of Oracle stored procedure

I have an Oracle stored procedure I am trying to execute in SSIS Execute SQL Task. This stored procedure involves refreshing materialized views. For each and ev

SQL Segmentation

I have this table Customer Amount Date Period Group 77766 50 2022-02-28 1 2 77766 20 2022-03-31 2 2 77766 30 2022-04-30 3 3 12345 50 2022-02-28 1 1 12345 20 20

How to Get spid using flyway tool?

I am using a flyway tool to run SQL script. I have requirements where I need to return the SPID during the run time in the flyway. Are there any config paramete

Tuning slow query to SYS tables

I'm monitoring the slowest queries to my databases and this one can't be indexed: USE [Project] SELECT TOP 10 t.NAME AS TableName, t.object_id, mai

How fix Configure Always on SQL Server error as shown below:

Replicate SQL image here Result error image description here

Need to match ClockIn with Clock out, multiple clocks on same day SQL

I'm trying to get the clock in and clock out times to correspond to each other so that I can calculate hours worked/amount of breaks/time worked within working

Query to show data checkin , checkout, breakin breakout in 1 row

I have structure data like this, I'm using SQL Server: ID User_ID CheckinTime Date 1 110 "2022-03-25 06:30:29" "2022-03-25" 2 110 "2022-03-25 12:12:31" "2022-

Query to show data checkin , checkout, breakin breakout in 1 row

I have structure data like this, I'm using SQL Server: ID User_ID CheckinTime Date 1 110 "2022-03-25 06:30:29" "2022-03-25" 2 110 "2022-03-25 12:12:31" "2022-

How to insert nulls into a SQL Server table

I have the following dataframe: data = [['Alex', 182.2],['Bob', 183.2],['Clarke', 188.4], ['Kelly', NA]] df = pd.DataFrame(data, columns = ['Name', 'Height'])

Get generated keys from single insert statement with multiple values

i'm inserting multiple rows into a table using a single insert statement. The table has an auto increment field as the primary key. Like so: INSERT INTO MyTabl

Order by calculated column with alias inside case expression

I've got a problem with my order by clause when using a calculated column with an alias as below: This order by works without any problem declare @Mode int = 1