快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

查询表、字段信息

-----------------------------------------------------------------------------------------------------------------------------------------------------
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://6mz.cn/article/jdsesg.html

其他资讯