RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
查询表、字段信息
-----------------------------------------------------------------------------------------------------------------------------------------------------
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'

标题名称:查询表、字段信息
标题URL:http://lswzjz.com/article/jdsesg.html