2009-07-29 29 views

回答

3

不能使用表參數類型,直到SQL Server 2008的

一種選擇是使用XML表格中和XPath通過解析它。

0

我試過了,但是沒有,@gbn是正確的,你不能在SQL Server 2005

這裏是我的嘗試:

CREATE FUNCTION dbo.TestTable 
(
    @InputTable table (RowID int, DataValue varchar(10)) 
) 
RETURNS 
table (RowID int, DataValue varchar(10)) 
AS 
    SELECT * FROM @InputTable ORDER BY 1 DESC 
RETURN 
go 

DECLARE @t table (RowID int, DataValue varchar(10)) 

INSERT INTO @t VALUES (3,'cccc') 
INSERT INTO @t VALUES (2,'bbbb') 
INSERT INTO @t VALUES (1,'aaaa') 

select * from @t 
select * from dbo.TestTable(@t) 

這裏的錯誤:

Msg 156, Level 15, State 1, Procedure TestTable, Line 3 
Incorrect syntax near the keyword 'table'. 
Msg 1087, Level 15, State 2, Procedure TestTable, Line 8 
Must declare the table variable "@InputTable". 
Msg 1087, Level 15, State 2, Line 1 
相關問題