大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

查询表、字段信息

-----------------------------------------------------------------------------------------------------------------------------------------------------
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://dzwzjz.com/article/jdsesg.html
在线咨询
服务热线
服务热线:028-86922220
TOP