2012-03-13 66 views
-1

我已經創建了一個存儲過程,但是當我正在執行這個過程但它顯示了一些錯誤。我不知道如何按順序傳遞變量值?SQL Server 2008中的執行過程

create procedure usp_cust4 
@EMPLOYEE_ID float(10), 
@EMP_NAME nvarchar(255), 
@DEPARTMENT_ID nvarchar(255), 
@DEPARTMENT_NAME nvarchar(255), 
@EMP_SALARY float(10) 
as 
update cust 
set 
[email protected]_NAME, 
[email protected]_ID, 
[email protected]_NAME, 
[email protected]_SALARY 
where [email protected]_ID* 

回答

3
exec usp_cust4 1, 'Smith', 1, 'Marketing', 1000 
+0

雅,它爲我的工作..!這意味着我們必須以相同的順序傳遞變量值,因爲它們出現在聲明部分中。或者我必須傳遞值,因爲它們在Update語句中使用。 – 2012-03-13 10:35:05

+2

@manojkumarsingh:或者您按**定義的**相同順序傳遞它們,或者您需要**指定參數名稱** exec exec_cust4 @EMP_SALARY = 10987,@EMP_NAME =「Manoj」..... ' – 2012-03-13 10:40:37

+0

酷男!很好的解釋 – 2012-03-13 10:45:31

2
exec usp_cust4 
@EMPLOYEE_ID  = 1, 
@EMP_NAME   = 'something', 
@DEPARTMENT_ID = 's23', 
@DEPARTMENT_NAME = 'abc', 
@EMP_SALARY  = 10987 
+0

這對於培訓者來說更容易理解 – 2012-03-13 10:44:50