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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Outputing text

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 not

can these things be done?

Thank you for the help

Mark

Dev@nlkss

134 Posts

Posted - 2009-05-11 : 05:54:42
Try this,

DECLARE @TAB TABLE(date datetime)
insert into @tab
select getdate()
union
select null

select isnull(convert(varchar(12),date,107),'No datafound')
from @tab

$atya.

Love All Serve All.
Go to Top of Page

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 again

Mark
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-05-11 : 06:09:23
U can make use of case statement

Select case when column1 <10 then "data less then 10" else "Data greater then 10" end
from table1


Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled
Go to Top of Page

MarkSensei
Starting Member

4 Posts

Posted - 2009-05-11 : 07:25:54
Thank you, that works great. I ended up with this
SELECT CASE WHEN COUNT(ItemID ) between 1 and 100 THEN 'less than 100' ELSE 'Greater Than 100'END

I wonder if this statement can be used for more values like
between 1~100
between 101~500
between 501~1000
for example

Thank you for all the help
Go to Top of Page

MarkSensei
Starting Member

4 Posts

Posted - 2009-05-11 : 10:28:50
OK I figured it out. Thank you everyone!
Go to Top of Page
   

- Advertisement -