Get all or part result from sql using one TSQL commnd
Posted
by Yongwei Xing
on Stack Overflow
See other posts from Stack Overflow
or by Yongwei Xing
Published on 2010-04-26T10:58:53Z
Indexed on
2010/04/26
11:03 UTC
Read the original article
Hit count: 196
sql-server
|tsql
Hi All
Here is my condition. There is a Text box in a form, if you don't input any thing, it would return all rows in this table. If you input something, it would return rows whose Col1 matches the input. I try to use the sql below to do it. But there is one problem, these columns allows Null value. It wouldn't return the row with NULL value. Is there any way to return all or matched row based on the input?
Col1 Col2 Col3
ABCD EDFR NULL
NULL YUYY TTTT
NULL KKKK DDDD
select * from TABLE where Col1 like Coalesce('%'+@Col1Val+'%',[Col1])
© Stack Overflow or respective owner