Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Sql Server Programming

Whats wrong with this statement?


DECLARE @TempPersonID uniqueidentifier

-- Insert statements for procedure here

INSERT INTO People
(FirstName,LastName,MiddleInitial,Prefix,Suffix,Birthdate,Gender,SSN,Websit eURL,Email1,Email2,EMail3)
OUTPUT INSERTED.PersonID INTO @TempPersonID VALUES
(@FirstName,@LastName,@MiddleInitial,@Prefix,@Suffix,@Birthdate,@Gender,@SS N,@WebsiteURL,@Email1,@EMail2,@EMail3)

I just want to get the unique identifier back (sql 2005) its a
newsquentialid() default value being created... I want to push its value
back to a parameter after creation of the record... when I do this one and
try to save it into a sproc it says

Msg 1087, Level 15, State 2, Procedure PEOPLE_CreatePerson, Line 30

Must declare the table variable "@TempPersonID".

thanks!

Hello, Smokey

Try something like this:

DECLARE @TempPersonID uniqueidentifier
DECLARE @Temp TABLE (PersonID uniqueidentifier)

INSERT INTO People
(FirstName,LastName,MiddleInitial,Prefix,Suffix,Birthdate,Gender,SSN,Websit eURL,Email1,Email2,EMail3)
OUTPUT INSERTED.PersonID INTO @Temp VALUES
(@FirstName,@LastName,@MiddleInitial,@Prefix,@Suffix,@Birthdate,@Gender,@SS N,@WebsiteURL,@Email1,@EMail2,@EMail3)

SELECT @TempPersonID=PersonID FROM @Temp

Razvan

-----------------------------------------------Reply-----------------------------------------------

Try:

DECLARE @TempPersonID table
(
    ID    uniqueidentifier    primary key
)

-- yada

INSERT INTO People
(FirstName,LastName,MiddleInitial,Prefix,Suffix,Birthdate,Gender,SSN,Websit eURL,Email1,Email2,EMail3)
OUTPUT INSERTED.PersonID INTO @TempPersonID

--
   Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON   Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau

"Smokey Grindle" <nos@nospam.com> wrote in message

news:O$kR9EEqHHA.3660@TK2MSFTNGP04.phx.gbl...
DECLARE @TempPersonID uniqueidentifier

-- Insert statements for procedure here

INSERT INTO People
(FirstName,LastName,MiddleInitial,Prefix,Suffix,Birthdate,Gender,SSN,Websit eURL,Email1,Email2,EMail3)
OUTPUT INSERTED.PersonID INTO @TempPersonID VALUES
(@FirstName,@LastName,@MiddleInitial,@Prefix,@Suffix,@Birthdate,@Gender,@SS N,@WebsiteURL,@Email1,@EMail2,@EMail3)

I just want to get the unique identifier back (sql 2005) its a
newsquentialid() default value being created... I want to push its value
back to a parameter after creation of the record... when I do this one and
try to save it into a sproc it says

Msg 1087, Level 15, State 2, Procedure PEOPLE_CreatePerson, Line 30

Must declare the table variable "@TempPersonID".

thanks!

-----------------------------------------------Reply-----------------------------------------------

that would do it, thanks.

"Razvan Socol" <rso@gmail.com> wrote in message

news:1181138245.394190.292790@q69g2000hsb.googlegroups.com...

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc