执行语句使用exec (sql)
2013-06-01 12:00 hongjiumu 阅读(857) 评论(3) 编辑 收藏 举报declare @fields varchar(max) set @fields=(select name+',' from sys.columns where object_id = object_id(N'p.e_LOG_AFSIP_BLOCK_ALL') and name in ( select ColName from cfg.Dict_Col where TblID=(select TblID from cfg.Dict_Tbl where TblName='p.e_LOG_AFSIP_BLOCK_ALL') ) for xml path('')) set @fields='select '+LEFT(@fields,LEN(@fields)-1)+ ' from p.e_LOG_AFSIP_BLOCK_ALL' print @fields exec (@fields)
执行语句使用exec (sql)