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
 stored variable

Author  Topic 

tariq2
Posting Yak Master

125 Posts

Posted - 2011-02-14 : 06:40:07
I want to run a query using a stored variable.

So instead of:
select * from d_jobattributes where jobid = '0903370501'

I want to run the following:

declare @job varchar
set @job = 0903370501
select * from d_jobattributes where jobid = @job

However when I process:
select @job

I get a * in the results pane

Thanks in advance



SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-02-14 : 06:43:37
declare @job varchar(30)
set @job = '0903370501'


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-14 : 09:41:03
Also refer this post
http://beyondrelational.com/blogs/madhivanan/archive/2007/12/04/column-length-and-data-length.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -