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
 General SQL Server Forums
 New to SQL Server Programming
 SQL LIKE

Author  Topic 

sinichi
Starting Member

2 Posts

Posted - 2012-10-30 : 21:09:05
hi! good day,

help me with this please, is this right??

SELECT * FROM a_tablename WHERE * LIKE '%a_value%'

cuz i want to find a specific value in all of my columns, but it would'nt work..

can you help me out?

sinichi-lio

sinichi
Starting Member

2 Posts

Posted - 2012-10-30 : 21:17:28
soory i forgot to include FROM and the table name.

its actually like this.

SELECT * FROM a_tablename WHERE * LIKE '%a_value%'.

tnx sqlconfused

sinichi-lio
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-10-30 : 22:18:08
WHERE col1 LIKE '%a_value%'
or col2 LIKE '%a_value%'
....

if you want the string to span columns then a single col1+col2+... like ... (maybe with coalesce to take care of nulls).

You can generate the statement from information_schema.columns.


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-11-02 : 04:42:11
Make use of this effectively
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 -