May 13, 2007 at 2:20 pm
Hello
I have the following TSQL update statment and i want to use a local variable to set these value on some fields , but they don´t work :
use focintegra
declare @conta as varchar(15)
set @conta = '62103'
select @conta
go
update cpoo set
/*Base Incidencia MN*/
ve11=@conta
ve21=ve11
ve31=ve11
ve41=ve11
ve51=ve11
from cpoo where cpoo.cpoo like '999999'
Someone could help me
Many thanks
Luis Santos
May 13, 2007 at 4:10 pm
Not too sure of what you want to do nor what is the problem, but give this version a try!
use focintegra
declare @conta as varchar(15)
set @conta = '62103'
select @conta
go
update cpoo set
/*Base Incidencia MN*/
ve21=@conta
ve31=@conta
ve41=@conta
ve51=@conta
ve11=@conta
from cpoo where cpoo.cpoo like '999999'
May 13, 2007 at 4:21 pm
Hello
i try your example but the same return this following error
Must declare the scalar variable "@conta"
Well the purpose is that i want to replace fields ve21,ve31,ve41,ve51 and ve11 on my table cpoo with the same value for cpoo.cpoo like '999999' and to do this i was declare a local variable = "62103" to replace theses fields values with my variable.
Thanks
Luis Santos
May 13, 2007 at 4:23 pm
My exemple will work, just remove the go.
BTW this is why the code samples you post should also work when posted .
May 13, 2007 at 9:02 pm
I'm thinking somebody is going to need a comma or two in there
--Jeff Moden
Change is inevitable... Change for the better is not.
May 14, 2007 at 4:16 am
Yup, that's what happens when you want to help but don't have the time to test the final solution.
Who said that if you don't have time to do it right the first time, then when will have have time to redo it right?
May 14, 2007 at 6:00 am
Heh... my boss' boss says that all the time... it's why our projects seem to go in so fast... who cares if it takes six months extra to fix what we put it? After all, the user are the best testers, right?
--Jeff Moden
Change is inevitable... Change for the better is not.
May 14, 2007 at 11:45 am
That's one way to do things... I preffer my way .
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply