Make PROCEDURE for insertn new bill from table order . is this right in sql server 2008 -
this code procedure . right want create procedures insert new bill , info here , need 1 table . columns in info in query . still want know if error . thanks
use [northwind] go create procedure [dbo].[proc_orders] ( @orderid int , @customerid nvarchar(5), @employeeid int , @orderdate datetime, @requireddate datetime, @shippeddate datetime, @shipvia int, @freight money, @shipname nvarchar(40), @shipaddress nvarchar(60), @shipcity nvarchar(15), @shipregion nvarchar(15), @shippostalcode nvarchar(10), @shipcountry nvarchar(15) ) begin set nocount on insert dbo.orders ( orderid, customerid, employeeid, orderdate, requireddate, shippeddate, shipvia, freight, shipname, shipaddress, shipcity, shipregion, shippostalcode, shipcountry ) values ( @orderid, @customerid, @employeeid, @orderdate, @requireddate, @shippeddate, @shipvia, @freight, @shipname, @shipaddress, @shipcity, @shipregion, @shippostalcode, @shipcountry ) end declare @return_value int exec @return_value = [dbo].[proc_orders] @orderid = n'my order', @customerid = 0, @employeeid = 0, @orderdate = n'2014-1-1', @requireddate = n'2014-1-1', @shippeddate = n'2014-1-1', @shipvia = 0, @freight = 0, @shipname = 0, @shipaddress = 0, @shipcity = 0 , @shipregion = 0 , @shippostalcode = 0, @shipcountry = 0 declare @rc int execute @rc = dbo.proc_orders 'my order',0,0,n'2014-1-1',n'2014-1-1',n'2014-1-1',0,0,0,0,0,0,0,0;
insert dbo.orders ( column list ) select column list from dbo.bill orderid = @var
by doing way , need pass orderid lone parameter procedure.
sql sql-server
No comments:
Post a Comment