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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a stored proc

Status
Not open for further replies.

AlwaysWilling

Programmer
Dec 29, 2005
51
0
0
US
Hi everyone, I am creating a stored proc like this:
Code:
use northwind
GO

create procedure sp_insert_orderDetails
  @OrderID int,
  @ProductID int,
  @UnitPrice smallmoney,
  @Quantity smallint,
  @Discount real
as

insert into sp_insert_orderDetails (OrderID, ProductID, UnitPrice, Quantity, DiscountValue)
values (@OrderID, @ProductID, @UnitPrice, @Quantity, @Discount)

And I get get a successful message like: The command(s) completed successfully..

Now, how can I insert values using this sp?

I tried this but didn't work:
Code:
use northwind
GO

create procedure sp_insert_orderDetails
  @OrderID int,
  @ProductID int,
  @UnitPrice smallmoney,
  @Quantity smallint,
  @Discount real
as

insert into sp_insert_orderDetails (OrderID, ProductID, UnitPrice, Quantity, DiscountValue)
values (@OrderID, @ProductID, @UnitPrice, @Quantity, @Discount)

GO

sp_insert_orderDetails @OrderID= '10245', @ProductID= '2', @UnitPrice= $123123.45, @Quantity = '20', @Discount= '.25'

GO

And I get an error like Server: Msg 208, Level 16, State 3, Procedure sp_insert_orderDetails, Line 10
Invalid object name 'sp_insert_orderDetails'.


What am I doing wrong?
 
You can't use a dollar sign in your EXEC statement.

BTW, you don't need quotes around integars, small or otherwise. But that's a semantics thing and won't cause problems with your EXEC statement.



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
Hi Catadmin, thanks for the reply.

I removed the $-sign but I still get that error. Am I calling the sp correctly?
 
you should use the EXEC statement:
Code:
EXEC sp_insert_orderDetails @OrderID= '10245', @ProductID= '2', @UnitPrice= 123123.45, @Quantity = '20', @Discount= '.25'
that should work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top