dbo.Genera_ID_Informe

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.Genera_ID_Informe 
 -- Add the parameters for the stored procedure here
 /*
  @informe INT OUTPUT
  */

AS
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;

    -- Insert statements for procedure here

 DECLARE @nkey int

 SET @nkey = 0
 WHILE @nkey = 0 BEGIN
  SET @nkey = convert(int,rand()*10000000)
  IF EXISTS (SELECT informe FROM informes
     WHERE informe = @nkey) BEGIN
   SET @nkey = 0
  END
 END
 /*
  select @nkey as nkey
  */

 return @nkey

 /* SET @informe = @nkey*/
END

GO

Depends On

1