开发者

Help with understanding SQL stored procedure parameters

I'm new to SQL and am now working with stored procedures. I was watching another developer's code and I saw this statement:

ALTER PROCEDURE [deleteRecords_UNICODE]
@RecordIDs ty_NumberList READONLY

Question 1: What does the "ty_NumberList" mean?

Question 2: I'm creatin开发者_JS百科g a stored procedure that needs to use the above parameter. When I created "DECLARE @RecordNum int", I obviously got the error of

Operand type clash: int is incompatible with ty_NumberList

I'm guessing I have to resolve this by:

a) Creating a variable of type "ty_NumberList"

b) then go with my usual DECLARE @RecordNum int

c) Then pass the value of @RecordNum into ty_NumberList

Question 3: How would I go about implementing the above steps in SQL?

Any help would be greatly appreciated!


ty_NumberList is the type of a table valued parameter.

You would use it like

DECLARE @Nums AS ty_NumberList;

INSERT INTO @Nums VALUES (1);

EXEC YourProc @Nums;


That code is using Table-Valued Parameters, read up on it in Books On Line: http://msdn.microsoft.com/en-us/library/bb510489.aspx


Read this

ty_number means you have to tell us because its a user defined data type

while declaring the stored procedure parameter

we no need to use declare

create proc sample @name vanchar(20), @num varchar(20) Begin

Select ........ .......

End

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