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)
 How to check in any field within this table this v

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2012-12-27 : 06:56:46
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
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-12-27 : 07:18:56
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
   

- Advertisement -