199 questions with SQL Server | SQL Server Transact-SQL tags

Sort by: Updated
0 answers

[SQLServer JDBC Driver][SQLServer]An expression of non-boolean type specified in a context where a condition is expected, near

Hi, I'm getting the following error: [SQLServer JDBC Driver][SQLServer]An expression of non-boolean type specified in a context where a condition is expected, near 'Jul' Here is the code: select 'Actual' SCENARIO, #PROGRESS_TO_HFM.P_YEAR …

SQL Server SQL Server Transact-SQL
asked 2025-06-20T10:11:18.2766667+00:00
Eldo Mills 0 Reputation points
commented 2025-06-24T12:44:15.83+00:00
Eldo Mills 0 Reputation points
1 answer

Enable Ledger on Azure SQL Server, will hang the Azure function execution which add around 65K records

I have an Azure function which read data from Excel sheets and update 3 SQL tables, and it clear 2 SQL tables before re-add the rows. On some scenarios, I will add the data as-is, while on another scenario I need to check if a column named ID exists, if…

SQL Server SQL Server Transact-SQL
asked 2025-06-15T23:41:33.0566667+00:00
john john Pter 1,040 Reputation points
answered 2025-06-16T21:34:34.4166667+00:00
Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
0 answers

Execution of the stored procedure gives different result comparing with the direct execution

Hi everybody, I'm getting very puzzling results executing stored procedure vs executing subset of the code from that stored procedure directly. I have the following code to execute SP: DECLARE @RC INT DECLARE @inp_region_nbr TINYINT = 1 DECLARE @inp_npi…

SQL Server SQL Server Transact-SQL
asked 2025-06-13T22:28:35.3266667+00:00
Naomi Nosonovsky 8,431 Reputation points
edited a comment 2025-06-15T03:41:40.6766667+00:00
Naomi Nosonovsky 8,431 Reputation points
1 answer

SQL Server 2019 Database Diagram Issue

hi, I am facing an issue that whenever I change some table relation or remove table from the database the database diagram containing that table shows blank page. I have used queries to check the database diagram exists and has data and tables. I can get…

SQL Server SQL Server Transact-SQL
asked 2025-06-15T01:20:24.67+00:00
W-Rehman 0 Reputation points
edited a comment 2025-06-15T03:05:07.04+00:00
Viorel 122.5K Reputation points
2 answers

Issue with SQL Azure Secure Enclave: LIKE Clause Failing with Error".

I am using Microsoft SQL Azure (RTM) - 12.0.2000.8 , where I configured the secure enclave with VBS where I am using keyvalut for creating column master key. All the operators are working fine except like. Able to insert, update with where clause. Tried…

SQL Server SQL Server Transact-SQL
asked 2025-06-05T09:44:00.5466667+00:00
Ashish Singhal 0 Reputation points
commented 2025-06-09T21:09:32.73+00:00
Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
2 answers

Using IsNull with different data types in SQL SERVER

Hi Team, I am working on on premises SQL Server. I have a requirement where I need to apply left outer join between 2 tables and use IsNull to show default data when columns are having null. Under ISNULL, if a column is null what shall i put for below…

SQL Server SQL Server Transact-SQL
asked 2025-06-06T18:06:46.15+00:00
Salil Singh 60 Reputation points
answered 2025-06-09T17:55:33.42+00:00
SUMIT RAY 0 Reputation points
1 answer One of the answers was accepted by the question author.

Regarding the stability of the execution plan generation

My English is not good, so I use a translator to communicate. Please excuse me if it's not accurate I'm optimizing an sql,I created a few indexes, and the cost exceeded the parallel threshold, and it reported that the optimization was prematurely…

SQL Server SQL Server Transact-SQL
asked 2025-06-06T06:58:03.05+00:00
博雄 胡 685 Reputation points
accepted 2025-06-09T03:33:17.3766667+00:00
博雄 胡 685 Reputation points
1 answer

SQL Linked Server Connection to Oracle

I have a linked server connection between my SQL server and remote Oracle server. I can query the Oracle server from SQL without issue. I need to insert data from SQL into Oracle. The problem is the table names in SQL are different than Oracle. I tried…

SQL Server SQL Server Transact-SQL
asked 2025-06-04T20:41:16.1066667+00:00
rr-4098 2,051 Reputation points
commented 2025-06-07T18:41:01.6733333+00:00
rr-4098 2,051 Reputation points
2 answers

Inquiry About Extended Stored Procedures

Hi Team, I hope you're doing well. I would appreciate it if you could help me understand the following: What is an Extended Stored Procedure in SQL Server? Why did Microsoft deprecate Extended Stored Procedures? A brief explanation would be greatly…

SQL Server SQL Server Transact-SQL
asked 2025-06-06T13:56:55.6933333+00:00
Abhishek Modi (amodi) 0 Reputation points
answered 2025-06-06T15:35:23.8766667+00:00
Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
1 answer

Contains/Containstable and search in Like mode

I have indexed the "Contenido" field in Full Text. Searching with CONTAINS/CONTAINSTABLE in Like mode yields no matches when using words that contain the text "ous" (house). If I remove the asterisks and I write 'house', the text is…

SQL Server SQL Server Transact-SQL
asked 2025-06-03T02:01:30.92+00:00
Central data 156 Reputation points
answered 2025-06-03T05:55:55.5466667+00:00
Olaf Helper 47,436 Reputation points
5 answers

