November 1, 2013 at 12:10 pm
Declare @SVPID int
Set @SVPID = 0
Select SummaryTitle =
Case When @SVPID = 0 Then 'All SVPs' Else Division End From ITSDivision Where ID = @SVPID
This should has nothing to do with the content of table ITSDivision when I query on the case of @SVPID = 0, why I get a empty SummaryTitle?
The content of ITSDivision is:
ID Division
1Division1
2Division2
3Division3
4Division4
5Division5
6Division6
Thank you.
November 1, 2013 at 12:23 pm
halifaxdal (11/1/2013)
Declare @SVPID int
Set @SVPID = 0
Select SummaryTitle =
Case When @SVPID = 0 Then 'All SVPs' Else Division End From ITSDivision Where ID = @SVPID
This should has nothing to do with the content of table ITSDivision when I query on the case of @SVPID = 0, why I get a empty SummaryTitle?
The content of ITSDivision is:
ID Division
1Division1
2Division2
3Division3
4Division4
5Division5
6Division6
Thank you.
SummaryTitle is empty because there are no rows in ITSDivision where ID = 0. The code you posted will not return any rows.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
November 1, 2013 at 12:30 pm
Sean Lange (11/1/2013)
SummaryTitle is empty because there are no rows in ITSDivision where ID = 0. The code you posted will not return any rows.
The cause turns out to be so simple! 😉
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply