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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Changing a table value!

Author  Topic 

macca
Posting Yak Master

146 Posts

Posted - 2005-06-07 : 06:41:15
I want to change the value of a variable in a table. I am using the set command but keep getting error. Here's my code:

set deptid = '35' for Staff_tsf
where staffno = '56'

deptid and staffno are columns in the table staff.

The error message is "Line 1: Incorrect syntax near '='."

Anyone any ideas what i'm doing wrong?

Thanks.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-07 : 06:47:41
That should be

Update Staff_tsf set deptid = '35' where staffno = '56'



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

macca
Posting Yak Master

146 Posts

Posted - 2005-06-07 : 07:01:39
Thanks for the reply, I should've known that, brain not workin or something.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-07 : 07:18:06
Well. Take relax and have cup of coffee

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

zokho
Starting Member

10 Posts

Posted - 2005-06-07 : 19:01:49
HI
the SET comand id used for variables and variable have to have @or@@ before their name
and for your question i suggest you to use UPDATE TableName SET RecordName=NewValue WHERE staffno='56'
and be sure that staffno is a varchar()datatype not INT
i hope my offer will be helpfull
babye
Go to Top of Page
   

- Advertisement -