pankaj pareek
Wednesday, June 12, 2013
select from another database dynamic query sql server
DECLARE @sql NVARCHAR(1000), @dbName varchar(50),@someValue INT SET @dbName ='OperationalDB' SET @sql = 'SELECT top 10 * FROM ' + QUOTENAME(@dbName) + '..Employee' --EXEC @sql - It will not work EXEC sp_ExecuteSQL @sql _ It will work
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)