4,691 questions with Transact-SQL-related tags

Sort by: Updated
5 answers

Union two tabls with different columns

Hi Everyone, I have a table A that has 205 columns and table B that has 160 columns. Some of the columns in two tables matches but there are differnces. is there a simple way to do a union of two tables and get null for column that doesnt belong in…

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
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2022-03-03T07:17:49.363+00:00
Rohit Kochar 46 Reputation points
edited an answer 2025-03-06T15:03:59.9666667+00:00
Trond Erik Bones 0 Reputation points
3 answers One of the answers was accepted by the question author.

When indexes are not available in SQLServer

I'm looking into indexes in SQLserver. In SQLserver, when an index is created for a string type (ex.char,nvarchar) and a numeric value is specified as a search condition, the index cannot be used. Are there any other examples like this where the index…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2025-03-03T02:04:59.89+00:00
nqyuta 80 Reputation points
accepted 2025-03-04T02:58:02.56+00:00
nqyuta 80 Reputation points
3 answers

Invalid object name 'STRING_SPLIT' in SQL Server 2019

Hi Support, Our SQL server version is 2019 and check the compatibility level is 150, but it still have error "Invalid object name 'STRING_SPLIT' ". We also tried the case sensitive according to this link, both of them have the same error. …

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
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2022-04-04T02:26:23.81+00:00
Chong 871 Reputation points
answered 2025-02-20T13:23:49.2733333+00:00
Karel Bešťák 0 Reputation points
4 answers

SQL Server bulk email issue.

There is a requirement to send the notification emails on every 1st and 2nd working day of every month to all the concerned users. Since we have SQL Server as our database, we are using SQL database mail to send the mails, which is connected with smtp…

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
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,816 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2021-05-03T08:29:26.623+00:00
utsav mistry 1 Reputation point
answered 2025-02-19T15:57:16.3033333+00:00
Ramesh Donagam 0 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.
147 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2025-01-21T05:59:20.4966667+00:00
Raj D 616 Reputation points
edited a comment 2025-02-15T14:09:46.71+00:00
Erland Sommarskog 118.9K Reputation points MVP
3 answers One of the answers was accepted by the question author.

Sortable MVC Tables with Stored Procedure

Hello everyone and thanks for the help in advance. I am developing a MVC application that requires a sortable table. The issue is that the tables utilize queries that are best suited for stored procedures. While researching, I cam across older…

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,793 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.
14,490 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2025-02-06T18:27:54.7366667+00:00
Kmcnet 1,006 Reputation points
accepted 2025-02-13T16:31:39.41+00:00
Kmcnet 1,006 Reputation points
1 answer One of the answers was accepted by the question author.

Breakdown text into multiple records

Greetings... I'm working on a SQL Server query where I have to breakdown text stored in Comments column which is of datatype varchar(max) into multiple records. For instance, if there are 280000 characters in the Comments column then it should 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.
14,490 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2025-02-03T06:27:58.5266667+00:00
Raj D 616 Reputation points
accepted 2025-02-13T03:15:44.1933333+00:00
Raj D 616 Reputation points
2 answers

Error while installing SQL Server 2022(Express Edition)

Kindly need help with SQL 2022 installation process. This is my summary.txt file, Overall summary: Final result: Failed: see details below Exit code (Decimal): -2068774911 Exit facility code: …

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 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.
3,009 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2022-12-19T06:24:16.09+00:00
Mohd Azam Ikhwal Bin Azmi 6 Reputation points
commented 2025-02-12T20:16:42.07+00:00
Steven Blackbeard 0 Reputation points
2 answers

Transaction Log Cannot Be Truncated After Memory-Optimized Filegroup Removal

Hello there, One of our clients is facing an issue with a database where the memory-optimized filegroup was forcibly removed using DBCC CHECKDB (test, REPAIR_ALLOW_DATA_LOSS). The database remains functional, but the transaction log continues to grow and…

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
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2025-02-11T04:59:42.99+00:00
kedar giri 81 Reputation points
answered 2025-02-11T22:54:49.09+00:00
Erland Sommarskog 118.9K Reputation points MVP
3 answers One of the answers was accepted by the question author.

How granting the execute permission for several stored procedures - SQL Server 2019

