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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to check in any field within this table this v
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cplusplus
Aged Yak Warrior

567 Posts

Posted - 12/27/2012 :  06:56:46  Show Profile  Reply with Quote
Is it possible to check the value in all fields any where it is occuring, this table has more than 80 columns.


select all_fields from T_SS_BSYRRVP where value=2027171

Thanks a lot for the helpful info.

jimf
Flowing Fount of Yak Knowledge

USA
2875 Posts

Posted - 12/27/2012 :  07:18:56  Show Profile  Reply with Quote
You can do something like this

select
'IF EXISTS (SELECT *
FROM T_SS_BSYRRVP
WHERE [' + COLUMN_NAME + '] = 2027171
)
SELECT ''' + REPLACE('[!]','!',COLUMN_NAME) +'''' +char(10)

from information_schema.columns dbs
where data_type like '%int%'

It will generate the code that you can then run in a query window.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000