473,506 Members | 17,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Correct syntax for an update stored procedure

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
3 1564
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14342
by: Robert | last post by:
I'm enhancing a large ASP application by replacing raw SQL statements in the code with calls to stored procedures. I've seen this recommended in many places to increase SQL Server effieicency....
9
9094
by: David Berman | last post by:
I'm having a problem with an update operation in a stored procedure. It runs so slowly that it is unusable, unless I comment a part out in which case it is very fast. However, I need the whole...
5
5119
by: S.Patten | last post by:
Hi, I have a problem with updating a datetime column, When I try to change the Column from VB I get "Incorrect syntax near '942'" returned from '942' is the unique key column value ...
18
5935
by: Bill Smith | last post by:
The initial row is inserted with the colPartNum column containing a valid LIKE pattern, such as (without the single quotes) 'AB%DE'. I want to update the column value with the results of a query...
1
11217
by: Sandesh | last post by:
Hello All, Me saying " has any body come across such error would be underestimating". Well I am getting a very peculiar and unique error "Line 1: Incorrect syntax near 'Actions'." ...
5
5331
by: wpellett | last post by:
I can not get the SQL compiler to rewrite my SQL UPDATE statement to include columns being SET in a Stored Procedure being called from a BEFORE UPDATE trigger. Example: create table...
10
4569
by: Ivan | last post by:
Hi to all !!! I have one stored procedure that update and delete rows in differents tables, but when I try of delete of the main table this show problems with primary and foreign key. I DROP...
3
1228
by: Grey Alien | last post by:
I have created a SQL Server Express db in my ASP.Net website. I have a file that contains several SQL statements to create tables (100+) and stored procedures. I am guessing that there has to be a...
6
7264
Soniad
by: Soniad | last post by:
Hello, I am excecuting a stored procedure in my ASP page , it has one out parameter (@confirm) . after executing the procedure i want to retreive this out parameter and assign it to variable...
0
7220
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7105
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7023
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5037
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
410
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.