【发布时间】:2011-06-15 01:09:55
【问题描述】:
我有一个返回对象所有字段的存储过程。
CREATE PROCEDURE getCustomer
(
@CustomerId int OUTPUT
)
AS
BEGIN
SELECT @CustomerId=CustomerId,FirstName,LastName FROM Customers
END
我希望能够将对象的 id 作为输出参数返回,以便另一个 sproc 可以使用它。我在这个例子中得到这个错误:
A SELECT statement that assigns a value to a variable must not be combined with
data-retrieval operations.
CREATE PROCEDURE getCustomer_and_more
AS
BEGIN
DECLARE @CustomerId int
EXEC getCustomer @CustomerId OUTPUT
-- call another sproc that requires this @CustomerId
END
【问题讨论】:
标签: sql sql-server tsql sql-server-2008 stored-procedures