我有3个变量:@testid
,@sampleid
和@clientid
。
如何通过执行此查询一次设置@sampleid
和@clientid
?
SELECT
[sample].sampleid,
[client].clientid
FROM
dbo.[test]
LEFT OUTER JOIN dbo.[sampleslice] ON dbo.[test].samplesliceid = dbo.[sampleslice].samplesliceid
LEFT OUTER JOIN dbo.[sample] ON dbo.[sampleslice].sampleid = dbo.[sample].sampleid
LEFT OUTER JOIN dbo.[client] ON dbo.[sample].clientid = dbo.[client].clientid
WHERE
testid = @testid
答案 0 :(得分:23)
DECLARE @sampleid YOUR_VAR_TYPE;
DECLARE @clientid YOUR_VAR_TYPE;
SELECT
@sampleid = [sample].sampleid,
@clientid = [client].clientid
FROM dbo.[test]
-- The variables are now initialized. You can now use them below.above