4,597 questions with Transact-SQL-related tags

Sort by: Updated
4 answers

SQL Statement taking long to execute

I have two SQL Databases that is on the same SQL server but on one database it only takes 4 seconds to complete the SQL statement but on the other SQL database it takes 25 minutes to complete. Both databases uses the same SQL elastic pool and I don't see…

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,325 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.
66 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-07-15T03:15:50.06+00:00
WingHong Shiu 5 Reputation points
answered 2024-07-21T20:58:04.8166667+00:00
Erland Sommarskog 106.5K Reputation points
1 answer

Transaction replication is getting failed for creating snapshot with message as "Prefetch objects failed for Database"

This issue "Message: Prefetch objects failed for Database " has been happening everytime I run the snapshot after 96% completed I was getting this issue (I need to wait for 5 hours for this). What ever .bcp files got created in storage 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.
13,325 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-07-12T11:33:24.7133333+00:00
Ravi Padakanti 0 Reputation points
commented 2024-07-19T05:32:04.7733333+00:00
LucyChenMSFT-4874 2,985 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

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,325 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,522 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,260 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-06-12T07:17:37.1633333+00:00
Vineet S 425 Reputation points
edited the question 2024-07-18T08:49:02.3533333+00:00
ShaktiSingh-MSFT 14,381 Reputation points Microsoft Employee
1 answer One of the answers was accepted by the question author.

left and right join

Hi, table 1 Table 2 select A.* from table1a LEFT join table2 b on a.col1=b.col1 output: which is correct but on right join it shows above results how to calculate this join and how it will react on NULL and blank

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,325 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,522 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-06-23T11:34:41.0833333+00:00
Vineet S 425 Reputation points
edited the question 2024-07-18T07:23:47.01+00:00
ShaktiSingh-MSFT 14,381 Reputation points Microsoft Employee
2 answers One of the answers was accepted by the question author.

Select alternate rows basis on pattern.

I have a table like below I want the result like below Please help on this. Thanks in advance.

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,325 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-07-01T12:00:38.2466667+00:00
sourav dutta 231 Reputation points
edited the question 2024-07-15T00:59:58.8533333+00:00
LiHongMSFT-4306 25,651 Reputation points
2 answers One of the answers was accepted by the question author.

SQL with bunch of or clauses

Trying to get the result with a bunch of or clauses. SELECT * FROM SA15B WHERE PoNo 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.
13,325 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-07-12T14:10:10.2066667+00:00
Jonathan Brotto 200 Reputation points
commented 2024-07-12T14:40:33.5066667+00:00
Olaf Helper 43,166 Reputation points
2 answers

SSIS : Decimal Places not loading from Excel Source to SQL table

Hi Team - I have an excel file with few columns but the issue is with one of the column, Lets say Column A. Column A : FY20 Work Extra Feb 4 4,401,0089 3,81,68182.01 27,381.59 - 42590062.77 99.8% Few of the numeric values above are rounding off 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.
13,325 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,522 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.
66 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-07-12T04:39:32.5766667+00:00
kkran 831 Reputation points
answered 2024-07-12T09:00:49.7366667+00:00
ZoeHui-MSFT 35,381 Reputation points
2 answers

updare dateid in table

HI, Hw to update date datatype into integer column to varchar column create table table1(dateid date,dateid1 int,dateid2 varchar(23) ) dateid --------------------- dateid1 -------------dateid2 2024-01-01…

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,325 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,522 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-07-10T18:59:02.5066667+00:00
RUPESH SHELAR 0 Reputation points
commented 2024-07-12T02:02:29.6333333+00:00
LiHongMSFT-4306 25,651 Reputation points
1 answer

email not been send to all in the ssrs report subscription

HI there I have a very bizarre situation in production environment of my work space where not all of the emails are been sent when the ssrs report is been published to go out. For example i have three emails(not real emails) like…

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,869 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2021-05-26T09:46:56.46+00:00
Farhan Jamil 421 Reputation points
commented 2024-07-11T05:35:03.8966667+00:00
Radhai Krish 191 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.
13,325 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,869 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2022-12-19T06:24:16.09+00:00
Mohd Azam Ikhwal Bin Azmi 6 Reputation points
answered 2024-07-10T12:15:29.9633333+00:00
Ijaz Muhammad 81 Reputation points
5 answers

Cannot insert the value NULL into column and column does not allow nulls

