27 questions with SQL Server Transact-SQL tags

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

Easiest way to verify that SQL has access to a folder that would contain mdf and ldf files

Re: Easiest way to verify that SQL has access to a folder that would contain mdf and ldf files I am writing a script to move ldf and/or mdf files. Doing the basic ALTER DATABASE commands below, but writing them in dynamic SQL so that multiple 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.
27 questions
asked 2024-03-07T13:56:37.7066667+00:00
Grossnickle, Brenda 40 Reputation points
accepted 2024-03-14T16:51:28.9766667+00:00
Grossnickle, Brenda 40 Reputation points
1 answer

How to determine which row in a table a LOB Page is connected to?

I have a table with Lob Data Pages, using DBCC IND and DBCC PAGE to look at a page, I am curious if there is a way to determine which record in the table the data on that page is tied too?

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,404 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.
27 questions
asked 2024-03-12T21:15:51.3066667+00:00
John Couch 181 Reputation points
commented 2024-03-13T04:18:12.9233333+00:00
Greg Low 1,150 Reputation points Microsoft Regional Director
2 answers One of the answers was accepted by the question author.

The conversion of a nvarchar data type to a datetime

When I get a report via view, I get an error like this. how can i fix this

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,404 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.
27 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,532 questions
asked 2024-02-20T09:21:41.4+00:00
Rabia Kurnaz 386 Reputation points
accepted 2024-03-08T07:54:56.8866667+00:00
Rabia Kurnaz 386 Reputation points
2 answers One of the answers was accepted by the question author.

Could drop user sa?

Dear Sir/Madam As we know user sa is default user that have sid=0x01 is_disabled=0 principal_id=1 on sys.server_principals table. Could we drop it to protect from attacker? Srean Regard Thank

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.
27 questions
asked 2024-03-07T04:53:58.0233333+00:00
Srean Noem 20 Reputation points
accepted 2024-03-07T06:33:57.32+00:00
Srean Noem 20 Reputation points
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,380 questions
Azure SQL Database
Azure VMware Solution
Azure VMware Solution
An Azure service that runs native VMware workloads on Azure.
305 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.
27 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 100.1K Reputation points MVP
2 answers

sys.dm_exec_cached_plans not showing any data after executing stored proc multiple times.

Executed different stored proc multiple times and ran below query to check stats. its not showing any data. SQL Version : Microsoft SQL Server 2012 (SP4) (KB4018073) - 11.0.7001.0 (X64) Stored Proc : exec [dbo].[uspGetManagerEmployees]…

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,404 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.
27 questions
asked 2024-02-16T16:39:46.52+00:00
SSR 20 Reputation points
commented 2024-02-29T06:47:40.4133333+00:00
CosmogHong-MSFT 21,146 Reputation points Microsoft Vendor
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,404 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.
27 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 21,146 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,404 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,756 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,426 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,239 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.
27 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 21,146 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,404 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.
27 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 100.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.
27 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 39,886 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.
27 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,532 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) 53,251 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.
27 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 100.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,404 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,756 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.
27 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,532 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.
27 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,532 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,656 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,404 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.
27 questions
asked 2024-02-09T12:23:46.3266667+00:00
YETIANRI EMMANUEL OUSMANE SORI 201 Reputation points
accepted 2024-02-13T07:17:31.0966667+00:00
YETIANRI EMMANUEL OUSMANE SORI 201 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,404 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.
27 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 100.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.
27 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 110.3K 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.
27 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 315 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,404 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.
27 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,532 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 21,146 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,404 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.
27 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 100.1K Reputation points MVP