4,582 questions with Transact-SQL-related tags

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

Syntax - How to use variable in LIKE clause

Trying to use a variable in the LIKE clause of a SELECT statement. Hope this is simple, but available guidance hasn't worked. As seen below, query works when a "fixed" value is used with wildcard characters, but I haven't managed to get it with…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-20T16:18:26.5933333+00:00
TreyS 166 Reputation points
accepted 2024-06-21T16:24:26.58+00:00
TreyS 166 Reputation points
2 answers One of the answers was accepted by the question author.

elapsed_time value more than query execution time?

I did take query from here in order to check performance of our queries. Executed a SP which took execution time of 1 min 45 seconds. Ran the query from the link which uses the view 'sys.dm_exec_query_stats' Highlighted rows in the screenshots are…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-20T11:09:53.1166667+00:00
Radhai Krish 141 Reputation points
accepted 2024-06-21T05:24:01.7233333+00:00
Radhai Krish 141 Reputation points
1 answer

convert returns conversion error but try_convert does return the correct value

Hi All, I have the following case statement in a TSQL script, which returns the correct negative decimal value, in the rows that acually have a value try_convert (decimal (18,6), max (case when [databody.daysQuality.testResults.testType] =…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-17T04:41:27.08+00:00
hans smeets 0 Reputation points
edited a comment 2024-06-21T04:15:08.07+00:00
hans smeets 0 Reputation points
7 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.
4,786 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.
13,115 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2023-12-19T13:11:52.4966667+00:00
Kıvanç ÖZDEMİR 125 Reputation points
commented 2024-06-21T02:25:09.6266667+00:00
Tristan Macelli 0 Reputation points
2 answers

ID's coming back as nulls are not appearing in my data set

I am trying to create a, intergrity check that bring back data after a record has been cancelled after a certain event. In my query. I am joining to a few tables and I can see all the old cancelled record. When I then cancel any new records, some IDs I…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 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.
58 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-19T13:29:32.62+00:00
Kuda 20 Reputation points
answered 2024-06-20T01:25:23.59+00:00
Bruce (SqlWork.com) 59,471 Reputation points
2 answers One of the answers was accepted by the question author.

Unexpected truncation error when inserting from UTF8 to non-UTF8 collation

I believe I am hitting a bug with moving data from a UTF8 to a non-UTF8 collations in SQL Server 2022 CU13 (running under Linux but assuming for now this issue is not related). The issue is that MSSQL appears to be determining the width of a string for…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-11T00:42:42.9533333+00:00
Ben 30 Reputation points
commented 2024-06-18T21:02:02.6166667+00:00
Erland Sommarskog 104.1K Reputation points MVP
3 answers One of the answers was accepted by the question author.

“user_scans” of table “sys.dm_db_index_usage_stats”

I am trying to find answer to the below. What exactly the scan means for the field "user_scans" being with the table "sys.dm_db_index_usage_stats" ? Like, there are tables in our prod which aren't used for sure as the module is…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-17T05:33:15.94+00:00
Radhai Krish 141 Reputation points
accepted 2024-06-18T06:14:28.97+00:00
Radhai Krish 141 Reputation points
4 answers

SSMS freezes on student computer when I demostrate TSQL queries using MS Teams on my computer

I lecture Microsoft SQL courses from my home using Microsoft Teams. I installed the latest edition of SSMS & SQL Dev 2019 Ed on my Lenovo laptop. During the lecture I would share my query window with the delegate to demonstrate TSQL queries. The…

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
9,407 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.
13,115 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,665 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2023-10-18T21:24:44.0066667+00:00
Marais Viljoen 10 Reputation points
answered 2024-06-17T14:49:01.7833333+00:00
Geoff 0 Reputation points
2 answers One of the answers was accepted by the question author.

Get Global Primary details from All the replicas in Distributed AlwaysOn

In Distributed AlwaysOn, I could not find any DMVs in SQL Server which could provide the details about Global Primary from replicas in Forwarder side (both Primary Forwarder and its local replicas). Is there a way to at-least pull the Global Primary…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-10T14:06:34.08+00:00
Sajal Bagchi 25 Reputation points
accepted 2024-06-17T13:39:37.6566667+00:00
Sajal Bagchi 25 Reputation points
1 answer One of the answers was accepted by the question author.

Querying table index stats not working

I am trying to query my tables index fragmentation in Azure Synapse studio with query: SELECT IPS.Index_type_desc, IPS.avg_fragmentation_in_percent, IPS.avg_fragment_size_in_pages, IPS.avg_page_space_used_in_percent, …

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.
4,565 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.
13,115 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,930 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-14T09:17:01.14+00:00
Jani Hämäläinen 40 Reputation points
accepted 2024-06-17T10:19:38.69+00:00
Jani Hämäläinen 40 Reputation points
3 answers One of the answers was accepted by the question author.

Partition by filter

Hey Team I have table where A values comes then E value should be filter or else E value should be there partition by data and mpr column expected values

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 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.
58 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-14T14:34:28.8633333+00:00
Vineet S 225 Reputation points
edited an answer 2024-06-14T21:11:05.9233333+00:00
Naomi Nosonovsky 405 Reputation points
2 answers One of the answers was accepted by the question author.

transpose row data into columns

Hope I'm asking this correctly. I have a table in this format: I need to have the Unique ID and the account numbers from both stores all in the same record. Like this: How can I accomplish this in SQL? Is this some kind of PIVOT or UNPIVOT? What…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-08T14:01:19.5733333+00:00
Dom 771 Reputation points
commented 2024-06-13T16:44:02.6533333+00:00
Dom 771 Reputation points
2 answers

unable to convert unique identifier

Hi Team, unable to convert this value as an unique identifier and getting null values SELECT try_convert(uniqueidentifier,''9UIC32D1-932-4V03-45E9-FGSGDASASDATY'')testid

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.
13,115 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,493 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,256 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-12T07:17:37.1633333+00:00
Vineet S 225 Reputation points
commented 2024-06-13T08:27:50.7633333+00:00
Erland Sommarskog 104.1K Reputation points MVP
2 answers

WHY Index Scan Instead Of Seek While Joining Big Table With #Temp Table

In my sql server 2016 database, I have a table 'BigData' having around 50 million rows and a Temporary table #TempID which contains 600 rows. CREATE TABLE BigData (ID INT IDENTITY(1,1) PRIMARY KEY, OtherID INT, Comment nvarchar(max),…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-10T11:46:44.9033333+00:00
Vikrant Sirohi 0 Reputation points
edited a comment 2024-06-11T03:45:37.8833333+00:00
Vikrant Sirohi 0 Reputation points
1 answer

Syntax Error When Attempting to run PREDICT function against table in dedicated pool in Synapse Studio

I am attempting to complete the tutorial listed here : https://learn.microsoft.com/en-us/azure/synapse-analytics/machine-learning/tutorial-sql-pool-model-scoring-wizard I am able to complete all of steps until I get to the final step, where I use Synapse…

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.
4,565 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-05T22:27:20.54+00:00
Andy 0 Reputation points Microsoft Employee
answered 2024-06-06T10:41:02.9033333+00:00
phemanth 7,515 Reputation points Microsoft Vendor
2 answers One of the answers was accepted by the question author.

Unable to Uninstall SQL Server 2019

I'm trying to uninstall SQL Server 2019 (64-bit) from the Control Panel, but I'm encountering errors during the uninstallation process. I was able to remove all the features, but I received a prompt to restart my system. After restarting, I noticed that…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-03T11:48:17.8633333+00:00
Pramod Kumar 20 Reputation points
edited the question 2024-06-06T06:11:01.7766667+00:00
Rakesh Gurram 4,890 Reputation points Microsoft Vendor
2 answers

How to fix Duplicate Output in sql server when using Distinct Create performance Issue

Respected Techie, I am facing very Bizarre issue of Duplicate Record in sql Output. May someone please help me with their expertise. I am very much Thankful for your kind help. The Problem I am facing is I am brining column from multiple dimension table…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-04T05:12:32.3666667+00:00
Uma 426 Reputation points
answered 2024-06-04T21:29:45.8733333+00:00
Erland Sommarskog 104.1K Reputation points MVP
1 answer One of the answers was accepted by the question author.

select top results without selecting columns

select top results without selecting columns?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-06-04T15:25:35.46+00:00
Jonathan Brotto 180 Reputation points
accepted 2024-06-04T17:59:56.2133333+00:00
Jonathan Brotto 180 Reputation points
3 answers

i have few snapshot transactions, now i need to put nolock/read uncommit for perticular table

hi, I have few snapshot transactions , now my admin has informed me that put no lock in all tables in snapshot transactions, as it was blocking locking deadlocking with others. so I suggested to put read uncommited instead of snapshot when u are…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-05-20T07:11:58.9+00:00
Rajesh Kumar Yadav 0 Reputation points
commented 2024-05-31T20:47:35.6666667+00:00
Erland Sommarskog 104.1K Reputation points MVP
2 answers One of the answers was accepted by the question author.

Benefits and disadvantages of WITH (NOLOCK)

Benefits and disadvantages of WITH (NOLOCK). Also is there other commands that can serve different use cases.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,115 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
asked 2024-05-30T15:12:46.18+00:00
Jonathan Brotto 180 Reputation points
answered 2024-05-30T21:20:01.3066667+00:00
Erland Sommarskog 104.1K Reputation points MVP