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 Transact-SQL
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 Transact-SQL

Query hang on single user database
We created a new 24 vcore SQL Azure instance and are getting hangs for 81 minutes with no timeouts on an update which previous took seconds. There is only one user and no blocking session SELECT s.login_name, DB_NAME(r.database_id) AS…
SQL Server Transact-SQL

Cannot insert Bassa Vah characters into SQL Server database
I am using SQL Server and Visual Studio 2022 for a language database, but I am unable to insert characters from this page for the Bassa Vah script (https://scriptsource.org/cms/scripts/page.php?item_id=character_list&key=16AD0). I tried NVARCHAR…
SQL Server Transact-SQL

Getting a Table Column value in Catch section while using Output clause for Update Statement
Hi Team, I am working on a SQL Server Stored Procedure which uses Output clause for Update Statement. Table getting updated is having a column name as ID. I need to put Try Catch in this SP and make sure that row which has errored, I am able to get the…
SQL Server Transact-SQL
Query related to length in CAST and Output clause
Hi Team, Could you please reply to below queries - Using CAST, I need to convert BigInt and Datetime2 values to Varchar. How could I be sure on the length that I need to use (in CAST) to convert these values to Varchar. I am using Update statement…
SQL Server Transact-SQL
Copying all tables from one Azure Managed Instance database to another
What is the best method to copy all tables from DatabaseA to DatabaseB in an Azure Managed Instance, including all object-level permissions, triggers, views, and indexes? The Export/Import and SELECT * INTO methods are known not to retain object-level…
SQL Server Transact-SQL
Is Select x like %(% as newname possible in a query
I have the following query that produces correct results however since UnRegMale or UnRegFemale may be bracketed in which case I need to select that field as '' in the query. Bracketed names in the table are not competitors but support persons whose…
SQL Server Transact-SQL


Sql Server to Excel
Hi Trying to export data from sql server to a Table formated excel. But after the data insert the Format of excel not coming properly. I mean the odd and even rows with different color Thanks
SQL Server Transact-SQL

SQL Server Management Studio 18 - Maintenance Plan
I have setup SQL backups to run daily at midnight for 5 servers, all works fine except 1 server does not run/create backup files. No errors or logs just does not run and not sure why. Any suggestions? Thanks! David
SQL Server Transact-SQL

SQL Server Limitations that aren't Solved
I use Sql Server 2022. I'm running Select queries using hundreds of words, and I need to know, for each matching record, which words were found. After running the Select query, I now have to run hundreds of searches for each word in each record, and…
SQL Server Transact-SQL

BCP OUT/IN, What is native format and its usage. I am planning to use BCP out/in to export & Import table data from source to target and would like to know which is the best option when my data contains special character inside it and also have some email
BCP native format when to use when not to use. Is there any alternative BCP utility to export and import data from source to target table
SQL Server Transact-SQL

SSMS got corrupted user settings and now SQL Prompt is no longer working
Good morning, I access SSMS through VDI. Today when I tried to open SSMS I got a message that my user settings got corrupted and do I want to restore from some long path. I believe I answered yes on that question. The connect server dialog didn't have…
SQL Server Transact-SQL
com.azure.core.management.exception.ManagementException: Long running operation is Failed or Cancelled. Error
This is happening quite frequently now. When I am creating Elastic job agent I get com.azure.core.management.exception.ManagementException: Long running operation is Failed or Cancelled. Now this error is happening with every api call. I am using…
SQL Server Transact-SQL
Why are query executed first blocked by update executed later
There are sessions 1-4, and session 1 is update, which is used to block the environment needed for other sessions to form. Symptom 1: Sessions 2 and 4 are select and 3 are update. 1-2-3-4 is executed in sequence. Once session 1 is terminated, I expect…
SQL Server Transact-SQL
External Activation and Microservices Question
Hello, I am working on a proof-of-concept for my company using SQL Server and Service Broker External Activation to send messages from a database to a console application (both .NET and .NET Framework). I successfully created the working POC on my local…
SQL Server Transact-SQL

Applying Non clustered Index on a table with no clustered index
Hi Team, I am working on to improve the performance of a Stored Procedure in SQL Server Database. Table scan is happening on a table on which there is no primary key defined. Structure of table is as such that primary key could not be defined on the…
SQL Server Transact-SQL

Improving SP performance using Non Clustered Index.
Hi Team, I need to improve performance of a SP which is in a Database in SQL Server. 1.One of the Select query uses a Table, which is having clustered index on Column A. This table is joined with other tables on columns A,B and C(all are columns of same…
SQL Server Transact-SQL
SQL 2022 -- cte + insert doesn't work
Good day, I have the following simple SQL statement: DELETE FROM stg.stg_facets_solo; ;WITH cte AS ( SELECT * , COUNT(*) OVER (PARTITION BY f.taxid) AS cntNpi , COUNT(*) OVER (PARTITION BY f.npi ,…
SQL Server Transact-SQL
How to fix connectivity timeout issue between azure function and azure sql server.
We are trying to connect to SQL database using azure function. We are facing a connectivity timeout issue. Below is the error message :- 4/7/2025, 4:10:22.220 PM An error occurred in updateDatabase: RequestError: Timeout: Request failed to complete in…