![]() |
| |||||||
| Sponsored Links |
![]() |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
| I have a query like the following: Code: "SELECT " & _
[last_name]," & _
[first_name]," & _
[hire_date]," & _
"FROM vw_people " & _
"WHERE id = @id"
Anyway, is there a way via my above query to return a default date if "hire_date" is NULL? I'm using SQL Server 2000. This is a hard coded query unfortunately and I'm not sure if I can do some sort of SELECT CASE here.
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.If you like it here...throw us a few bones to help support us. Join our Folding team: DeveloperBarn Folding |
| Sponsored Links |
|
#2
| ||||
| ||||
| try something like this Code: "SELECT " & _
[last_name]," & _
[first_name]," & _
CASE WHEN [hire_date] IS NULL THEN 'default_date' ELSE [hire_date] END AS hire_date," & _
"FROM vw_people " & _
"WHERE id = @id"
__________________ Quote of the Month: Quality: The race for quality has no finish line- so technically, it's more like a death march. Questions to Ponder: What do you do when you see an endangered animal eating an endangered plant? iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm") copyright © 2008 sbenj69 |
|
#4
| ||||
| ||||
| then you would need to do something in the .NET app to account for NULL values? |
|
#5
| ||||
| ||||
| That's the problem. For some reason certain .Net methods won't accept NULL dates. Which is why I'm trying to return a default value before it gets to the method. |
|
#6
| ||||
| ||||
| then without changing the query ... i don't see how you can. unless you update the database and put a default value in there. |
|
#7
| ||||
| ||||
| Quote:
![]() And believe me, I'd much rather rid myself of NULL in this database, but that is not up to me, unfortunately. |
|
#8
| ||||
| ||||
| ugh ... you said it was hardcoded ... wow ... need to get my head out of the clouds. use what i posted then. |
|
#9
| ||||
| ||||
| Quote:
When you said 'change your query', I was confused as that was a vague statement. So I'm assuming there is no way to do what I want and I'm going to have to put my right boot on when I go talk to the database morons. |
|
#10
| ||||
| ||||
| Hmm, y'all seem to be posting in circles here JMH & mehere . Obviously sumpin' gotta change sumplace, so which would you like to do:(a) Change the data (b) Change the query (c) Handle the null in code (d) Write a sproc (e) Kill the DB designer ?
__________________ Wolffy ------------------------ Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary. |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| No Default Member Found for type | richyrich | .Net Development | 5 | May 29th, 2008 01:33 PM |
| Webform Default Button | Devwhiz | .Net Development | 9 | May 15th, 2008 01:15 PM |