Home > Microsoft SQL Server > Passing a value into a variable in a Stored Procedure

Passing a value into a variable in a Stored Procedure



Hi everyone



I would like to know how to declare a variable

Set a value from a database table to that variable

And Then IF that variable = a value

Then to execute an Update statement



The error message i get when executing the stored procedure is as follows:



The multi-part identifier "dbo.OrdersCheckStockAvailable.WarehouseTypeID" could not be bound.



The example of the code i have attempted is as below.



DECLARE @WID varchar(10)

SET @WID =dbo.OrdersCheckStockAvailable.WarehouseTypeID

IF @WID = 'WT1'

BEGIN

UPDATE dbo.OrderParams SET dbo.OrderParams.WarehouseTypeID='WT2' WHERE (dbo.OrderParams.TempOrderNo)=@TON;

END





CAN ANYONE PLEASE HELP ME WITH THIS ONE.

    
Guest


Example:


Code:



DECLARE @WID varchar(10)
SELECT @WID = dbo.OrdersCheckStockAvailable.WarehouseTypeID

IF @WID = 'WT1'
BEGIN
UPDATE dbo.OrderParams SET dbo.OrderParams.WarehouseTypeID='WT2' WHERE (dbo.OrderParams.TempOrderNo)=@TON;
END



Was this answer helpful ? Yes No   
Guest


Ive changed 'SET' TO 'SELECT' and i still recieve the following error:



Msg 4104, Level 16, State 1, Procedure TestOrderProcess, Line 45

The multi-part identifier "dbo.OrdersCheckStockAvailable.WarehouseTypeID" could not be bound.



Does anyone know what the above error actually means or can help me with the above query.



Thanks

Was this answer helpful ? Yes No   
Guest


What is this?


Code:



dbo.OrdersCheckStockAvailable.WarehouseTypeID




is it a table? a stored procedure?




Code:



SELECT @WID = WarehouseTypeID FROM dbo.OrdersCheckStockAvailable WHERE...



Was this answer helpful ? Yes No   
Guest


It is a Query.

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2010 by Infoqu. All rights reserved