I have 3 variables: @testid
, @sampleid
and @clientid
.
How can I set @sampleid
and @clientid
by executing this query once?
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
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
精彩评论