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 |
|
SimonGough
Starting Member
23 Posts |
Posted - 2002-01-11 : 06:46:03
|
| select jobID, transportjobnumber from transport_job_numbers where jobID = 1 select @transjobnum = transportjobnumberThis SQL is from a transaction in an insert stored procedure. I need to grab this number and then set it to the @transjobnum variable but I am getting an 'Invalid column name' error for 'transportjobnumber'there are no spelling mistakes or anything so I can't figure what is wrongany idea's???Simon |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-01-11 : 06:57:41
|
Hi SimonThat is running as two separarate statements.By the time the second select runs, it has no idea what transportjobnumber is. Also you can not do variable assigning in the same batch, so you would have to do thisselect jobID, transportjobnumber,from transport_job_numbers where jobID = 1Select @transjobnum = transportjobnumberfrom transport_job_numbers where jobID = 1 Hope that helpsDamian |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-01-11 : 17:25:49
|
quote: Also you can not do variable assigning in the same batch...
OK, Merkin, why do you say this? Is it because Simon mentioned that this is in an insert stored procedure? I don't see any INSERT syntax here, so I guess we're assuming that the syntax being used isINSERT INTO.... SELECT jobID, trans...In that case, I agree. However, if this select is separate from the INSERT statement (even though it's in the same stored procedure), then it seems to me you could do the assigning in the one statement.--------------------------------There's a new General in town...Edited by - AjarnMark on 01/11/2002 17:26:21 |
 |
|
|
|
|
|
|
|