文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>sql语句_实现查询库中所有表的所有字段中包含XX的删除

sql语句_实现查询库中所有表的所有字段中包含XX的删除

时间:2011-01-18  来源:yond

DECLARE @tabName VARCHAR(40),@colName VARCHAR(40)

DECLARE @sql VARCHAR(200)

DECLARE tabCursor CURSOR FOR
SELECT name From sysobjects WHERE xtype = 'u' AND name <> 'dtproperties'

OPEN tabCursor

FETCH NEXT FROM tabCursor INTO @tabName
WHILE @@fetch_status = 0
BEGIN
  SET @sql = 'UPDATE ' + @tabName + ' SET '
  DECLARE colCursor CURSOR FOR Select Name FROM SysColumns Where id=Object_Id(@tabName)
  OPEN colCursor
  FETCH NEXT FROM colCursor INTO @colName
  WHILE @@fetch_status = 0
  BEGIN
    SET @sql = @sql + @colName + '=REPLACE(' +@colName+ ',''XX'',''''),'
    FETCH NEXT FROM colCursor INTO @colName
  END
  SET @sql = LEFT(@sql,LEN(@sql)-1)
  EXEC(@sql)
  CLOSE colCursor
  DEALLOCATE colCursor
  FETCH NEXT FROM tabCursor INTO @tabName
END

CLOSE tabCursor

DEALLOCATE tabCursor

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载