130 questions with SQL Server Transact-SQL tags

Sort by: Updated
0 answers

How to truncate logs with log shipping enabled

Hello, I have a SQL Server 2016 server with multiple SQL Server instances acting as primary server in a log shipping configuration. I have configured log shipping as per…

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.
130 questions
asked 2025-02-28T09:32:57.27+00:00
Stefanos Evangelou 116 Reputation points
0 answers

listener issue

Failed to retrieve data for this request.(Microsoft.SQLServer.Management.sdk.sfc)

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.
130 questions
asked 2025-02-27T05:10:29.93+00:00
Mohammad Abid (SONATA SOFTWARE NORTH AMERICA INC) 0 Reputation points Microsoft Vendor
commented 2025-02-28T09:02:40.9133333+00:00
Mohammad Abid (SONATA SOFTWARE NORTH AMERICA INC) 0 Reputation points Microsoft Vendor
2 answers

CPU HyperThreading Core evaluation

Hello, We are currently trying to evaluate our current On-Prem Sql Server CPU HyperThreading Core evaluation for license cost purpose. Our current Sql Servers are from 2014 to 2019 sql version. Is it any prefer way I can estimate that Sql server has the…

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.
130 questions
asked 2025-02-27T20:32:42.79+00:00
pdsqsql 411 Reputation points
answered 2025-02-28T02:32:06.5733333+00:00
LiHongMSFT-4306 30,826 Reputation points
2 answers

removestaledbentries: cleanup of stale db entries skipped beacuse master db is not memory optimized

removestaledbentries: cleanup of stale db entries skipped beacuse master db is not memory optimized The above message is occurring frequently and persistently. How can I resolve this issue?" sql-server 2022

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.
130 questions
asked 2025-02-26T05:37:46.5733333+00:00
T Lee 0 Reputation points
answered 2025-02-28T00:51:27.92+00:00
T Lee 0 Reputation points
1 answer

How to replace all illegal XML chars when casting to XML

Hi, What is the proper way to cast varchar value to XML which may contain illegal XML characters? Can you please explain with CDATA or should it be complex replace command? Thanks in advance.

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.
130 questions
asked 2025-02-27T18:10:56.1533333+00:00
Naomi Nosonovsky 8,191 Reputation points
answered 2025-02-27T22:24:45.4366667+00:00
Erland Sommarskog 117.8K Reputation points MVP
2 answers

Azure SQL - can't drop system versioned tables

Hello. I'm can't drop system versioned tables in master db in Azure SQL I have a docs - https://learn.microsoft.com/en-us/sql/relational-databases/tables/stopping-system-versioning-on-a-system-versioned-temporal-table?view=azuresqldb-current but…

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.
130 questions
asked 2025-02-26T09:06:45.93+00:00
Vitalii Bohachov 0 Reputation points
commented 2025-02-27T21:59:11.06+00:00
Erland Sommarskog 117.8K Reputation points MVP
1 answer

No drag and drop on SQL Server Management Studio on external display after installing update KB5051987

After installing the following update last Tuesday, I've lost the drag and drop feature in SQL Server Management Studio: 2025-02 Cumulative Update for Windows 11 Version 24H2 for x64-based Systems (KB5051987) The mouse drag'n'drop is completely disabled…

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.
130 questions
asked 2025-02-21T20:13:46.6+00:00
Alberto Silva 0 Reputation points
commented 2025-02-27T15:36:31.14+00:00
Alberto Silva 0 Reputation points
1 answer

Install error for packages-microsoft-prod.deb

I am following the guide here:…

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.
130 questions
asked 2025-02-26T22:21:40.04+00:00
Eric Soulliard (UHC) 0 Reputation points
commented 2025-02-27T14:33:38.96+00:00
Eric Soulliard (UHC) 0 Reputation points
2 answers One of the answers was accepted by the question author.

Does the order of JOIN criteria's matter?

