| Author |
Topic |
|
jgn1013
Starting Member
24 Posts |
Posted - 2009-07-28 : 12:46:27
|
Need some help please, try to convert a oracle sql statement but have never worked with Select Into from variable.This is the oracle stored procedure sample, can i get some help in converting to ms sql. TIAcreate procedure test( @userid varchar(8), @flag varchar(10), @pwd varchar(8))ASdeclare @count intdeclare @pwd2 varchar(8)select tablename.password into @pwd2from tablenamewhere upper(userid) = upper(@userid) end |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-28 : 13:06:08
|
select @pwd2 = tablename.password from tablename where ... No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-07-28 : 13:09:09
|
| Also, if you do not have case sensitive collation on your SQL server then you do not need to use the UPPER function. Just thought I'd mention it just in case... |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-28 : 13:36:10
|
My given solution is as wrong or as right as the code in the opening post. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
jgn1013
Starting Member
24 Posts |
Posted - 2009-07-28 : 14:15:27
|
quote: Originally posted by webfred My given solution is as wrong or as right as the code in the opening post. No, you're never too old to Yak'n'Roll if you're too young to die.
the query "select @var = tablename.pwd where userid = @userid" just assigns the variable @var the pwd correct? If so then why can't i get this to work?oracle statementselect distinct(wa) into @var from tablename where id = @idI tried doing it this was but I get an errorselect @var = distinct wa from tablename where id = @id______________________________________________________________Is this the solution?select @var = (select ditinct(wa) from tablename where id = @id) |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-28 : 14:43:13
|
So if you can't get it to work then what is the problem?Is there an error message?Please show:executed statementerror messageThank you for helping to help you  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
jgn1013
Starting Member
24 Posts |
Posted - 2009-07-28 : 14:46:07
|
I think this is the correct select statementselect @var = (select ditinct(wa) from tablename where id = @id) |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-28 : 14:50:43
|
Then try it and you will know...Good luck! No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|