4,555 questions with Transact-SQL-related tags

Sort by: Updated
2 answers

Connect to on-prem sql server using Azure Relay

Hi, I would like to connect to a on-prem sql server and execute T-SQL commands to listen and receive SQL broker messages from Azure cloud hosted .net application. How can i connect to on-prem sql server and execute these sql commands and receive the…

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,412 questions
Azure Fluid Relay
Azure Fluid Relay
An Azure service used to add real-time collaborative experiences to apps with Fluid Framework.
2 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.
46 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-04-01T07:44:00.09+00:00
Santhi Dhanuskodi 145 Reputation points
edited the question 2024-04-15T16:10:13.3+00:00
MayankBargali-MSFT 68,656 Reputation points
2 answers

Delete query throws "semaphore timeout period has expired"

Hi All, I'm running a delete query as part of purge activity. The delete query has about 12+ foreign key constraints, and when we try to delete 1300 records as per our condition we get the below error. The table has about only 15K records and the db…

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.
12,789 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-04-09T17:56:57.0133333+00:00
Arunkumar Janakiraman 1 Reputation point
answered 2024-04-12T05:04:08.69+00:00
ShaktiSingh-MSFT 13,751 Reputation points Microsoft Employee
1 answer

Complex Pivot using the existing data

--ALTER PROCEDURE Energy.GetGTSTDataForManualEntry --( -- @Date DateTime -- ) --AS BEGIN DECLARE @Date DateTime = '2024-03-29 00:00:00.000'; DECLARE @CalendarID INT = Time.GetCalendarIDByLocationCode('Energy'); DECLARE @DayPeriod…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,789 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.
46 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-04-07T09:23:56.2033333+00:00
pepcoder 1 Reputation point
edited a comment 2024-04-11T05:13:40.8+00:00
pepcoder 1 Reputation point
3 answers

Oracle Connector on Polybase

Hi everyone, I currently have Polybase (SQL Server 2019 RTM) that connects to Oracle database. This was working well untill the Oracle database was upgraded to 13c and I started getting this error: TNS: Listner could not resolve SERVICE_NAME…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,789 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2022-08-25T15:35:27.173+00:00
tobz 161 Reputation points
answered 2024-04-08T22:51:22.22+00:00
Robishaw, Eric 0 Reputation points
1 answer One of the answers was accepted by the question author.

Convert 14 Char String to Datetime

I have a field in a table called TraceID that stores data like this: 2024040611102200021 The first 8 characters represent the date (YYYYMMDD). The next 6 characters represent the time (HHMMSS). The last five are insignificant numbers. So this would be…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,789 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-04-06T15:15:48.1066667+00:00
Dom 751 Reputation points
commented 2024-04-07T12:28:13.28+00:00
Dom 751 Reputation points
1 answer

Transpose column to rows

Hi, Without using a cursor (if poss) I would like to turn the following data into rows based based upon the integer in column two. So I would end up with 5 rows for the first date, 1 for the second etc. Can anyone advise on how best to do this pls?…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-04-05T08:59:01.73+00:00
Dave Gray 581 Reputation points
answered 2024-04-05T20:14:16.1866667+00:00
Bruce (SqlWork.com) 56,851 Reputation points
1 answer

SQl Server Agent "Unexpected Termination" with no error details

Hi, I have built an SSIS project where one main package refers to and carries out over 30 other packages in succession. Each package does the same job - uses an excel sheet as a source to then update the same data stored in a SQL Server 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.
12,789 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,459 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2022-07-13T12:04:38.75+00:00
Dan Gallagher 6 Reputation points
commented 2024-04-02T11:45:06.3433333+00:00
Paolo Cos 31 Reputation points
3 answers

DATEDIFF (YEAR, StartDate, EndDate) returns incorrectly

