1、查询包含某字段的所有表 select object_name(id) objName,Name as colName from syscolumns where (name like‘%你要查询的字段名%‘) and id in(select id from sysobjects where xtype=‘u‘) order by objname ; 2、查询包含某字段的所有存储过程 SELECT obj.Name 存储过程名, sc.TEXT 存储过程内容 FROM syscomments sc INNER JOIN sysobjects obj ON sc.Id = obj.ID WHERE sc.TEXT LIKE ‘%你要查询的字段名%‘
declare @verId UNIQUEIDENTIFIER=‘xxxxx‘ BEGIN SET NOCOUNT ON; DECLARE @sql NVARCHAR(max) DECLARE cursorClearUserData CURSOR LOCAL FOR SELECT 表名 = D.name FROM syscolumns A LEFT JOIN systypes B ON A.xusertype=B.xusertype INNER JOIN sysobjects D ON A.id=D.id and D.xtype=‘U‘ and D.name<>‘dtproperties‘ LEFT JOIN sys.extended_properties g ON a.id=g.major_id AND a.colid=g.minor_id WHERE A.name= ‘IsUser‘ ORDER BY D.name ; OPEN cursorClearUserData DECLARE @tableName NVARCHAR(100); FETCH NEXT FROM cursorClearUserData INTO @tableName WHILE @@FETCH_STATUS = 0 BEGIN SET @sql = ‘update ‘ + @tableName + ‘ set IsUser= 0 where Pro_PrVeId=‘+ ‘‘‘‘+CAST(@verId AS NVARCHAR(36)) + ‘‘‘‘+‘;‘ print @tableName FETCH NEXT FROM cursorClearUserData INTO @tableName END CLOSE cursorClearUserData DEALLOCATE cursorClearUserData SET NOCOUNT OFF; END
原文地址:https://www.cnblogs.com/daizhipeng/p/12170604.html
时间: 2024-09-26 19:46:48