Select Convert(Char(40), O.Name) From SysObjects O, SysColumns C Where O.Id = C.Id And O.XType = 'U' And C.Name = 'Invtid' Will give you every table in the app database with the field Invtid in it. Loop thru the results and execute a delete statement agains each table. Use at your own risk, in a test environment first! DECLARE @delInvtid varchar(30) SET @delInvtid = 'commodore_64' DECLARE @tablename varchar(40) DECLARE table_cursor CURSOR FOR Select Convert(Char(40), O.Name) From SysObjects O, SysColumns C Where O.Id = C.Id And O.XType = 'U' And C.Name = 'Invtid' OPEN table_cursor FETCH NEXT FROM table_cursor INTO @tablename WHILE (@@FETCH_STATUS <> -1) BEGIN EXECUTE ('DELETE from ' + @tablename + ' where Invtid = ''' + @delInvtid + ''''); FETCH NEXT FROM table_cursor INTO @tablename END DEALLOCATE table_cursor; GO
↧