Hi, in order to review some security aspects about a SQL Server 2019 instance I need to assign the execute permission for several stored procedures to a db_datareader and db_datawriter user without operating one by one. How could I accomplish a such…

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
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2025-02-03T08:18:41.0633333+00:00
pmscorca 1,032 Reputation points
edited a comment 2025-02-06T21:51:17.2166667+00:00
Erland Sommarskog 118.9K Reputation points MVP
3 answers One of the answers was accepted by the question author.

Best practices for joining tables of different collation property database

Hi, I am trying to join two tables of databases present on same server but with different collation property and getting following error: What are the best practices to join tables of different databases present on same server but with different…

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
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2025-01-30T10:48:40.5633333+00:00
Priya Jha 896 Reputation points
accepted 2025-02-05T12:21:45.1733333+00:00
Priya Jha 896 Reputation points
2 answers One of the answers was accepted by the question author.

Scalability LEFT JOIN vs MERGE

Hi there, I'm UPSERTING AND handling 70 + millions of rows of UPSERT. I'm the only developer on the DB. GP_Gen5_6 LEFT JOIN DURING UNIT TEST OF ALL RECORDS 12 mins SCALED UP OVERNIGHT PROCESS GP_Gen5_20 History of existing MERGE process same operation…

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.
14,490 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2025-01-28T17:04:24.43+00:00
RJ 326 Reputation points
edited the question 2025-02-05T01:23:44.56+00:00
ZoeHui-MSFT 41,286 Reputation points
2 answers

How to access skillpipe.com site

Hello, A few years ago I took a Microsoft course related to Transaction-SQL. All learning materials were provided by instructors from skillpipe.comsite. I liked it very much.. Obviously I have an account to access it. Now I can’t access it. I used 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.
14,490 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2025-02-02T14:02:06.0366667+00:00
Susja 741 Reputation points
answered 2025-02-04T02:19:34.9166667+00:00
LiHongMSFT-4306 30,996 Reputation points
3 answers One of the answers was accepted by the question author.

An expression of non-boolean type specified in a context where a condition is expected

Hi, I have an issue with this stored procedure (code below), it returns me the following error: An expression of non-boolean type specified in a context where a condition is expected, near 'seque'. Can you please help me with it ? Thank you DECLARE…

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
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2021-05-07T11:06:17.85+00:00
Naami.Ayman 331 Reputation points
commented 2025-01-30T08:11:43.1366667+00:00
Moses Ogada 0 Reputation points
2 answers One of the answers was accepted by the question author.

Select with Conditional COUNT

Hello everyone and thanks for the help in advance. In a prevous post https://learn.microsoft.com/en-us/answers/questions/2148980/counting-occurrences-in-a-table, Erland Sommarskog built a query for me that counted the occurrences of vaccines by patient.…

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
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2025-01-27T23:07:18.69+00:00
Kmcnet 1,006 Reputation points
commented 2025-01-28T22:08:15.4233333+00:00
Kmcnet 1,006 Reputation points
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.
147 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 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,650 Reputation points Microsoft External Staff
3 answers One of the answers was accepted by the question author.

Run SQL Statements Parallel within a SP

Hi there, Is there a way to run SQL Statements in parallel within the same SP? Thanks for your time. CREATE PROCEDURE CustomerPARALLEL AS BEGIN EXEC DBO.CUST1 - TAKES 20 MINS (INDEPENDENT) EXEC DBO.CUST2 - (TAKES 20 MINS (NO DEPENDENCY)) HOW TO…

Azure SQL Database
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2025-01-22T18:28:57.0533333+00:00
RJ 326 Reputation points
answered 2025-01-25T22:29:15.7166667+00:00
Erland Sommarskog 118.9K Reputation points MVP
10 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.
5,447 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.
14,490 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2023-12-19T13:11:52.4966667+00:00
Kıvanç ÖZDEMİR 135 Reputation points
answered 2025-01-25T19:04:25.2733333+00:00
Joshua Moonstar 0 Reputation points
0 answers

How to get a CSV file from a T-SQL in SQL Agent

I am using SQL agent to schedule a task. This task is the execution of a script that performs a query to several databases and concatenates the output. I have managed to obtain a file but not a CSV file, that is, I cannot obtain a file separating the…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 questions
asked 2024-09-26T13:24:49.4666667+00:00
LUIXANY COLISEE 0 Reputation points
commented 2025-01-24T16:40:24.2966667+00:00
GlockByte 161 Reputation points
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.
147 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,691 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,201 Reputation points