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)

posted on 2008-01-17 15:57  飞天舞者  阅读(275)  评论(0编辑  收藏  举报

导航

For more information about me, feel free email to me winston.he@hotmail.com