42 questions with SQL Server Transact-SQL tags

Sort by: Updated
1 answer

Database consistency check for 2 TB database taking 14 hours 20 mins

1)Database size is 2 TB 2)Largest Tables (only one large table) Total pages it has - 274190987 3)Execution for this single DB consistency check is 13 hours 38 minutes 23 seconds. ---most of the time we had to cancel the execution just to avoid conflicts…

Windows Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
3,467 questions
Azure SQL Database
Azure VMware Solution
Azure VMware Solution
An Azure service that runs native VMware workloads on Azure.
318 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.
42 questions
asked 2024-02-28T16:42:06.3033333+00:00
Dhaval Ambawade 0 Reputation points
commented 2024-02-29T22:18:01.6466667+00:00
Erland Sommarskog 101.1K Reputation points MVP
2 answers

Why Dynamic Sql written in procedure working and returning data on development server but not returning on production server

Why Dynamic Sql written in procedure working and returning data on development server but not returning on production 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.
12,743 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.
42 questions
asked 2024-02-08T16:39:24.89+00:00
BIDYUT KARMAKAR 0 Reputation points
commented 2024-02-29T06:08:29.9433333+00:00
CosmogHong-MSFT 23,246 Reputation points Microsoft Vendor
3 answers

Cannot connect to SQL Management studio 19.3

Hi Microsoft team, I have been trying to connect to the SQL server for a long time now and i have been getting error message cannot connect to.... How can i overcome this challenge?

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,743 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,806 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,454 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
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.
42 questions
asked 2024-02-08T16:10:07.1266667+00:00
Boluwaji Olusegun 0 Reputation points
commented 2024-02-29T05:56:26.4866667+00:00
CosmogHong-MSFT 23,246 Reputation points Microsoft Vendor
1 answer One of the answers was accepted by the question author.

Subquery makes complet code very slow

Hello, I have the following query that uses another query. As I understand the runtime behavior, this second query is called again every time the main query creates a new record. Both queries are actually quite fast. Unfortunately, the overall construct…

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,743 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.
42 questions
asked 2024-02-24T16:15:05.8866667+00:00
Hans Furmann 40 Reputation points
commented 2024-02-25T14:11:43.1966667+00:00
Erland Sommarskog 101.1K Reputation points MVP
1 answer

SQL Server unit test Item - Unable to locate version 17.10

Hi, I have installed Visual Code v 17.10 to start Unit testing but I'm unable to locate new item called Unit Test, Any thoughts where to locate or install to see SQL Server Unit Test item?

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.
42 questions
asked 2024-02-23T05:53:46.3933333+00:00
Imdaad Khan 0 Reputation points
answered 2024-02-23T06:28:38.12+00:00
Olaf Helper 40,896 Reputation points
3 answers

Best Practice/Standard Alias Schema/Table Convention

Just looking for suggestions for best practices and/or standards for table aliases in a Query. I know this is very subjective...but just looking for some general guidelines from experts and their experience and what works and what might not work. Should…

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.
42 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
asked 2024-02-21T15:20:45.85+00:00
Bobby P 221 Reputation points
answered 2024-02-22T00:47:33.9466667+00:00
Bruce (SqlWork.com) 56,531 Reputation points
2 answers

select query where condition with in operator and string with %

Hi, Below query is not working with in operator and string having % sign. DECLARE @types Table ( ID int, type varchar(50) mailtype varchar(50) ) INSERT INTO @types (ID, type, mailtype) SELECT 1, 'Redem', 'ABS_HOME' UNION SELECT 2,…

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.
42 questions
asked 2024-02-20T16:53:10.2966667+00:00
Spunny 326 Reputation points
edited the question 2024-02-20T22:31:27.2133333+00:00
Erland Sommarskog 101.1K Reputation points MVP
1 answer One of the answers was accepted by the question author.

Grouping Data

Hello there, I need a help about the SQL Query. Data example: Date Amount 2024-01-11 10:15 1000 2024-01-11 11:10 2000 2024-01-12 10:16 5000 2024-01-13 11:12 4000 2024-01-13 11:18 4000 Expeceted result: Date Amount…

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,743 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,806 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.
42 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
asked 2024-02-14T09:10:13.5133333+00:00
Kuler Master 246 Reputation points
accepted 2024-02-14T21:06:02.1566667+00:00
Kuler Master 246 Reputation points
2 answers

Azure SQL Database Stored Procedure long execution time issue

In my Azure SQL Database I have Stored Procedure sp_subledger (Attached the code : sp_subledger.txt) The Stored Procedure is completing within 1 min when Tenant = 1 is provided but when Tenant = 2 is provided it is running for more than 2 hours. for…

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.
42 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
asked 2024-02-07T16:10:08.8533333+00:00
Arundhati Sen 151 Reputation points
commented 2024-02-13T22:15:14.64+00:00
Saurabh Sharma 23,751 Reputation points Microsoft Employee
2 answers One of the answers was accepted by the question author.

language of sql server 2022 and SSMS