Enable parallelism for TSQL scalar UDFs involving CLR function call in SQL Server

We are working on a UDF solution for MSSQL Server. Currently we have scalar TSQL UDFs which calls CLR functions. CLR functions (written in C#) further calls C functions present in a DLL file which is imported by C# layer using DLLImport. Also due to some…

SQL Server SQL Server Transact-SQL
asked 2025-05-30T05:25:49.0966667+00:00
Rakesh Kumar 0 Reputation points
answered 2025-05-30T19:48:51.6266667+00:00
Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
1 answer

SQLServerBulkCSVFileRecord java and quotes problem

i can't laod using SQLServerBulkCSVFileRecord (ver 12.10) a file like this: xxx;yyyy;test"test;zzzz simple file with 1 simple quote in nvarchar column, give error "com.microsoft.sqlserver.jdbc.SQLServerException: Unable to retrieve data from…

SQL Server SQL Server Transact-SQL
asked 2025-05-23T14:21:07.0933333+00:00
STELMACH Daniel Ext O-PL/Korpo 0 Reputation points
commented 2025-05-26T12:32:22.7633333+00:00
STELMACH Daniel Ext O-PL/Korpo 0 Reputation points
2 answers

Avoiding table locking while Update

Hi Team, I am working on a SQL Server Stored Procedure, where I need to update a column of a table in a no. of rows. This stored procedure will be called from a timer trigger Azure function, which will scale so that 2 function instances may call the…

SQL Server SQL Server Transact-SQL
asked 2025-05-21T18:29:31.7566667+00:00
Salil Singh 60 Reputation points
edited a comment 2025-05-22T00:07:29.6566667+00:00
Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
2 answers One of the answers was accepted by the question author.

Sql connectionstring "Old Password" attribute not working on OLE DB Driver for SQL Server - getting error "Invalid connection string attribute"

Sql connectionstring "Old Password" attribute not working on OLE DB Driver for SQL Server - getting error "Invalid connection string attribute" We have downloaded the OLE DB diver…

SQL Server SQL Server Transact-SQL
asked 2025-05-19T14:28:00.7066667+00:00
Alice Van Rensburg 20 Reputation points
accepted 2025-05-20T15:29:35.23+00:00
Alice Van Rensburg 20 Reputation points
2 answers

Error - FOR XML could not serialize the data for node 'NoName'

I am using FOR XML to concatenate varchar data. The data came from user input so it could have garbage characters. Getting the "Error - FOR XML Could Not Serialize the data for node NoName". Not really picky about what to do with the bad data,…

SQL Server SQL Server Transact-SQL
asked 2025-05-17T22:00:51.08+00:00
brenda grossnickle 206 Reputation points
edited an answer 2025-05-19T23:23:08.1+00:00
Yitzhak Khabinsky 26,586 Reputation points
2 answers One of the answers was accepted by the question author.

Table locked

Good day, My colleague was using Import/Export wizard and the package got stuck. He since killed SSMS, but the table got locked somehow. We're unable to truncate it or rename it. What can be done to unlock it? Thanks in advance.

SQL Server SQL Server Transact-SQL
asked 2025-05-15T18:02:46.8333333+00:00
Naomi Nosonovsky 8,431 Reputation points
answered 2025-05-15T21:05:44.94+00:00
Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
1 answer One of the answers was accepted by the question author.

Restore Database from .MDF and .LDF files in Sql Server 2019

Hello, We have Sql Server 2019 and we need to restore the database using .MDF and .LDF file into existing database. We have received .MDF and .LDF file from another server which is also Sql 2019 and our current server which has already database which is…

SQL Server SQL Server Transact-SQL
asked 2025-05-13T20:26:29.48+00:00
pdsqsql 431 Reputation points
accepted 2025-05-15T15:45:57.1466667+00:00
pdsqsql 431 Reputation points
2 answers

What is the performance cost of using PIVOT in Microsoft SQL Server

I'm using PIVOT in my query, but it's resulting in high logical reads and performance degradation. Could you recommend a more optimal alternative approach.

SQL Server SQL Server Transact-SQL
asked 2025-05-14T15:07:42.86+00:00
RajeshKumar Tuta 0 Reputation points
answered 2025-05-14T20:39:00.74+00:00
Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
2 answers

Can a column name used as part of a CTE be used in the SELECT query that creates the CTE?

When converting a SQL script from SQL Anywhere to SQL Server, my code generated an error for the following CTE code sample; the error says that the column name used in the ROW_NUMBER function is invalid. Any suggestions on how to fix this would be…

SQL Server SQL Server Transact-SQL
asked 2025-05-09T13:15:11.4133333+00:00
Gil Robinson 0 Reputation points
commented 2025-05-12T06:29:48.6166667+00:00
Olaf Helper 47,436 Reputation points
2 answers One of the answers was accepted by the question author.

How to script views by a pattern

Hi, I'm wondering if there is a simple way to script views definitions by some pattern, e.g. views in a particular schema and named using 'ndb' in the name? Thanks in advance.

SQL Server SQL Server Transact-SQL
asked 2025-05-09T14:14:17.4433333+00:00
Naomi Nosonovsky 8,431 Reputation points
commented 2025-05-11T19:33:08.9633333+00:00
Michael Taylor 60,161 Reputation points