execute sql query dynamically
eg:
create proc pr_test
@table varchar(128),
@database varchar(128)
as
declare @str1 varchar(128)
declare @str2 varchar(128)
set @str2=' select * from '+@database+'.dbo.'+@table
exec (@str1+@str2)
eg:
create proc pr_test
@table varchar(128),
@database varchar(128)
as
declare @str1 varchar(128)
declare @str2 varchar(128)
set @str2=' select * from '+@database+'.dbo.'+@table
exec (@str1+@str2)
For more information about me, feel free email to me winston.he@hotmail.com |