TSQL

There are 2 entries for the tag TSQL

Search across all fields in all tables in SQL server

I found this script that allows you to search across all fields in all tables of a database for a specific string. It’s helpful when you trying to where data might be stored in a strange/large/new database that you are not intimately familiar with. Being a consultant I have found myself digging though a clients database many times trying to figure how the data is stored and this has saved me from looking in every table manually. I did not come up with this code myself, but I didn’t save the link of the blog where I found it. So...

Search for column name across all tables

  Here is another sql script I got from my friend David McCollough that will allow you to search all tables for a specific field name. Just set the @ColumnName variable and let ‘er rip.   DECLARE @ColumnName varchar(1000) SET @ColumnName = 'PlayerId' select o.name as TableName, c.name as [ColumnName] from sysobjects o inner join syscolumns c on c.id = o.id where o.type = 'u' and c.name = @ColumnName ...