码迷,mamicode.com
首页 > 其他好文 > 详细

查询表、字段信息

时间:2018-05-10 15:46:14      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:查询表字段信息

----------------------------------------------------------------------------------------------------------------------------------------------------- use DSCSYS go DECLARE @TableName nvarchar(100) = ‘COPTD‘ ,@DataBase nvarchar(100) = ‘TOPLED2015‘ ,@SQL nvarchar(4000) ,@Where nvarchar(4000) = ‘ where ‘ set @SQL = ‘select MD001,MD003,MD004,MD005,MD006,MD007 from DSCSYS..ADMMD where MD001 = ‘+ ‘‘‘‘ + @TableName + ‘‘‘ and substring(MD003,1,2) = substring(‘‘‘ + @TableName + ‘‘‘,4,2)‘ exec(@SQL) ---------------------------------------------------------------------------------------------------------------------------------------------------- set @SQL = STUFF((SELECT ‘,‘+ rtrim(MD003) + ‘ as ‘‘‘ + rtrim(MD004) + ‘‘‘‘ FROM ADMMD where MD001 = @TableName and substring(MD003,1,2) = substring(@TableName,4,2) FOR xml path(‘‘)),1,1,‘‘) set @SQL =replace(‘select * from ‘,‘*‘,@SQL) + @DataBase + ‘..‘ + @TableName exec(@SQL) -------------------------------------------------------------------------------------------------------------------------------------------------------

查询表、字段信息

标签:查询表字段信息

原文地址:http://blog.51cto.com/gongxi/2114818

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!