Skip to content

Tag: sql-server

Dynamic SQL output of a query to a variable

I would like to output the result of the dynamic SQL into a variable called @Count but not sure what the syntax or even the code should like to accomplish this. The code looks as follows: thank you Answer You can utilize sp_executesql to execute your count() query, and output it @Count. Try this: One last thi…

To UNION or Not to UNION

I am currently running into an issue with my UNION clause. I am trying to figure out how many orders I am import via each day. The problem is, I have two tables that these orders are stored in OLDORDERHEADER and ORDERHEADER. After an order is completed, it moves from the ORDERHEADER table into the OLD. Both h…

SQL BACKUP and Restore Full backup

I have two full backups of different dates first full backup is of date lets suppose 21-05-2017 and I have restored that backup to client machine (RESTORE WITH NO RECOVERY) and now I got second full back on date : 26-05-2017 , now I want to restore that full backup on previous restored Full back on my client …