返回身份列表的过程

时间:2013-01-04 17:29:05

标签: c# sql-server-2008 tsql stored-procedures

  

可能重复:
  How can I retrieve the identities of rows that were inserted through insert…select?

我需要一个可以在插入

之后返回主键列表(自动生成)的过程
PROCEDURE [dbo].[Person_InsertCloud]
@TablePerson Catalog.Type_Person READONLY
AS
SET NOCOUNT ON
    INSERT INTO dbo.PersonaTestCLOUD
    (IdPerson, IdDocument,NroDocument,Name,LastName, SecondLastName,BrandName, 
     Birthdate, IdSex, IdState, IdTypePerson, IdUbicationGeographic, NumberPhoneDefault,
     IdDirectory,IdPhoto)
    SELECT t.Id,t.IdDocument,t.NroDocument,t.Name,t.LastName,t.SecondLastName,t.BrandName,
        t.BirthDate,t.IdSex,t.IdState, t.IdTypePerson,t.IdUbicationGeographic,t.NumberPhoneDefault,
        t.IdDirectory, t.IdPhoto
    FROM @TablePerson t
    WHERE t.IdServer = -1;

这可能吗?我在一个只返回一个id的过程之前使用过。

由于

0 个答案:

没有答案