|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Correct syntax for an update stored procedurethe 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/Forums.aspx/asp-net/200511/1 "martinharvey" <u14945@uwe> wrote in message news:57d57cab571aa@uwe... It is, and has very little to do with ASP.NET - > This is probably a very simple question microsoft.public.sqlserver.programming would have been the correct newsgroup to post this... > but i would appreciate some help with A quick search in Books OnLine, or even Google, would have answered this for > the correct syntax for and update stored procedure you straightaway. Show quoteHide quote > I have created a user form that allows the user to update the name and On the assumption that 'customerID' is an int, and that 'name' and 'address' > 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. 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 Create Procedure SP_UpdateCustomer
(@customerID Int, @name NVarchar(200), @address NVarchar(200) ) As update customers set name = @name, address = @address where customerID = @customerID GO Show quoteHide quote "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/Forums.aspx/asp-net/200511/1 > Martin,
The correct syntax for a simple UPDATE command would be: Update customers Set name = @name, address = @address Where customerID = @customerID -- Show quoteHide quoteHope 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/Forums.aspx/asp-net/200511/1 >
Other interesting topics
Using Components in ASP.NET (C#)
The system cannot find the file specified. (Exception from HRESULT: 0x80070002) XHTML 1.0 About web.config file Retreive images stored in Access database Can we search keywords in a word document? Setting Profile properties for not logged in users Dynamic content problem MS Forms 2.0 Combo box control How to initiate a postback in a function? |
|||||||||||||||||||||||