278 questions with SQL Server | SQL Server Transact-SQL tags
Stored Procedure running longer hours
Hello, I am facing currently issue as stored procedure running very longer hours although my DB is not that big means around 20 GB. We are also running OLA's maintenance solution for Update Stats Daily and Index maintenance weekly basis. Stored procedure…
SQL Server | SQL Server Transact-SQL
Sequel server licensing
My distributer is telling me that SQL Server Standard 2022 - 2 Core License Pack - 3 yearSQL Server Standard 2022 - 2 Core License Pack - 3 year billed annually is a perpetual license? I have query with this as it has a termed subscription time?…
SQL Server | SQL Server Transact-SQL
Implementing User-Defined Sort via Trigger
Hi, Running SQL Server 2008 R2. We have a requirement to implement an arbitrary sort for a table using a numeric sort column. DDL and DML below: CREATE TABLE [dbo].[Test] ( [TestID] [bigint] IDENTITY(1,1) NOT NULL, …
SQL Server | SQL Server Transact-SQL
Identity Column jumps massively from 168712 to 9999993
I have table with identity column id. There was massive jump from id 168712 to 9999993. It has happened twice in different servers. Its not identity cache/transaction rollback/manual insert/ reseed. Why its happening. Please guide me on this.
SQL Server | SQL Server Transact-SQL
how to fix error 1205 on mssql 2022
Riscontro vari errori 1205 nei log e dopo alcuni di questi, si verifica l'errore 824
SQL Server | SQL Server Transact-SQL
SQL query across linked servers
Hi All, I have a number of linked servers. In each server I have the same table Q_TESTS. I would like to run t-sql script across all the servers, select * from Q_TESTS where Act = 1 How can I achieve this? Kindly advise Many thanks
SQL Server | SQL Server Transact-SQL
Copying a 32-Million Row Table From Production Server to Test Server
So we believe we're having tempdb issues with a very wide table that has 32-Million Rows on it. There is no Primary Clustered Index, No Indexes defined on it at all. We have tried an INSERT SELECT going across a Linked Server to our Test Server to copy…
SQL Server | SQL Server Transact-SQL
Best, Most Efficient DATETIME filtering
I have seen many discussions regarding doing filtering against a DATETIME Data Type. Some suggest to use a true DATTETIME format. WHERE <DATETIME_Column_Name> >= '2026-02-17 00:00:00.000' Others suggest to use just a quoted Date... WHERE…
SQL Server | SQL Server Transact-SQL
How to create initial full backup followed by transaction logs daily?
This is related to work. I have been sending out a full-back up of a database in BAK file format (using SQL Server 2022) for a client, but now the client is asking for an initial full backup followed by transaction logs daily. How do I go about doing it…
SQL Server | SQL Server Transact-SQL
What is SQL error ID 8179 and how to fix it?
The customer often found NAV Server error at Event Viewer (Application log), Event ID 216, MicrosoftDynamicsNavServer$MBKNAV. It was NavSqlException, SQL error ID 8179 (“Could not find prepared statement with handle …”). This issue often occurs when…
SQL Server | SQL Server Transact-SQL
Best and most efficient way to convert a VARCHAR(10) to a Date for filtering
We have a "Blob" Table with a Date and a Data Type of VARCHAR(10). What is the best and most efficient way to convert that to a Date so that we can look back and filter based on the last 3-years? Thanks in advance for your review and am hopeful…
SQL Server | SQL Server Transact-SQL
Point in time restore after initial backup
Hello, I have a specific question to which i coulnd't really find an exact answer. I have a scenario in which let's say I have an initial full backup(no backups present before that) that for some reason is slow and takes let's say 5 hours, starting at…
SQL Server | SQL Server Transact-SQL
SSMS does not recognize data table
SSMS does not recognize data table....how do I fix this? See images below.
SQL Server | SQL Server Transact-SQL
unable install sql on on pc due to power shell error
unable install sql on on pc due to power shell error
SQL Server | SQL Server Transact-SQL
A Scalar UDF works consistently in SQL Server 2017, fails sporadically under 2019 and 2022.
You can try this at home! I use this udf to capture the number of cores available when my stored procedure runs in cloud. But, since I develop against my local on-prem database, I coded it to return a -1 when it's not running in the cloud. Here's the…
SQL Server | SQL Server Transact-SQL
Syntax error in the statement
Hi, I wrote the following query and trying to figure out the syntax error: incorrect syntax near WHERE. DECLARE @SQL NVARCHAR(MAX) SET @SQL = (SELECT 'SELECT COUNT(*) FROM rv.' + table_name, +','+ QUOTENAME((table_name) + ' as table_name ' FROM…
SQL Server | SQL Server Transact-SQL
How can I create TRN file to capture only difference daily (between TRN files)?
I am trying to understand how Transaction Log works. This question is related to my previous post. My requirement is, instead of providing BAK file (because it is huge), I am trying to generate one TRN file daily for any change (insert, update or delete)…
SQL Server | SQL Server Transact-SQL
sqlcmd to backup on one server and write to another
I have a sql agent job that runs a CmdExec step on server 'Destination'. It executes a full backup on server 'Source' and needs to write the backup to server 'Destination'. This works perfectly when the server names are hard coded. However, both the…
SQL Server | SQL Server Transact-SQL
Dose SQL Server works on Snapdragon Arm Laptop
Dose SQL Server works on Snapdragon Arm based Laptop. if yes how to run on arm based Snapdragon Laptop
SQL Server | SQL Server Transact-SQL
SQL error -An expression of non-boolean type specified in a context where a condition is expected
Thanks in advance for any help folks can offer. I've been pulling my hair our all day yesterday trying to figure out how to fix this. I received the error below after I added 3 new lines (line 60, 61 and 62). The original code without these 3 new lines…