270 questions with SQL Server | SQL Server Transact-SQL tags
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
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
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
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
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
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
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…
SQL Server | SQL Server Transact-SQL
Reinitializing the replication caused the deletion of database
I’m running a pull subscription using transactional replication between two databases, where the Publisher and Distributor are the same server. We removed the permissions for the account originally used for the replication job and replaced it with a new…
SQL Server | SQL Server Transact-SQL
Joins vs Functions and Performance
It is axiomatic that joining to another table from your primary table to retrieve data, using primary keys, provides better performance than using a function. At least that's what I know from the last time I cared about it years ago. It's time to care…
SQL Server | SQL Server Transact-SQL
Alternative manner to implement an hierarchy without using recursive CTEs
Hi, I'm searching an alternative manner to implement an hierarchy in T-SQL without using recursive CTEs. Actually, a MS Fabric warehouse doesn't support a such useful feature and I need to use recursive CTEs in some scenarios. Any suggests to me, please?…
SQL Server | SQL Server Transact-SQL
Recompile Command Performance Effect
We use .net core Ef .netcore version 8.0. We use an interseptor to manipulete each EF s sql commandS. This interceptor adds OPTION(RECOMPILE) to each sql query. Could you please tell me it is neccessary to use this command.
SQL Server | SQL Server Transact-SQL
Tools for SQL Query Tuning
Hi Expert, What is tool for tuning the SQL Query? I need to checking the query that take long time in running thanks for all valued information warm regards, Urbel
SQL Server | SQL Server Transact-SQL
DBCC TRACEOFF 3604
Good afternoon SQL 2022 Standard I would like to better understand: DBCC TRACEOFF 3604 DBCC TRACEON 3604 How to use it? How to activate it? How and when should it normally be used? Thank you Urantia
SQL Server | SQL Server Transact-SQL
SQL Server Database Engine error during insert/update sequence in employee audit table
I was running a SQL Server test for an internal employee-audit scenario. The script creates two tables, inserts a few rows and performs joins/updates. Expected: All inserts and updates should complete successfully. Observed: Several statements fail…
SQL Server | SQL Server Transact-SQL
Select most recent data per record from multiple tables
I am trying to get the latest data for a record from multiple tables. The issue I am running into is that the data on each table could have been modified at different times and each table may contain multiple rows per record. I am currently using row…
SQL Server | SQL Server Transact-SQL
The audit for this user shows success, but when using SSMS, the error that is received is 18456 and he cannot sign in
We are using integrated security. All other users have no problem getting to this database. One user, gets and 18456 error. The user is part of the SQL Contributor Group. The activity logs for login shows successful login in SQL server through AD,…
SQL Server | SQL Server Transact-SQL
Raiserror doesn't output messages
Hi everybody, I have a strange problem. I have a long procedure which has 2 places that send notes for other procedure. This procedure outputs NULL by this line of code: DECLARE @message VARCHAR(200) = ' Notes is ' + ISNULL(@notes, 'NULL') RAISERROR…