4,566 questions with Transact-SQL-related tags

Sort by: Updated
2 answers

delete with Y flag and I with N

please note this is no duplicate question,here output is different HI EXPERT, create tabletest19 (col1 char(23), col2 CHAR(20),col3 char(3),col4 CHAR(23),col5 CHAR(23),col6 DATETIME )and expected output is this insert into tabletest19…

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,951 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,690 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-02-20T23:36:07.36+00:00
Shambhu Rai 1,406 Reputation points
answered 2024-03-05T22:49:34.1733333+00:00
Bruce (SqlWork.com) 58,441 Reputation points
1 answer One of the answers was accepted by the question author.

performance issue

WITH MaxD AS (select t1.* from D as t1 inner join ( SELECT ID, CN, TB, MAX(BD) as MaxBD FROM ( SELECT ID, CN, TB, BD FROM [D] UNION ALL SELECT ID, CN, TB, BD FROM [M] ) AS t2 GROUP BY ID, CN, TB)t3 on t1.ID =…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-02-29T16:19:04.26+00:00
VK 20 Reputation points
accepted 2024-03-05T18:02:28.8866667+00:00
VK 20 Reputation points
2 answers One of the answers was accepted by the question author.

find column name in db

Hey, how to find a data in the database for an example . I want to find out mobile number column from all tables in database

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,951 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-03-03T10:43:17.8533333+00:00
Vineet S 205 Reputation points
accepted 2024-03-05T01:00:33.25+00:00
Vineet S 205 Reputation points
1 answer

timestamp manupulation

Hey, here is the table & it contains timestamp at the end. check the output create table customer (CustomerName char(22), ContactName char(22), Address char(22), City char(22) , PostalCode char(22), Country char(22),time DATETIME DEFAULT…

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,951 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,474 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,252 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-02-26T04:40:10.3066667+00:00
Vineet S 205 Reputation points
edited the question 2024-03-04T17:56:13.4133333+00:00
Oury Ba-MSFT 16,901 Reputation points Microsoft Employee
2 answers One of the answers was accepted by the question author.

Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

I am trying to write a case statement for my query which checks that if a person got two address on file then get the primary address else which ever one is on file. I have created a temp table for all persons address. This is my code: SELECT…

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,951 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-03-02T18:38:44.1066667+00:00
Ali Ahad 91 Reputation points
commented 2024-03-03T11:08:00.41+00:00
Erland Sommarskog 102.6K Reputation points
1 answer One of the answers was accepted by the question author.

json file in sql server

could you please explain how we can load below curly bracket files in sql server when there are multiple unwanted curly brackets are there apart from main data? in this case data is available in till Result only {     "Generic": {        …

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,951 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,474 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,252 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-03-01T02:01:10.4466667+00:00
Vineet S 205 Reputation points
edited an answer 2024-03-01T03:09:35.2533333+00:00
Yitzhak Khabinsky 25,211 Reputation points
2 answers

What is the best choice for this scenario - CTE or View

Hello Team, I have a scenario where in the source data is in an Azure SQL DB. The data in the source is stored in the form of snapshots. For Ex:- Day1 - 500K Records, Day2 - 510K Records - Day3 - 520K Records (Total - 1.53M records). All the tables the…

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,951 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-02-07T11:11:16.49+00:00
Nagesh CL 621 Reputation points
commented 2024-02-29T05:59:59.8+00:00
CosmogHong-MSFT 24,026 Reputation points Microsoft Vendor
1 answer One of the answers was accepted by the question author.

multiple merge condition

Hey, due to multiple merged condition in same query, it is taking lots of time to run in sql tried partition but did not work . what can be best approach?

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,951 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,836 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,474 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,252 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-02-27T23:50:13.4333333+00:00
Vineet S 205 Reputation points
accepted 2024-02-28T02:09:44.1233333+00:00
Vineet S 205 Reputation points
1 answer One of the answers was accepted by the question author.

Left Join Problem

I have two table: CREATE TABLE [dbo].[TableLeft] ON [PRIMARY] CREATE TABLE [dbo].[TableRight] ON [PRIMARY] INSERT INTO TableLeft values (1, 'TableLeft_1') INSERT INTO TableLeft values (2, 'TableLeft_2') INSERT INTO TableLeft values (3,…

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,951 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-02-24T07:37:30.62+00:00
Masoud Aliakbari 20 Reputation points
accepted 2024-02-24T09:17:05.4833333+00:00
Masoud Aliakbari 20 Reputation points
0 answers

Optimizing stored procedure that exceeds timeout limit

I am encountering a challenge with a Windows service responsible for generating reports using the stored procedure "Mgmt_Report". The stored procedure is subjected to a timeout period of 5 minutes. While smaller reports, typically taking 1 to 3…

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,951 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-02-21T07:37:37.88+00:00
BalajiG2000 0 Reputation points
commented 2024-02-23T08:21:16.7933333+00:00
Erland Sommarskog 102.6K 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.
52 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 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) 58,441 Reputation points
1 answer

insert delete and insert

Hi Expert, the below mentioned records having insert first then delete the same record and inserted the same record. how we can maintain delete and insert records in output. Col2 to Col4 is PK and wants to merge into this table tabletest20 (col1…

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,951 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-02-19T15:24:29.94+00:00
Shambhu Rai 1,406 Reputation points
commented 2024-02-20T23:41:05.53+00:00
Shambhu Rai 1,406 Reputation points
0 answers

maintain last record

HI Expert, needs deleted records as mentioned below 'd' means deleted ... 'I' means inserted we need to delete the the record --- 1st inserted --- 2nd deleted same record so output is mentioned Create table table1 (col1 varchar(20),col2…

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,951 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-02-10T09:01:42.1466667+00:00
Shambhu Rai 1,406 Reputation points
edited the question 2024-02-20T16:57:55.01+00:00
Oury Ba-MSFT 16,901 Reputation points Microsoft Employee
5 answers

SSIS not inserting all rows from ODBC (oracle) to SQL server 2019

I have an issue with migration to SQL server 2019. My Source is Oracle and my Destination is Microsoft SQL Server 2019. My package consists of a simple Data Load task; ODBC Source Connection(oracle)/ and OLE DB Destination connection(2019 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,951 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,474 questions
SQL Server Migration Assistant
SQL Server Migration Assistant
A Microsoft tool designed to automate database migration to SQL Server from Access, DB2, MySQL, Oracle, and SAP ASE.
496 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2021-04-05T06:10:44.777+00:00
Kumar, A. be 16 Reputation points
commented 2024-02-18T08:42:25.26+00:00
CF 0 Reputation points
2 answers

Tuning of a delete query causing slowness

Dear Experts, There is a delete statement which is causing considerable slowness on the server and it runs after hours. Please provide recommendations to tune this query. The primary key is there on this HostNTEvent_TimeGenerated column. delete FROM…

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,951 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-02-14T08:30:02.2333333+00:00
mo boy 396 Reputation points
answered 2024-02-15T03:15:20.83+00:00
CosmogHong-MSFT 24,026 Reputation points Microsoft Vendor
1 answer One of the answers was accepted by the question author.

update the rows after 1st insert

Hi Expert, there are 2 tables the DATA should insert in 1st row as it has PK(primary key) from col2 to col4 but timestamp is difference so instead of insert it should update the 2 row while inserting into table29. create table table28 (col1…

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,951 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-02-14T11:12:46.53+00:00
Shambhu Rai 1,406 Reputation points
accepted 2024-02-15T02:56:48.8933333+00:00
Shambhu Rai 1,406 Reputation points
0 answers

EXISTS with IN returning all rows

Hi, I have two tables Table_A and Table_B, both with very many rows. I need data from both so I am using a JOIN and then filtering on column TXNCODE and DVAL in Table_B. Column DVAL has values ONE,TWO,THREE, FOUR,FIVE,SIX and I need only…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2024-02-09T08:57:30.09+00:00
Mirithu Kinyanjui 21 Reputation points
commented 2024-02-14T21:57:27.95+00:00
Erland Sommarskog 102.6K Reputation points
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,951 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,836 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.
52 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 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
3 answers

IN SSIS How to change SQL Authentication to Windows Authentication

HI I was trying to deploy the packages in to server it is erroring out with the below error . TITLE: SQL Server Integration Services The operation cannot be started by an account that uses SQL Server Authentication. Start the operation with an account…

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,951 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,474 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
asked 2022-05-24T17:50:21.357+00:00
Dinesh Shetty 1 Reputation point
answered 2024-02-14T07:09:31.4833333+00:00
Krishna Shah 0 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.
52 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 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,766 Reputation points Microsoft Employee