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 |
|
Potso6767
Starting Member
18 Posts |
Posted - 2009-02-19 : 14:53:24
|
| I am writing a Query that will bring back a row in the database if any field within that row is null... Does anyone know a Where statement i can use to do this instead of creating a where statement like the followingselect * from table1where field1 is null or field2 is null, or field3 is null......(there are a ton of fields, and about 15 tables i have to do this for so i am sure you can understand why i dont want to have to type out every field!) |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-02-19 : 15:03:24
|
| You can use excel to avoid typing,use sp_help to find the name of the fields in table, copy and paste in column B in excel, type 'select * from table1 where ' in a cell in column A, paste the same in rest of the cells in column A, type 'is null or' in column D and paste the same in rest of the cells in column C. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-02-20 : 03:07:50
|
| or make use of the resultselect column_name +' is null or ' from information_schema.columnswhere table_name='table_name'MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-20 : 03:48:08
|
| [code]declare @col_list varchar(1000)select @col_list=coalesce(@col_list,'') + column_name +' is null or ' from information_schema.columnswhere table_name='sales_process'and is_nullable='Yes'select @col_list[/code] |
 |
|
|
|
|
|