Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Sql :: delete top 10 rows in sql 
Sql :: function in postgresql 
Sql :: mysqldump database 
Sql :: @firebase/database: FIREBASE WARNING: update at /users failed: permission_denied 
Sql :: How to insert Arabic characters into SQL database 
Sql :: sql oracle update multiple rows 
Sql :: postgres default value 
Sql :: multiple replace value mssql 
Sql :: create table from existing table in sql 
Sql :: SQLSTATE[01000]: Warning: 1265 Data truncated for column 
Sql :: python mysql create table if not exists 
Sql :: sqlite3 pragma foreign keys 
Sql :: orderBy sqlalchemy 
Sql :: sum mysql 
Sql :: insert into table from another table 
Sql :: oracle sql number to varchar2 
Sql :: docker add mysql to image 
Sql :: sql stored procedure with table parameter 
Sql :: between 
Sql :: POSTGRES INSERT INTO TABLE VALUE FROM OTHER TABLE 
Sql :: mysqli inner join (php) 
Sql :: right join sql 
Sql :: php get closest location by latitude longitude 
Sql :: oracle tablespace usage 
Sql :: delete all duplicate rows keep the latest except for one in mysql 
Sql :: decimal() mysql 
Sql :: mariadb create index if not exists 
Sql :: sql to c# model 
Sql :: case condition in mongodb 
Sql :: lost connection to mysql server during query when dumping table 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =