We help IT Professionals succeed at work.

SELECT @newLinkId = Link_Id FROM inserted what to use for "inserted"?

276 Views
Last Modified: 2010-03-19
hello experts,

the line "SELECT @newLinkId = Link_Id FROM inserted" is wrong.
Please tell me what to use instead of inserted.
Thanks a lot!

CREATE PROCEDURE [dbo].[Linksummary_CreateNewLink]

  @Linkname nvarchar(50),
  @Linkdescr nvarchar(100),
  @Linkurl nvarchar(500),
  @CategoryId int

AS
INSERT Link
      (
            Link_Name,
            Link_Descr,
            Link_Url
      )
      VALUES
      (
            @Linkname,
            @Linkdescr,
            @Linkurl
      )

      DECLARE @newLinkId int
      SELECT @newLinkId = Link_Id FROM inserted

      INSERT Category_Link
      (
            Category_Id,
            Link_Id
      )
      VALUES
      (
            @CategoryId,
            @newLinkId

      )
RETURN @@IDENTITY
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2010
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
No i'm not allowed :-) but I didn't know better... so I just wort it like that to explain my problem better...
Thanks! @@identity worked... too easy to imagine..
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.