简体   繁体   中英

Get variables of a stored procedure from a SELECT statement

I'd like to execute a stored procedure with variables that I'm getting from a select statement like its possible in insert, update and delete.

EXEC [dbo].[upsert_release_artist_role_sp] 
@release_guid = @release_guid,
@artist_id = @artist_id OUTPUT,
@external_role_id = @external_role_id
(
    SELECT @release_guid, artist_id, @external_role_id 
    FROM  @artist_ids
)

In the code, artist_id is defined in a table variable and I need a way to retrieve it. Any idea what's the best way to tackle this?

Was solved by using https://chat.openai.com/ :D Solved this by

DECLARE @artist_id INT
SELECT @artist_id = artist_id FROM @artist_ids


EXEC [dbo].[upsert_release_artist_role_sp] 
@release_guid, @artist_id, @external_role_id

-- This has been verified in my code and works well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM