4,675 questions with Transact-SQL-related tags

Sort by: Updated
0 answers

How do I update DBContext after adding new table to SQL database?

We added a new table to our SQL Server database called Occupation. From the ASP.NET Web Form project, I can not seem to access it. Imports System.Data.Entity Public Class CCDBContext Inherits DbContext Public Sub New() …

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,561 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,764 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2025-01-11T17:50:11.4366667+00:00
Joe Pool (Heartland) 0 Reputation points
commented 2025-01-11T18:14:14.0933333+00:00
Erland Sommarskog 115.1K Reputation points MVP
1 answer

@@ROWCOUNT issue

Hi there, I had the below code and it worked fine in counting the records inserted and logging insert counts. CREATE PROCEDURE ProcessCustomer AS BEGIN DECLARE @RowsInserted INT; -- Insert into the final table and capture row count …

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,675 questions
asked 2025-01-11T05:26:26.6833333+00:00
RJ 206 Reputation points
answered 2025-01-11T11:59:43.69+00:00
Erland Sommarskog 115.1K Reputation points MVP
2 answers One of the answers was accepted by the question author.

Avoid unnecessary updates on MERGE UPSERT

Hi there, You all might have used UPSERT operation using MERGE. Currently the update section updates all rows once the key is matched. Is there a way to update only rows which have column value changed and not update all rows to avoid unnecessary updates…

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,675 questions
asked 2025-01-09T16:08:24.4733333+00:00
RJ 206 Reputation points
accepted 2025-01-09T17:05:02.9166667+00:00
RJ 206 Reputation points
3 answers

Strip non numeric characters from string

Hi there, Happy New Year! I'm creating a new table (billions of records). I need to strip non numeric values from a column. Input '.I82807- R%' Output 82807 i created a function based on online however ITS SLOOOOOWWWWWW.... Wanted to check if…

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,675 questions
asked 2025-01-03T17:20:48.4066667+00:00
RJ 206 Reputation points
commented 2025-01-07T19:45:08.95+00:00
Mahesh Kurva 1,700 Reputation points Microsoft Vendor
1 answer One of the answers was accepted by the question author.

Identify the users with minimum votes and allocate new votes to that user in Synapse SQL

Hello Experts I came up with one problem where I am looking for a solution as I have two tables: Table1: Users |UserID | TotalTasks| | A3 | 12 | | A4 | 14 | | A5 | 11 | Table2: Tasks | TaskID | NewTask| | 1 …

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,117 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,276 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2024-12-27T17:28:31.5566667+00:00
Avanish Tomar 20 Reputation points
commented 2025-01-02T08:14:30.27+00:00
Avanish Tomar 20 Reputation points
1 answer

stored proc

Hello, I have a stored procedure which does the following: 1- filter tables and place data into #table1 2- filter tables and place data into #table2 ... Then at the end of the stored proc, select columns by joining these #tables. I have several stored…

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,276 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2024-03-18T16:32:41.9133333+00:00
arkiboys 9,696 Reputation points
edited the question 2024-12-30T01:49:26.43+00:00
ZoeHui-MSFT 39,421 Reputation points
1 answer

Alternative approaches for Recursive CTE in SQL server. The data is 1 million records. need to calculate the current value based on previous value and iterate through Million records. Please suggest a methods which performs better than Recursive CTE

here is the query for your reference. Thanks! Alternative approaches for Recursive CTE in SQL server. The data is 1 million records. need to calculate the current value based on previous value and iterate through Million records. Please suggest a…

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,276 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.
109 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2024-12-24T08:30:28.83+00:00
roopa g 20 Reputation points
answered 2024-12-25T01:53:37.3033333+00:00
LiHongMSFT-4306 29,746 Reputation points
1 answer

COALESCE and CONCAT Address Line 1 and Address Line 2 separated by a comma

We are trying to COALESCE and CONCAT Address Line 1 and Address Line 2 separated by a comma "," from potentially two data sources. So like...123 Main St., Apt. 101 The first part is easy enough... CONCAT ( COALESCE ( LTRIM (RTRIM…

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,276 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.
109 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2024-05-09T18:55:45.0266667+00:00
Bobby P 231 Reputation points
commented 2024-12-24T09:16:39.78+00:00
Erland Sommarskog 115.1K Reputation points MVP
3 answers One of the answers was accepted by the question author.

How to get the current row value based on previous row value in sql server- ex first row has value, calculate the second row value using first row and some conditions and 3rd using 2nd row and same conditions

when basin <> prebasin, numberinbasinnew=numberinbasin. when basin=prebasin use the numberinbasinnew from the first row (basin<>prebasin) and calculate the second row value for numberinbasinnew based on below conditions -- CASE …

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,276 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.
109 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2024-12-19T11:36:41.54+00:00
roopa g 20 Reputation points
accepted 2024-12-24T08:33:34.1733333+00:00
roopa g 20 Reputation points
1 answer

Using Temporary Tables and Re-Using Temporary Tables in a SSRS Report

So we need to standardize Member Eligibility by using a SQL Server Stored Procedure that will be called, Executed by our Patient/Member SSRS Reports. The SQL Server Stored Procedure currently uses a Global Temporary Table to pass its result set back to…

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,276 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,967 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2024-11-07T13:49:08.8166667+00:00
Bobby P 231 Reputation points
answered 2024-12-24T03:34:42.0033333+00:00
Naveen Kumar M 75 Reputation points
1 answer

SCOPE_IDENTITY() is Returning NULL instead of IDENTITY Value

Hello, I'm using dynamic SQL to insert a default value into a table and want to return the SCOPE_IDENTITY() value for my surrogate key. However, SCOPE_IDENTITY() is returning NULL for some reason. Am I missing something? Thanks for your…

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,276 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2024-12-23T20:23:37.25+00:00
libpekin 166 Reputation points
commented 2024-12-24T01:53:01.4833333+00:00
LiHongMSFT-4306 29,746 Reputation points
2 answers One of the answers was accepted by the question author.

slow query on large data

Hi there, --3billion rows of accumulated data over a period of time CREATE TABLE [dbo].[large_accumulation_table]( [amt] float(24) NULL, [lastdate] smalldatetime NULL, [type] [varchar](8) NULL, [doc1] [int] NULL, [line1] [smallint] NULL, [type1]…

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,276 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2024-12-19T18:50:52.5133333+00:00
RJ 206 Reputation points
commented 2024-12-20T22:31:25.0833333+00:00
Erland Sommarskog 115.1K Reputation points MVP
2 answers

Unable to debug Stored Procedure

I get the following error: Unable to start the Transact-SQL debugger, could not connect to the Database Engine instance. Make sure you have enabled the debugging firewall exceptions and are using a login that is a member of the sysadmin fixed 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.
14,276 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,015 questions
Windows Server Security
Windows Server Security
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
1,879 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2021-08-30T20:02:34.027+00:00
D D 6 Reputation points
commented 2024-12-20T21:52:52.7233333+00:00
Erland Sommarskog 115.1K Reputation points MVP
9 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,338 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,276 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2023-12-19T13:11:52.4966667+00:00
Kıvanç ÖZDEMİR 130 Reputation points
commented 2024-12-18T07:13:04.9033333+00:00
Rohit Sonawane 0 Reputation points
1 answer

Record count difference during update query execution.

We are trying to update around 5 millions of data in Azure SQL DWH at a time. While updating the same it has been observed the count of records on table is getting frequently changed, until the update query is completed. What could be underlying reason…

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,117 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,276 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2024-12-11T18:36:37.46+00:00
NIKHIL KUMAR 101 Reputation points
answered 2024-12-17T23:34:44.5833333+00:00
vinod singamsetty 5 Reputation points
3 answers

changing the endcoding of an attached file in sql trasaction

Hi, I have written a sql server procedure which sends the result of a query as a csv file via e-mail. SQL server generates the attached file in UTF-8 BOM encoding. I need the attached file to be generated in UTF-8 (without BOM). I tried to…

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,276 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2021-07-02T10:37:55.837+00:00
Massimo 1 Reputation point
edited an answer 2024-12-17T11:39:59.86+00:00
Paul Geldenhuys 0 Reputation points
4 answers One of the answers was accepted by the question author.

SQL Server 2019 Instance Name Change

I am running SQL 2019 on Windows 2019 server and have come across an issue I have not seen before and cannot find a resolution on the web. I have went through the normal process of changing the Instance name by using the following.. EXEC sp_dropserver…

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,276 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2022-03-15T17:08:06.187+00:00
Rich 21 Reputation points
commented 2024-12-12T13:50:13.6233333+00:00
Luis Saldana 0 Reputation points
1 answer

Database schema change of result in query sql server

How we can get database schema change result in query sql server? Is there any tool ? Suppose we do any change in schema. I want the result of that change in 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,276 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2023-11-16T22:31:07.1766667+00:00
Kanav Sharma 25 Reputation points
commented 2024-12-06T18:03:35.93+00:00
Marie Phillips 0 Reputation points
2 answers One of the answers was accepted by the question author.

Create JSON file and import as a table

Hi, This should be simple, but I tried various options and can not get it to work. I'm trying the following: SELECT TOP (100) ADMIN_AUDIT.admin_audit_id AS [id] , ADMIN_AUDIT.admin_audit_dttm AS [time] , ADMIN_AUDIT.process_txt 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.
14,276 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2024-11-27T21:12:31.1+00:00
Naomi Nosonovsky 8,051 Reputation points
accepted 2024-12-01T00:27:07.44+00:00
Naomi Nosonovsky 8,051 Reputation points
3 answers One of the answers was accepted by the question author.

loop through table records and execute Stored Proc with row data as params in sql server

Hi, I import data from csv file into a temp table. I need to loop through each row and call Stored procedure and pass that row details to the stored procedure as parameters. I know that it can be done using cursor and i have implemented it. I would…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,675 questions
asked 2022-05-12T13:57:59.817+00:00
Spunny 326 Reputation points
commented 2024-11-28T16:11:33.4966667+00:00
Brian Downey 0 Reputation points