| Author |
Topic |
|
jkessler43
Starting Member
2 Posts |
Posted - 2012-01-03 : 16:24:14
|
| Hello all,I have a SQL Query that I am running that writes a file full of selected variables from different tables. One of those fields being outputted has the potential to be a null value. My problem is when there is no value I would like to write "null" to the file. How do I do this?SELECT COALESCE((Select d.DATEFrom TWO b, ONE c, THREE d Where 1=1 and c.onething = b.onethingand d.something = b.somethingelseand d.ID = '213'), 'NONE') AS DATEConversion failed when converting date and/or time from character string.Ultimately I want to output this to a file. I am just trying to get the output I want first. Any Ideas?Thanks, |
|
|
jkessler43
Starting Member
2 Posts |
Posted - 2012-01-03 : 16:30:32
|
| I apologize this is the error I am getting: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-04 : 06:13:43
|
quote: Originally posted by jkessler43 I apologize this is the error I am getting: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
check subquery and see if its returning more than a row. if yes you cant use it inside COALESCE as done nowSelect d.DATEFrom TWO b, ONE c, THREE d Where 1=1 and c.onething = b.onethingand d.something = b.somethingelseand d.ID = '213' ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-04 : 06:16:24
|
| Actually i didnt get what OP is trying to do with subquery here------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|