SqlServer动态变换库名


declare @tname varchar(20),@num int
set @tname='Players_Log_L10001'
declare @sql Nvarchar(1000)=N'select @num=COUNT(*) from '+@tname+'.dbo.Log_Party_Join';
Exec sp_executesql @sql,N'@num int output',@num output
select @num

posted @ 2018-05-30 11:02  离散音符  阅读(140)  评论(0编辑  收藏  举报