SELECT sysobjects.name
FROM syscolumns
LEFT JOIN sysobjects on sysobjects.id = syscolumns.id
WHERE syscolumns.name LIKE ‘%fieldname%’
ORDER BY 1
Tag: SQL Server
SQL Server: Remove All Data From Database
— disable referential integrity:
EXEC sp_MSForEachTable ‘ALTER TABLE ? NOCHECK CONSTRAINT ALL’
GO
–delete the data:
EXEC sp_MSForEachTable ‘DELETE FROM ?’
GO
— enable referential integrity again:
EXEC sp_MSForEachTable ‘ALTER TABLE ? CHECK CONSTRAINT ALL’
GO