There could be situations when we need to know all the table names in our database which contain a required column name.The below stored procedure could be of use -
If exists ( select * from sysobjects where name
like 'GetTableName' and type = 'P'
)
BEGIN
DROP procedure GetTableName
END
GO
Create procedure GetTableName
@strString varchar(100)
As
Begin
Select name from sysobjects
where id in ( Select id from syscolumns where name like @strString )
End
GO
No comments:
Post a Comment