Answer the question
In order to leave comments, you need to log in
How to transfer to procedure parameter result of request which in procedure?
Good day!
I have a procedure that adds "Organization"...
CREATE PROCEDURE AddOrganization
@NameOrg NVARCHAR(50),
@StatusId INT,
@Email NVARCHAR(50) = NULL,
@PhonesNumbers nvarchar(12) = NULL,
@IdOrganizations INT = null
AS
INSERT INTO Organizations([Name], StatusId)
VALUES(@NameOrg, @StatusId)
WITH res AS
(
SELECT TOP (1) Id
FROM Organizations
ORDER BY Id DESC
)
SELECT * FROM res
Answer the question
In order to leave comments, you need to log in
CREATE PROCEDURE AddOrganization
@NameOrg NVARCHAR(50),
@StatusId INT,
@Email NVARCHAR(50) = NULL,
@PhonesNumbers nvarchar(12) = NULL,
@IdOrganizations INT = NULL OUTPUT
AS
INSERT INTO Organizations ( [Name], StatusId ) VALUES ( @NameOrg, @StatusId )
SELECT @IdOrganizations = MAX( ID ) FROM Organizations -- Это вместо TOP(1)
SET @IdOrganizations = IDENT_CURRENT ('Organizations') -- Это если Organizations.ID у вас IDENTITY
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question