SQL Server Forums
Profile | Register | 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
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cplusplus
Aged Yak Warrior

533 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
2869 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  
 New 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.05 seconds. Powered By: Snitz Forums 2000