Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Find a string value in all varchar/text fields

Author  Topic 

Ciupaz
Posting Yak Master

232 Posts

Posted - 2014-01-10 : 10:03:57
Hello all,
is it possible to find Column/Table that contains a
particular string in varchar/nvarchar/text fields for every table in my database?

For example, having the string 'Welcome'
I need to find the field/fields in every table
where this string is in.

Thanks in advance.

Luis

djj55
Constraint Violating Yak Guru

352 Posts

Posted - 2014-01-10 : 12:32:33
To find all columns of a data type look ate the sys.table, sys.columns, and sys.types tables.

Someone will most likely have a neat way of doing it, but I use those tables.

djj
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-01-10 : 23:16:12
quote:
Originally posted by Ciupaz

Hello all,
is it possible to find Column/Table that contains a
particular string in varchar/nvarchar/text fields for every table in my database?

For example, having the string 'Welcome'
I need to find the field/fields in every table
where this string is in.

Thanks in advance.

Luis



see
http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Ciupaz
Posting Yak Master

232 Posts

Posted - 2014-01-12 : 14:47:02
That stored procedure works perfectly. Thanks a lot Visakh.

Luis
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-01-13 : 05:58:57
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-01-27 : 07:09:44
Another one http://beyondrelational.com/modules/2/blogs/70/posts/10883/search-a-value-in-character-column-of-all-tables.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -