Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sql #pass #table #variable
ADD COMMENT
Topic
Name
7+6 =