|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Simple Query Analyzer Query question
Hello all,
Simple question here in regards to strings in SQL. I'm more of a Visual Basic's guy so maybe someone can relate. How do I assign a particular value to a variable in SQL? Here is an example: Select userid From Users Where (username = 'JohnSmith') I would like to assign that value from that query to for example IntUSERID so I can use it in this context: Update TblUsersInfo Set lockout=0, password='Nothing' Where (userid=IntUSERID) Im sure this is extremely simple but I dont know how to assign information to a variable. |
|
#2
|
||||
|
||||
|
One Way:
Code:
Update TblUsersInfo Set lockout=0, password='Nothing' Where (userid = (Select userid From Users Where (username = 'JohnSmith')))
__________________
Wolffy ------------------------ Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary. Not FDIC insured |
|
#3
|
|||
|
|||
|
Excellent that will do the trick. Thank you.
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Simple Query Analyzer Query question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|