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 |
|
MarkSensei
Starting Member
4 Posts |
Posted - 2009-05-11 : 05:33:36
|
| Hi,I have a CMS called dotnetnuke and am using a SQL module to output from the database. I have been looking around but I can not find a way to output text though. For example if a simple SQL select returns no date, show "There is no data".Or using IF statements, and show a message depending if the statement is true or notcan these things be done?Thank you for the helpMark |
|
|
Dev@nlkss
134 Posts |
Posted - 2009-05-11 : 05:54:42
|
| Try this,DECLARE @TAB TABLE(date datetime)insert into @tabselect getdate()union select nullselect isnull(convert(varchar(12),date,107),'No datafound') from @tab$atya.Love All Serve All. |
 |
|
|
MarkSensei
Starting Member
4 Posts |
Posted - 2009-05-11 : 06:06:15
|
| Thank you. I will give it a try. How about using IF statements? for example a users comment count, if commentCount is between 1~10 then show "text 1"commentCount is between 11~100 then show "text 2"and so on..thank you againMark |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-05-11 : 06:09:23
|
| U can make use of case statementSelect case when column1 <10 then "data less then 10" else "Data greater then 10" endfrom table1Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceled |
 |
|
|
MarkSensei
Starting Member
4 Posts |
Posted - 2009-05-11 : 07:25:54
|
| Thank you, that works great. I ended up with thisSELECT CASE WHEN COUNT(ItemID ) between 1 and 100 THEN 'less than 100' ELSE 'Greater Than 100'ENDI wonder if this statement can be used for more values likebetween 1~100between 101~500between 501~1000for exampleThank you for all the help |
 |
|
|
MarkSensei
Starting Member
4 Posts |
Posted - 2009-05-11 : 10:28:50
|
| OK I figured it out. Thank you everyone! |
 |
|
|
|
|
|