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.
Author |
Topic |
jassie
Constraint Violating Yak Guru
332 Posts |
Posted - 2012-10-18 : 01:41:48
|
In a sql server 2008 r2 database, I have a column that can be null. What I am looking for values that equal zero. The column I am looking at is declared as an ineger. Thus how do I check for the value = 0, but not select recrods where the value in this column can be null.How would I do this check in a where statement? |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-10-18 : 01:54:56
|
SELECT * FROM YourTableNameWHERE ColumnName = 0--Chandu |
|
|
Andy Hyslop
Starting Member
14 Posts |
Posted - 2012-10-18 : 04:35:14
|
Or is you just wanted to return any integers excluding NULLS without hard coding the WHEREDECLARE @TABLE AS TABLE(NUMBER INT)INSERT INTO @TABLE(NUMBER)SELECT NULL UNION ALLSELECT NULL UNION ALLSELECT 0 UNION ALLSELECT 1 UNION ALLSELECT 2 SELECT *FROM @TABLEWHERE ISNUMERIC(NUMBER) = 1 Andy |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-10-18 : 05:34:30
|
copy/paste this into a query window, run it and see what happens.declare @sample table (id int null)insert @sampleselect null union allselect 5 union allselect 10 union allselect 0 union allselect nullselect * from @samplewhere id=0select * from @samplewhere id is nullselect * from @samplewhere id is not null Too old to Rock'n'Roll too young to die. |
|
|
|
|
|