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 |
Fulkan
Starting Member
2 Posts |
Posted - 2013-04-20 : 17:40:58
|
i got a problem with a easy stored procedure that gives me the error: Incorrect syntax near keyword 'select'. Must declare the scalar variable "@llnnr".------------------------------ALTER procedure ziekeleerling@voornaam varchar(50),@achternaam varchar(50)asbegindeclare @llnnr as numeric = select llnnr from Leerlingen where @voornaam = voornaaminsert into Ziektes(llnnr,voornaam,achternaam,datum)values(@llnnr,@voornaam,@achternaam,getdate())end------------------------------i have a table with automatic raise on the primary key (nummeric) for evey new entry. it has 3 fields "voornaam", "achternaam" and "llnnr". all i want in the declare is for the @llnnr to get the value of llnnr on the place where the @voornaam is "voornaam" in my table. i can't figure out the error |
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-04-20 : 20:10:59
|
Use parenthesis around your select statement as shown in red below:[CODE]declare @llnnr as numeric = (select llnnr from Leerlingen where @voornaam = voornaam)[/CODE] |
|
|
Fulkan
Starting Member
2 Posts |
Posted - 2013-04-21 : 09:55:37
|
... i feel like such a clown now, that i could have missed that, thank you |
|
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-04-21 : 10:29:37
|
No worries, it happens to the best of us |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-22 : 01:39:59
|
quote: Originally posted by Fulkan ... i feel like such a clown now, that i could have missed that, thank you
hope you'll have only one record per value of voornaam otherwise the select will fail------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|