Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
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  

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:

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.

In (Som, Ni, Yak)

17689 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


Go to Top of Page

Posting Yak Master

210 Posts

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

Premature Yak Congratulator

22864 Posts

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

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


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.02 seconds. Powered By: Snitz Forums 2000