By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,574 Members | 2,960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,574 IT Pros & Developers. It's quick & easy.

Correct syntax for an update stored procedure

P: n/a
This is probably a very simple question but i would appreciate some help with
the correct syntax for and update stored procedure

I have created a user form that allows the user to update the name and
address fields in a datatable called customers based on the input value
customer ID = ( datatable/Customers)customerID

I have got this far and then got lost:

Create SP_UpdateCustomer
(@customerID, @name, @address)

As

Update customers ( name, address)

Where customerID = @customerID

GO

Could anyone tell me what the correct sntax should be.

many thanks

Martin

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200511/1
Nov 24 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"martinharvey" <u14945@uwe> wrote in message news:57d57cab571aa@uwe...
This is probably a very simple question
It is, and has very little to do with ASP.NET -
microsoft.public.sqlserver.programming would have been the correct newsgroup
to post this...
but i would appreciate some help with
the correct syntax for and update stored procedure
A quick search in Books OnLine, or even Google, would have answered this for
you straightaway.
I have created a user form that allows the user to update the name and
address fields in a datatable called customers based on the input value
customer ID = ( datatable/Customers)customerID

I have got this far and then got lost:

Create SP_UpdateCustomer
(@customerID, @name, @address)

As

Update customers ( name, address)

Where customerID = @customerID

GO

Could anyone tell me what the correct sntax should be.


On the assumption that 'customerID' is an int, and that 'name' and 'address'
are varchar(50), the syntax is as follows:

CREATE uspUpdateCustomer
@customerID int,
@name varchar(50),
@address varchar(50)
AS
UPDATE
customers
SET
[name] = @name,
address = @address
WHERE
customerID = @customerID
Also:

1) avoid naming stored procedures SP_xxxxx
http://www.devx.com/tips/Tip/14432

2) avoid using SQL keywords e.g. 'name' as table names or field names
Nov 24 '05 #2

P: n/a
hn
Create Procedure SP_UpdateCustomer
(@customerID Int,
@name NVarchar(200),
@address NVarchar(200)
)

As

update customers set name = @name,
address = @address
where customerID = @customerID

GO

"martinharvey" wrote:
This is probably a very simple question but i would appreciate some help with
the correct syntax for and update stored procedure

I have created a user form that allows the user to update the name and
address fields in a datatable called customers based on the input value
customer ID = ( datatable/Customers)customerID

I have got this far and then got lost:

Create SP_UpdateCustomer
(@customerID, @name, @address)

As

Update customers ( name, address)

Where customerID = @customerID

GO

Could anyone tell me what the correct sntax should be.

many thanks

Martin

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200511/1

Nov 24 '05 #3

P: n/a
Martin,

The correct syntax for a simple UPDATE command would be:

Update customers Set name = @name, address = @address
Where customerID = @customerID

--
Hope this helps,

Bill Manring
"martinharvey" wrote:
This is probably a very simple question but i would appreciate some help with
the correct syntax for and update stored procedure

I have created a user form that allows the user to update the name and
address fields in a datatable called customers based on the input value
customer ID = ( datatable/Customers)customerID

I have got this far and then got lost:

Create SP_UpdateCustomer
(@customerID, @name, @address)

As

Update customers ( name, address)

Where customerID = @customerID

GO

Could anyone tell me what the correct sntax should be.

many thanks

Martin

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200511/1

Nov 24 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.