USP_SELECTIONHELPER_INSERTIDS
Will insert all IDs in the selection into a table with the given name.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@SELECTIONID | uniqueidentifier | IN | |
@TABLENAME | nvarchar(max) | IN |
Definition
Copy
create procedure dbo.USP_SELECTIONHELPER_INSERTIDS
@SELECTIONID uniqueidentifier, --ID of a SELECTION to build the "select id from..." for.
@TABLENAME nvarchar(max) --name of a table to insert into. Usually a local temp table such as "#idsetIDs".
as
/*
Will insert all IDs in the selection into a table with the given name.
Usually used with a local temp table declared outside this routine. The table must have a column named ID that matches the datatype of the ID for the selection.
*/
set nocount on;
declare @SQL nvarchar(max);
declare @r int;
exec @r= dbo.USP_SELECTIONHELPER_BUILDIDSELECTSQL @SELECTIONID,@SQL output;
if @r <> 0
BEGIN
--the sp raised an error generating the SQL.
RETURN @R;
END
set @SQL= N' insert into ' + @TABLENAME + N' ' + @SQL ;
exec (@SQL);
RETURN 0;