Answers for "sql pass table name as variable"

SQL
0

sql pass table name as variable

declare @schema varchar(50)
declare @table varchar(50)
declare @query nvarchar(500)

set @schema = 'dbo'
set @table = 'ACTY'

set @query = 'SELECT * FROM [DB_ONE].[' + @schema + '].[' + @table + '] EXCEPT SELECT * FROM [DB_TWO].[' + @schema + '].[' + @table + ']'

EXEC sp_executesql @query
Posted by: Guest on February-24-2022

Code answers related to "sql pass table name as variable"

Code answers related to "SQL"

Browse Popular Code Answers by Language