Return identity as an output parameter.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm [quoted text, click to view] "Anbu" <t_anbazhagan2001@yahoo.co.in> wrote in message
news:1143608634.206122.169410@e56g2000cwe.googlegroups.com...
> Hi All,
>
> First my apologize for cross posting. It's already posted in
> sqlserver.programming. But I see this group would also help me.
>
> I'm creating an appplication with some stored procedures. The stored
> procedure needs to return the @@Identity of the table's new record. The
>
> function has no errors and compiles without any warnings. The function
> does work fine some times (returning value). But most of the calls are
> failing and the function does not return proper value.
>
>
> CREATE PROCEDURE CreateNewCourse
> @CourseName NVARCHAR(256),
> @Duration Int,
> @Contents NVarChar(500),
>
>
> AS
>
>
> DECLARE @Identity int
>
>
> INSERT into CourseMaster
> (
> CourseName,Contents,
> Duration
>
>
> )
> VALUES
> (
> @CourseName,
> @Contents,
> @Duration
> )
>
>
> SET @Identity = SCOPE_IDENTITY()
>
>
> return @Identity
>
>
> Any suggestions???
>
>
> TIA.
>