I'm currently trying to figure out if the order or JOIN criteria's has an influence on performance. Example query: SELECT * FROM table1 AS t1 JOIN table2 AS t2 ON t1.col1 = t2.col2 AND t1.col2 = t2.col2 ... AND t2.coln = t2.coln ```What I…

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.
130 questions
asked 2025-02-26T08:16:31.36+00:00
Johannes Maly 101 Reputation points
accepted 2025-02-27T06:14:29.9566667+00:00
Johannes Maly 101 Reputation points
1 answer

Upgraded to Windows 11 from Windows 10, Excel Macro that fetches SQL data no longer works

Windows 11 Excel macro connect to sql server 2008 not working. Receiving System Error &H80004005 (-2147467259). Unspecified error. Any ideas on how to get this to work? The Excel macro works from Windows 10.

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.
130 questions
asked 2025-02-25T22:17:26.1666667+00:00
Jimmy Jimenez 0 Reputation points
commented 2025-02-27T03:10:23.28+00:00
LiHongMSFT-4306 30,826 Reputation points
1 answer One of the answers was accepted by the question author.

does sql auditing log the same as sql defender

we have auditing enabled and sql defender both writing to log analytics workspaces, am I doubling my storage cost in doing so?

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.
130 questions
asked 2025-02-26T12:32:49.45+00:00
John Allen 60 Reputation points
accepted 2025-02-26T22:24:54.4266667+00:00
John Allen 60 Reputation points
0 answers

Recover a Database

Recover a Database that was deleted and the point in time recovery after 7 days has elapsed

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.
130 questions
asked 2025-02-25T07:59:52.4433333+00:00
Jonathan Pretorius 0 Reputation points
commented 2025-02-26T03:11:16.7633333+00:00
LiHongMSFT-4306 30,826 Reputation points
1 answer One of the answers was accepted by the question author.

Function on Column used in Index - need optimization advice

First, is this the proper forum for MS SQL tsql questions? Why am I seeing only 114 questions? OK, so we have a table ods_DDAHIS which has a TransDate column that is numeric in format YYYYMMDD. There is an index on ods_DDAHIS.Transdate. Then view…

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.
130 questions
asked 2025-02-18T21:38:57.8033333+00:00
Grossnickle, Brenda 120 Reputation points
accepted 2025-02-21T15:26:40.43+00:00
Grossnickle, Brenda 120 Reputation points
1 answer One of the answers was accepted by the question author.

How to add total sum of per Customer under each ID

I have a demo table like this: OrderID CustomerID ProductID OrderAmount OrderDate 1 101 201 100.00 2024-08-01 00:00:00.000 2 101 202 150.00 2024-08-03 00:00:00.000 3 102 201 200.00 2024-08-10 00:00:00.000 4 101 203 120.00 2024-09-15…

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.
130 questions
asked 2025-02-21T02:30:27.2933333+00:00
Zhu 20 Reputation points
accepted 2025-02-21T06:45:07.57+00:00
Zhu 20 Reputation points
1 answer

Request: Safe Updates Feature in SQL

This feature prevents UPDATE or DELETE queries from executing unless they include a WHERE clause or a LIMIT. It's a safeguard against accidental table-wide modifications and helps maintain data integrity. I believe SQL Server would greatly benefit from a…

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.
130 questions
asked 2025-02-20T15:40:18.7433333+00:00
Mohammad.safyar 0 Reputation points
commented 2025-02-21T01:53:17.92+00:00
LiHongMSFT-4306 30,826 Reputation points
1 answer One of the answers was accepted by the question author.

High parallelism in Query Store.

Greetings. As you see in the screen shot the bulk of my wait time is going to one wait type. A few fun facts: This is in a reporting type DB with the bulk of activity coming from ETL and Power BI queries, no OLTP type stuff at all. Maxdop on the…

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.
130 questions
asked 2025-02-19T17:12:20.9666667+00:00
chrisrdba 471 Reputation points
commented 2025-02-20T13:35:27.52+00:00
chrisrdba 471 Reputation points
1 answer One of the answers was accepted by the question author.

Need tsql to find index usage on views

I have some views that have indexes and i want to get their usage - seeks, scan, lookups - but i cannot find the tsql code.

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.
130 questions
asked 2025-01-15T22:35:28+00:00
Grossnickle, Brenda 120 Reputation points
accepted 2025-02-18T21:04:54.8233333+00:00
Grossnickle, Brenda 120 Reputation points
1 answer

SQL gaps and island issue

Greetings!!! We're working on migrating data from a legacy application and have a requirement to get all the consecutive SESSION START_DATE & END_DATE. For the SESSION_ID - 8642, SESSION_TYPE - 3256, based on the requirement using sql server 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,490 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.
130 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,690 questions
asked 2025-01-21T05:59:20.4966667+00:00
Raj D 611 Reputation points
edited a comment 2025-02-15T14:09:46.71+00:00
Erland Sommarskog 117.8K Reputation points MVP
1 answer One of the answers was accepted by the question author.

How to figure out the total number of doses within a time span given to a client as dose are being added and stopped.?

If the cadence values are different, even if the dates overlap the records must be separate. If an order for the same dose and cadence value (including nulls) starts on the same day or the next day (+or-1 day) the record should continue. outlook of…

Azure SQL Database
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.
130 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,690 questions
asked 2024-07-22T22:24:04.8633333+00:00
andrew omofonma 61 Reputation points
edited the question 2025-01-27T04:28:08.7933333+00:00
Rakesh Gurram 12,490 Reputation points Microsoft Vendor
1 answer One of the answers was accepted by the question author.

A Simple SQL Query

I have the following table:- I want Col 1 and Col 2 where Col2 =1 and the corresponding all the values of Col 1 where Col 1 =2. But this is an example. I can find 1st part (i.e,, Select Col1, Col 2 from Table1 where Col 2 =1). But my problem is how do…

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,490 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.
130 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,690 questions
asked 2025-01-21T14:07:34.2966667+00:00
chuck DM 101 Reputation points
commented 2025-01-22T07:23:58.6166667+00:00
Olaf Helper 46,196 Reputation points