4,668 questions with Transact-SQL-related tags

Sort by: Updated
2 answers One of the answers was accepted by the question author.

slow query on large data

Hi there, --3billion rows of accumulated data over a period of time CREATE TABLE [dbo].[large_accumulation_table]( [amt] float(24) NULL, [lastdate] smalldatetime NULL, [type] [varchar](8) NULL, [doc1] [int] NULL, [line1] [smallint] NULL, [type1]…

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-12-19T18:50:52.5133333+00:00
RJ 186 Reputation points
commented 2024-12-20T22:31:25.0833333+00:00
Erland Sommarskog 114.2K Reputation points MVP
2 answers

Unable to debug Stored Procedure

I get the following error: Unable to start the Transact-SQL debugger, could not connect to the Database Engine instance. Make sure you have enabled the debugging firewall exceptions and are using a login that is a member of the sysadmin fixed server…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,010 questions
Windows Server Security
Windows Server Security
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
1,873 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2021-08-30T20:02:34.027+00:00
D D 6 Reputation points
commented 2024-12-20T21:52:52.7233333+00:00
Erland Sommarskog 114.2K Reputation points MVP
2 answers

How to get the current row value based on previous row value in sql server- ex first row has value, calculate the second row value using first row and some conditions and 3rd using 2nd row and same conditions

when basin <> prebasin, numberinbasinnew=numberinbasin. when basin=prebasin use the numberinbasinnew from the first row (basin<>prebasin) and calculate the second row value for numberinbasinnew based on below conditions -- CASE …

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
107 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-12-19T11:36:41.54+00:00
roopa g 0 Reputation points
edited an answer 2024-12-20T19:58:47.34+00:00
Viorel 118.6K Reputation points
9 answers One of the answers was accepted by the question author.

Microsoft SQL Server Studio - Dark Mode

Is there any official method to use Microsoft SQL Server Management Studio Studio with Dark Mode?

Azure SQL Database
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,303 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2023-12-19T13:11:52.4966667+00:00
Kıvanç ÖZDEMİR 130 Reputation points
commented 2024-12-18T07:13:04.9033333+00:00
Rohit Sonawane 0 Reputation points
1 answer

Record count difference during update query execution.

We are trying to update around 5 millions of data in Azure SQL DWH at a time. While updating the same it has been observed the count of records on table is getting frequently changed, until the update query is completed. What could be underlying reason…

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,088 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-12-11T18:36:37.46+00:00
NIKHIL KUMAR 101 Reputation points
answered 2024-12-17T23:34:44.5833333+00:00
vinod singamsetty 5 Reputation points
3 answers

changing the endcoding of an attached file in sql trasaction

Hi, I have written a sql server procedure which sends the result of a query as a csv file via e-mail. SQL server generates the attached file in UTF-8 BOM encoding. I need the attached file to be generated in UTF-8 (without BOM). I tried to…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2021-07-02T10:37:55.837+00:00
Massimo 1 Reputation point
edited an answer 2024-12-17T11:39:59.86+00:00
Paul Geldenhuys 0 Reputation points
4 answers One of the answers was accepted by the question author.

SQL Server 2019 Instance Name Change

I am running SQL 2019 on Windows 2019 server and have come across an issue I have not seen before and cannot find a resolution on the web. I have went through the normal process of changing the Instance name by using the following.. EXEC sp_dropserver…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2022-03-15T17:08:06.187+00:00
Rich 21 Reputation points
commented 2024-12-12T13:50:13.6233333+00:00
Luis Saldana 0 Reputation points
1 answer

Database schema change of result in query sql server

How we can get database schema change result in query sql server? Is there any tool ? Suppose we do any change in schema. I want the result of that change in query.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2023-11-16T22:31:07.1766667+00:00
Kanav Sharma 25 Reputation points
commented 2024-12-06T18:03:35.93+00:00
Marie Phillips 0 Reputation points
2 answers One of the answers was accepted by the question author.

Create JSON file and import as a table

Hi, This should be simple, but I tried various options and can not get it to work. I'm trying the following: SELECT TOP (100) ADMIN_AUDIT.admin_audit_id AS [id] , ADMIN_AUDIT.admin_audit_dttm AS [time] , ADMIN_AUDIT.process_txt AS…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-11-27T21:12:31.1+00:00
Naomi Nosonovsky 7,971 Reputation points
accepted 2024-12-01T00:27:07.44+00:00
Naomi Nosonovsky 7,971 Reputation points
3 answers One of the answers was accepted by the question author.

loop through table records and execute Stored Proc with row data as params in sql server

Hi, I import data from csv file into a temp table. I need to loop through each row and call Stored procedure and pass that row details to the stored procedure as parameters. I know that it can be done using cursor and i have implemented it. I would…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2022-05-12T13:57:59.817+00:00
Spunny 326 Reputation points
commented 2024-11-28T16:11:33.4966667+00:00
Brian Downey 0 Reputation points
2 answers One of the answers was accepted by the question author.

Account ledger query with debit and credit

Hi All respected community member, i am trying to develop ledger query from long time still i could not get ,please do review and help me out , if you have any suggestion for restructure #tbl_Transection_test table ,please let me know or guide me…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
107 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-11-26T10:07:32.43+00:00
Analyst_SQL 3,576 Reputation points
accepted 2024-11-28T06:56:43.5266667+00:00
Analyst_SQL 3,576 Reputation points
1 answer One of the answers was accepted by the question author.

Migrating existing packages - C# task is failing on a new server

Hi, We're migrating our SSIS server to a new server. Original server is Windows Server 16, SQL Server 2019. New server is Windows Server 2022 and OS is SQL Server 2022. We're getting the error on the packages that use C# script task: Code: 0x00000005 …

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-11-21T23:58:54.0533333+00:00
Naomi Nosonovsky 7,971 Reputation points
commented 2024-11-27T16:27:22.74+00:00
Naomi Nosonovsky 7,971 Reputation points
2 answers One of the answers was accepted by the question author.

Maximum Length Exceeded

I am seeing the following error in my logs: EntityFramework.Exceptions.Common.MaxLengthExceededException: Maximum length exceeded ---> Microsoft.Data.SqlClient.SqlException (0x80131904): String or binary data would be truncated in table 'dbo.Profile',…

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
766 questions
Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-11-22T14:57:18.8166667+00:00
Mike-E-angelo 561 Reputation points
edited the question 2024-11-25T05:27:49.19+00:00
ZoeHui-MSFT 38,796 Reputation points
2 answers

SQL Recursive query to generate output

Hello Expert , I am trying to generate one output as: Two different Tables: Table1: Cat1, Vol,Rank Cat1, 1, 1 Cat1, 4, 2 Cat1, 6, 3 Table2: Rank, Vol_Threshold, Partition 1, 21, 1 2, 27, 2 3, 34, 3 Would like to generate output: if running first…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-11-18T12:14:09.0766667+00:00
Avanish Tomar 0 Reputation points
commented 2024-11-22T07:17:52.2866667+00:00
LiHongMSFT-4306 29,441 Reputation points
1 answer

How to covert UTC time to CST

I have a dataset recorded in UTC format. I want to covert it and add a field as CST. I used convert(datetime, switchoffset(convert(datetimeoffset, @UTCTime), datename(TzOffset, sysdatetimeoffset()))) to covert CST. However, I found it changed the time…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-11-04T22:10:18.3466667+00:00
2956 1 Reputation point
commented 2024-11-22T06:33:10.26+00:00
LiHongMSFT-4306 29,441 Reputation points
2 answers

How detecting the field that causes "string or binary data would be truncated" error

Hi, I'm working on a SQL Server 2017 (RTM-CU31-GDR) instance and I'm testing an INSERT INTO ... SELECT ... FROM ... statement that unfortunately causes a "string or binary data would be truncated" error. If possible, I'd like to save…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-10-31T17:10:14.1766667+00:00
pmscorca 1,007 Reputation points
commented 2024-11-22T06:18:33.1966667+00:00
LiHongMSFT-4306 29,441 Reputation points
1 answer One of the answers was accepted by the question author.

partition by

Hi, how to add partition by in below table where there is no date key or duration..please give example here is example of sample data customerid - 1 product - grains productcategory-rice sales- 1000

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-11-20T20:43:21.9033333+00:00
Vineet S 1,350 Reputation points
accepted 2024-11-21T02:14:32.33+00:00
Vineet S 1,350 Reputation points
1 answer One of the answers was accepted by the question author.

performance tuning in sql

Hi, how to do a performance tuning in large set of sql data ... please help me with the steps and not link how cluster and not cluster index works in terms of disk space and memory

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-11-19T14:04:23.5733333+00:00
Vineet S 1,350 Reputation points
accepted 2024-11-19T22:33:11.26+00:00
Vineet S 1,350 Reputation points
2 answers One of the answers was accepted by the question author.

Bulk Insert not working in SQL Server 2016

Hi, I am trying to insert the following CREATE TABLE Palletinfo ( id int IDENTITY(1,1) PRIMARY KEY, Parcel_Id varchar(20), Pallet_Id varchar(10), Date_Upload datetime, ); ID,Parcel ID,Pallet_ID,Date_Upload …

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2021-02-10T11:12:13.057+00:00
Christopher Jack 1,616 Reputation points
commented 2024-11-18T16:05:11.91+00:00
Hans Haupt 0 Reputation points
1 answer One of the answers was accepted by the question author.

find duplicate record

Hi, have 3 rows in one table how to remove 2 duplicate from table 1, 2, 3 1, 2, 3 1, 2, 3

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,207 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,668 questions
asked 2024-11-16T08:40:28.9666667+00:00
Vineet S 1,350 Reputation points
accepted 2024-11-16T14:44:23.7366667+00:00
Vineet S 1,350 Reputation points