SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 print variable contents
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

-Dman100-
Posting Yak Master

210 Posts

Posted - 07/04/2006 :  18:18:42  Show Profile
I have the following table which I want to display the output using print.

Here is my table:

dbo.press_releases
headline varchar(255)
description varchar(294)
content text
pr_date datetime
pdf varchar(255)
id int primary key


Using query analyzer I was trying the following statement to display the contents:

DECLARE @pr varchar(8000)

SET @pr = (SELECT headline, description, content
FROM dbo.press_releases
WHERE id = 11)

print @pr

Thanks for any help.

khtan
In (Som, Ni, Yak)

Singapore
17645 Posts

Posted - 07/04/2006 :  18:25:25  Show Profile
You have to declare one variable for each column

select @hl = headline, @dc = description, @ct = convert(varchar(8000), content)
from dbo.press_releases
where id = 11




KH

Go to Top of Page

-Dman100-
Posting Yak Master

210 Posts

Posted - 07/04/2006 :  18:37:26  Show Profile
Thank you.
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22761 Posts

Posted - 07/05/2006 :  04:15:30  Show Profile  Send madhivanan a Yahoo! Message
or

If all columns are of varchar type, then

DECLARE @pr varchar(8000)

SET @pr = (SELECT headline+','+ description+','+ content
FROM dbo.press_releases
WHERE id = 11)

print @pr


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000