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 |
fralo
Posting Yak Master
161 Posts |
Posted - 2010-12-21 : 13:50:19
|
Hi all,I'm very new with t-sql. I'm trying to simply store the value from a query and am unsure what is wrong with this statement.I'm getting: 'Incorrect syntax near the keyword 'select'BEGIN set @empid = select empid from [eso-cad].empmast.dbo.empmast a where a.lname =@lname and a.mname = @mname and a.fname = @fname update test_Concentra set empid = @empid where lname = @lname and mname = @mname and fname = @fname fetch next from emp_cursor into @lname,@fname,@mnameendThanks for your help. |
|
Kristen
Test
22859 Posts |
Posted - 2010-12-21 : 13:58:50
|
set SELECT @empid = select empid from [eso-cad].empmast.dbo.empmast awhere a.lname =@lname and a.mname = @mname and a.fname = @fnameAlthough:1. Your statement is not ATOMIC so there is opportunity for another process to update the record between your SELECT and UPDATE2. Using Cursors is slow and not recommended. Use SET-Based logic if possible. |
 |
|
fralo
Posting Yak Master
161 Posts |
Posted - 2010-12-21 : 14:05:15
|
That works. thanks a lot. |
 |
|
|
|
|