USP_SELECTIONHELPER_BUILDIDSELECTSQL

Will generate a SELECT ID FROM ... statement that when executed will return all IDs that are in the selection.

Parameters

Parameter Parameter Type Mode Description
@SELECTIONID uniqueidentifier IN
@IDSELECTSQL nvarchar(max) INOUT

Definition

Copy


CREATE procedure dbo.[USP_SELECTIONHELPER_BUILDIDSELECTSQL]
(
  @SELECTIONID uniqueidentifier,      --ID of a selection to build the "select ID from..." for

  @IDSELECTSQL nvarchar(max) output   --Will be the SQL statement in the form "select ID from ..."

)
as
  set nocount on;

  --Generate a "select ID from ..." statement that when executed will return all IDs that are in the selection...

  set @IDSELECTSQL = dbo.[UFN_SELECTIONHELPER_BUILDIDSELECTSQL](@SELECTIONID);
  if @IDSELECTSQL is null
    begin
      raiserror('Selection does not exist in the database.', 15, 1);
      return 70;
    end

  return 0;