I am trying to figure out why the DATEDIFF(YEAR) Function is returning incorrectly and am wondering if I have to get the StartDate and EndDate in a certain format before attempting to use the function. SELECT DATEDIFF(YEAR, '2023-12-31 08:31:42.373',…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,789 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.
46 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-03-28T13:03:43.4066667+00:00
Bobby P 221 Reputation points
answered 2024-03-29T02:13:05.4266667+00:00
CosmogHong-MSFT 23,321 Reputation points Microsoft Vendor
1 answer

display rtf saved in the database with proper format in react app

I have c# desktop application using the Microsoft's built in Microsoft Rich Textbox Control and we have used it to save the rtf in mssql database. now i do want to display the rtf fetched from the database to be displayed in my react application with the…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-03-13T16:09:09+00:00
aynuayex 0 Reputation points
edited an answer 2024-03-28T21:17:01.52+00:00
Bruce (SqlWork.com) 56,851 Reputation points
1 answer

The MSSQLSERVER service terminated unexpectedly

Dear All SQL expert, Do you know what is the case that make The MSSQLSERVER service terminated unexpectedly? Recently, The SQL server (MSSQLSERVER) and SQL Server Agent are stopped automatically during running import data to sql server. We are using…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,789 questions
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,811 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.
46 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-03-27T05:07:01.8566667+00:00
Suy Peang 91 Reputation points
commented 2024-03-28T06:18:59.3333333+00:00
Suy Peang 91 Reputation points
4 answers

Azure SQL Database large tables performance Issue

In my Azure SQL Database, there exists a considerably large table, let's call it 'tableA'. In my application, I have several distinct queries (approximately 10) that involve different sets of columns from this table. For example, 'query1' utilizes…

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.
12,789 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-03-19T11:58:45.5833333+00:00
Arundhati Sen 151 Reputation points
answered 2024-03-27T22:45:29.02+00:00
Erland Sommarskog 101.6K Reputation points MVP
2 answers

Rewriting an Oracle procedure with cursor in a T-SQL procedure

Hi, I need to rewrite an Oracle procedure that uses heavily a cursor in a T-SQL stored procedure. An Oracle cursor is an object more efficient/performant than a T-SQL cursor and moreover the Oracle procedure logic works row by row and has several IF ...…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,789 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-03-23T20:46:10.0933333+00:00
pmscorca 792 Reputation points
answered 2024-03-27T22:40:35.5366667+00:00
Erland Sommarskog 101.6K Reputation points MVP
3 answers

has inline function got any catch?

hi, I heard many people saying "functions are denounced in tsql" is there any catch? q1) need to know what are the cases where we should not use? q2) should we avoid scaler functions also? q3) should we avoid scaler functions if we have 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.
12,789 questions
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,811 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,459 questions
SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,245 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-03-11T05:57:35.8533333+00:00
Rajesh Kumar Yadav 0 Reputation points
answered 2024-03-26T17:11:52.99+00:00
Bruce (SqlWork.com) 56,851 Reputation points
3 answers One of the answers was accepted by the question author.

SQL Server : Get size of all tables in database

The above sql works fine but i want the size in KB OR MB OR GB at the end i want a new column which show total size like TableSizeInMB+IndexSizeInMB KB OR MB OR GB ;with cte as ( SELECT t.name as TableName, SUM (s.used_page_count) as…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2021-07-11T08:28:44.977+00:00
T.Zacks 3,986 Reputation points
edited a comment 2024-03-21T17:20:28.94+00:00
Julio Kawai 5 Reputation points
4 answers One of the answers was accepted by the question author.

I would like some advice on how to use a query to get the total size of each disk drive.

When I try to get the total size of each disk drive using sp_OAGetProperty in mssql, I cannot get a value greater than 17,592,186,040,320 for large drives. I would like to ask for advice on a solution that can be checked using a query. And I don't want…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,789 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-03-15T06:49:13.85+00:00
준영 이 40 Reputation points
commented 2024-03-18T23:46:08.8066667+00:00
준영 이 40 Reputation points
0 answers

stored proc

Hello, I have a stored procedure which does the following: 1- filter tables and place data into #table1 2- filter tables and place data into #table2 ... Then at the end of the stored proc, select columns by joining these #tables. I have several stored…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-03-18T16:32:41.9133333+00:00
arkiboys 9,641 Reputation points
1 answer One of the answers was accepted by the question author.

Statement causes error

Dear All, What's wrong with the statement "create index engnamestuid on engname + cast(student as nvarchar(6))"?

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-03-16T08:29:12.0633333+00:00
BenTam 1,561 Reputation points
accepted 2024-03-16T12:09:47.42+00:00
BenTam 1,561 Reputation points
4 answers

slow execution WHEN update chemical id on table chemicalhash so how to enhance it ?

I work on sql server 2017 i need update chemical id on table chemicalhash based on 3 columns compare to table fmd chemical compare 3 columns strSubstances,strMass,strCASNumber from table chemicalhash with 3 columns strSubstances,strMass,strCASNumber from…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,789 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2022-05-17T01:08:48.69+00:00
ahmed salah 3,216 Reputation points
edited an answer 2024-03-15T20:26:59.0833333+00:00
Bruce (SqlWork.com) 56,851 Reputation points
2 answers

How to get parts from table part and not exist on both tables chemical missing and chemical master ?

I work on sql server 2012 i need to get parts from table part and not exist on both tables chemical missing and chemical master by using exist or not exist and if there are more ways please help me I need to rewrite these statement with another…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,789 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2021-01-15T00:30:58.383+00:00
ahmed salah 3,216 Reputation points
answered 2024-03-15T13:49:21.59+00:00
https://www.ChemicalSuppliers.com 0 Reputation points
2 answers

SSRS Dataset using #Temp Tables

I could have sworn I have done this before. I have multiple Datasets in my SSRS .rdl. The first Dataset creates the #Temp Tables which subsequent Sub-Reports and SQL Server Stored Procedures and Datasets utilize. Also, utilizing the Use single…

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,811 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
asked 2024-03-14T21:39:06.71+00:00
Bobby P 221 Reputation points
answered 2024-03-15T06:01:18.5866667+00:00
Olaf Helper 40,916 Reputation points