查询表、字段信息-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

查询表、字段信息

-----------------------------------------------------------------------------------------------------------------------------------------------------
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)      
-------------------------------------------------------------------------------------------------------------------------------------------------------
select MD001,MD003,MD004,MD005,MD006,MD007,* from DSCSYS..ADMMD 
where MD001 = 'PURTC' and MD003 = 'UDF12'
update DSCSYS..ADMMD  set UDF01 = '质保年限'
where MD001 = 'PURTC' and MD003 = 'UDF12'

分享标题:查询表、字段信息
分享路径:http://kswsj.cn/article/jdsesg.html

其他资讯