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 |
havey
Starting Member
16 Posts |
Posted - 2008-02-23 : 20:23:41
|
Hi i'm having trouble this is simple task, any thoughts:declare @id intset @id = select w.[PNumber] from [WTables].[dbo].[Demographics] w where w.ENo = 3012the goal is to set the pNumber value to the @idThanks |
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2008-02-23 : 20:31:01
|
What is the problem? Are you getting more than 1 record?You could do it like this:Select Top 1 @ID = w.PNumber FROM [WTables].dbo.[Demographics] w Where w.ENo = 3012 Poor planning on your part does not constitute an emergency on my part. |
 |
|
havey
Starting Member
16 Posts |
Posted - 2008-02-23 : 20:35:52
|
i was getting Incorrect syntax near the keyword 'select'.Your suggestion worked!, thank you very much. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-25 : 03:09:50
|
quote: Originally posted by havey Hi i'm having trouble this is simple task, any thoughts:declare @id intset @id = select w.[PNumber] from [WTables].[dbo].[Demographics] w where w.ENo = 3012the goal is to set the pNumber value to the @idThanks
You should have usedeclare @id intset @id = (select w.[PNumber] from [WTables].[dbo].[Demographics] w where w.ENo = 3012)provided query returns single valueMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|