Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple stored proc undate problem

Status
Not open for further replies.

anyideas

Programmer
May 2, 2002
127
GB
hi, I'm trying to update several columns in a row, but am running into problems.

If anyone can help I'd appreciate it... the database is sql2000.

cheers

mark

CREATE PROCEDURE op_CSUpdateCustomer(
@CustomerID int,
@CustomerTitle char(20),
@CustomerFirstName char(40),
@CustomerLastName char(40),
@CustomerInitials char(10),
@CustomerDOB char(40),
@SourceID int,
@Notes varchar(255),
@DateCreated datetime
)

AS

UPDATE tbl_Customers(
CustomerTitle
,CustomerFirstName
,CustomerLastName
,CustomerInitials
,CustomerDOB
,SourceID
,CustomerNotes
,DateCreated
)
VALUES(
@CustomerTitle
,@CustomerFirstName
,@CustomerLastName
,@CustomerInitials
,@CustomerDOB
,@SourceID
,@Notes
,@DateCreated
)

WHERE CustomerID = @CustomerID

GO
 
Are you getting an error message back?

Maybe you need to change your where clause to:

WHERE tbl_Customers.CustomerID = @CustomerID

-SQLBill
 
it won't even pass the syntax check - error incorrect syntax near line 25:

,DateCreated
--> )
VALUES(

I'm really not sure whether an insert can be done like this.

cheers for replying

mark
 
The syntax that you want to use is as follows...

UPDATE tblName SET col_name1=@val1, col_name2=@val2, etc, etc
WHERE customerID = @customerID

Jim
 
Try using the update this way

UPDATE tbl_Customers
set CustomerTitle = @CustomerTitle
,CustomerFirstName = @CustomerFirstName
, etc....
WHERE CustomerID = @CustomerID

Phil



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top