Hello, I installed sql server 2022 and ssms in English on my machine. how to change the language to French of my sql server 2022 and my ssms. Best Regards

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,743 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.
42 questions
asked 2024-02-09T12:23:46.3266667+00:00
YETIANRI EMMANUEL OUSMANE SORI 241 Reputation points
accepted 2024-02-13T07:17:31.0966667+00:00
YETIANRI EMMANUEL OUSMANE SORI 241 Reputation points
1 answer One of the answers was accepted by the question author.

Where to graph precise tsql for a query run from php

I'd like to pin a plan for a query by adding a table hint. I've read the docs that says the query text pasted into @stmt must be the same as came from the app. I used the Extended Events 'sql_statement_completed' and 'rpc_completed' to get precise sql…

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,743 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.
42 questions
asked 2024-02-09T21:33:40.59+00:00
Jan Vávra 231 Reputation points
commented 2024-02-09T22:35:46.38+00:00
Erland Sommarskog 101.1K Reputation points MVP
1 answer

sql select query

Hi, We get data from vendor and import into table like this TxID BCode Ecode SType SCode Desc 12345 SR SR MF Abc This is one type 12346 SD SD MF Bcd One more type 12347 CC SD OF Efg New type 12348 SR SR MF Xyz I get…

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.
42 questions
asked 2024-02-06T15:03:38.7633333+00:00
Spunny 326 Reputation points
edited a comment 2024-02-09T06:30:03.11+00:00
Viorel 112.4K Reputation points
1 answer

The underlying provider failed on Open. while connecting to SQL Azure database through mvc application login

I've deployed my MVC application successfully on Azure..But while logging into application I get "The underlying provider failed on Open." I've implemented transient failure in code also. I connected my application locally to Azure SQL DB, its…

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.
42 questions
asked 2024-01-17T08:55:29.19+00:00
Dhananjay 0 Reputation points
answered 2024-02-06T04:19:28.3833333+00:00
hossein jalilian 2,990 Reputation points
1 answer

How to calculate number of weeks worked by an employee for a fiscal year in sql server

How to determine the total weeks an employee has worked during a fiscal year using SQL Server. My start date is 12-28-2023 and till today, I would like to calculate the no.of weeks worked by an employee during that 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.
12,743 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.
42 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
asked 2024-02-02T20:23:26.1633333+00:00
Maddi, Shyam 0 Reputation points
commented 2024-02-05T03:32:24.3566667+00:00
CosmogHong-MSFT 23,246 Reputation points Microsoft Vendor
1 answer

How can I close this Configuration review point 'Sanitize Database and Application User Input '

How we can close this configuration review point on Sanitize Database and Application User Input can you please guide me to close

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,743 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.
42 questions
asked 2024-02-02T05:07:46.3066667+00:00
Srinivas Syamala 20 Reputation points
answered 2024-02-02T22:13:58.26+00:00
Erland Sommarskog 101.1K Reputation points MVP
1 answer One of the answers was accepted by the question author.

From which version did SQL Server start showing the actual duplicate value in primary key violations

Dear Experts, Could you please let me know from which version did SQL Server start showing the actual duplicate values in primary key violations. Take for example, in some older versions, I only see something like this. "Violation of PRIMARY KEY…

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,743 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.
42 questions
asked 2024-02-01T13:14:54.7066667+00:00
mo boy 396 Reputation points
accepted 2024-02-02T00:00:15.31+00:00
mo boy 396 Reputation points
1 answer

T-SQL R language - return fewer columns

I'm running an R language script under T-SQL where I use REGEX to validate data in two columns. However I only want to output the id column in my result set. My script is: EXECUTE sp_execute_external_script @language = N'R', @script = N' pattern =…

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.
42 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
asked 2024-02-01T13:47:50.79+00:00
Peter Bishop 161 Reputation points
answered 2024-02-01T14:06:39.1+00:00
Peter Bishop 161 Reputation points
1 answer

sqlpackage export data

Is it possible to export data only of all the tables in the DB using sqlpackage export action? Schema is not to be included in the .bacpac file.

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,743 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.
42 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
asked 2024-01-22T10:36:27.7466667+00:00
Indiana 0 Reputation points
commented 2024-01-29T02:09:26.5666667+00:00
CosmogHong-MSFT 23,246 Reputation points Microsoft Vendor
2 answers

How to do the bulk insert of one lack records in sql server using node js

Hi, I will store the data in following Json format. Now I want to insert this one lack. records in sql server. Kindly Please provide the best solution and if it's possible share your solution with sql query. [ { key: value, key: value, key: value, key:…

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,743 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.
42 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
asked 2024-01-22T13:07:05.89+00:00
Arutprakasam 261 Reputation points
answered 2024-01-22T22:29:53.3633333+00:00
Konstantinos Passadis 17,286 Reputation points
4 answers

Tempdb Shrink Issue in SQL Server

Dear Support Team, I need your consultancy regarding this issue: After shrinking the tempdb in Microsoft sql management studio the tempdb does not shrink and the disk size is not reclaimed even though the db is not being used only works after a restart…

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,743 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.
42 questions
asked 2024-01-18T11:09:46.98+00:00
Jad Tabet 0 Reputation points
edited an answer 2024-01-19T07:30:51.8133333+00:00
ZoeHui-MSFT 33,126 Reputation points