HI Team i have build a physical table with some columns, where i have an identity column in my table [ProdID] [int] IDENTITY(1,1) NOT NULL I am trying to insert the records into this prod table using the destination table values ,insert fails…

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,325 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,522 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2022-10-03T10:35:41.323+00:00
Naresh y 146 Reputation points
answered 2024-07-09T09:50:54.8966667+00:00
Muhammad Shoaib 0 Reputation points
1 answer One of the answers was accepted by the question author.

unique column in table

HI, merging table1 in table2 merge into table2 using table1 on table.col1=table2.col1 when not match then insert how to add unique column with auto increament number and not null in table like uniquenumner; Name;' 001 Test1 003 …

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,325 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-07-06T02:21:59.06+00:00
Vineet S 425 Reputation points
edited the question 2024-07-08T03:38:42.9333333+00:00
ShaktiSingh-MSFT 14,381 Reputation points Microsoft Employee
3 answers

Training database PUBS

Dear friends, I'm looking for a description of the tables and fields of the Pubs training database. Can you help me please? Thank you very much, Anna

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,325 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2021-05-07T16:47:27.23+00:00
BIVS Databaze 1 Reputation point
answered 2024-07-04T12:13:44.9366667+00:00
Anthony Lesar 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,873 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,325 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2023-12-19T13:11:52.4966667+00:00
Kıvanç ÖZDEMİR 130 Reputation points
commented 2024-07-03T04:42:42.13+00:00
Harsh Sugandhi 0 Reputation points
1 answer One of the answers was accepted by the question author.

Sporadic INSERT EXEC failed because the stored procedure altered the schema of the target table

Hi everybody, We're getting this error sporadically. The outer stored procedure has a table variable and it also has a temporary table called #Results which is used to hold results of another stored procedure, e.g. DROP TABLE IF EXISTS…

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,325 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-07-02T15:54:40.36+00:00
Naomi Nosonovsky 525 Reputation points
edited a comment 2024-07-02T21:40:08.37+00:00
Erland Sommarskog 106.5K Reputation points
2 answers One of the answers was accepted by the question author.

Preventing Database Deletion in SSMS

prevent accidental database deletions within SQL Server Management Studio (SSMS). Currently, I am exploring options to enforce this restriction effectively implemented a DDL trigger Is the above DDL trigger approach appropriate for preventing…

SQL Server on Azure Virtual Machines
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,325 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-06-28T13:20:16.26+00:00
Niket Kumar Singh 300 Reputation points
accepted 2024-07-01T12:12:22.7666667+00:00
Niket Kumar Singh 300 Reputation points
2 answers One of the answers was accepted by the question author.

Query to get Month , Day and Week number of current month.

Hi, Need a query to get Month , Day and Week number of current month.   Sample table   DateMonth NameDayWeekYear6/29/2024JunSatWK52024

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,325 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-06-29T10:28:08.37+00:00
mrrobottelg 20 Reputation points
accepted 2024-07-01T06:06:20.8933333+00:00
mrrobottelg 20 Reputation points
5 answers One of the answers was accepted by the question author.

How to calculate Median Value

Suppose i have table and one column has numeric value. now how could i calculate median value ? i found one code from this url https://stackoverflow.com/questions/1342898/function-to-calculate-median-in-sql-server but their approach is not…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2020-12-13T19:32:57.437+00:00
Sudip Bhatt 2,276 Reputation points
answered 2024-06-28T14:04:48.3766667+00:00
Cédric Hutt 0 Reputation points
2 answers

Msg 22050, Level 16, State 1, Line 0 Failed to initialize sqlcmd library with error number -2147467259.

DECLARE @RowId NVARCHAR(255) DECLARE @Query NVARCHAR(MAX) DECLARE @Header NVARCHAR(MAX) SET @RowId = '[sep=,' + CHAR(13) + CHAR(10) + 'RowId]' SET @Query = 'set nocount on; SELECT ROW_NUMBER() OVER (ORDER BY PDTMO.MONo DESC, PDTWF.CreateDate ASC) AS ' +…

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,325 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2024-06-28T05:37:28.5766667+00:00
Elson Wong 0 Reputation points
commented 2024-06-28T05:38:54.6066667+00:00
Elson Wong 0 Reputation points
2 answers One of the answers was accepted by the question author.

Insert with Transaction Significantly Faster than Individual Inserts - SQL Server

Hello, Could you please explain this? Why insert with Transaction significantly faster than individual inserts in SQL Server?

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
asked 2021-12-06T14:26:13.723+00:00
Shervan360 1,481 Reputation points
commented 2024-06-27T11:21:02.9166667+00:00
Victor Almeida Schinaider 0 Reputation points