October 16, 2024 at 10:03 am
How do I use a variable name for a linked server name in a linked server query?
set @servername = (SELECT TOP (1) [ServerName]
FROM [Database].[dbo].[Servers]
declare @servername =
SELECT * FROM [SERVER_NAME].[DATABASE_NAME].[SCHEMA_NAME].[TABLE_NAME]
SELECT * FROM [@servername ].[DATABASE_NAME].[SCHEMA_NAME].[TABLE_NAME]
Ideally how can I backup all servers/databases onto a single fileshare from a single server as a sqljob ?One server will be chosen from this query SELECT TOP (1) [ServerName]
FROM [Database].[dbo].[Servers] every time the sqljob runs.
October 16, 2024 at 12:12 pm
Dynamic SQL is one way of creating a variable SELECT statement that can be executed.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy