我希望能够做这样的事情:我的存储过程将始终返回一个数字(tinyint)
INSERT INTO CustomerSelections
([draw_date]
,[val1]
,[val2]
,[val3]
,[val4]
,[val5]
,[val6])
VALUES
(
'2013-07-05'
,EXEC GenerateRandomNumbers 1, 49, 1, 0
,EXEC GenerateRandomNumbers 1, 49, 1, 0
,EXEC GenerateRandomNumbers 1, 49, 1, 0
,EXEC GenerateRandomNumbers 1, 49, 1, 0
,EXEC GenerateRandomNumbers 1, 49, 1, 0
,EXEC GenerateRandomNumbers 1, 49, 1, 0
)
但我不知道如何在那里获得价值?
更新: 我尝试过这样的事情:
我将传递的值放入一个名为的存储过程中:
ALTER PROCEDURE [dbo].[GetUniqueLottoNumber]
AS
BEGIN
DECLARE @return_value int
EXEC @return_value = [dbo].[GenerateRandomNumbers]
@StartNumber = 1,
@EndNumber = 49,
@QuantityToOutput = 1,
@AllowDuplicates = 0
END
然后这样做:
CREATE TABLE #tmp (Number TINYINT)
DECLARE @q nvarchar(4000)
DECLARE @return_value int
SET @q = 'EXEC @return_value = [dbo].[GetUniqueLottoNumber]';
INSERT INTO #tmp (Number)
EXEC sp_executesql @q
但是当我将@q 放入插入值时它不喜欢它。