Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004
    Posts
    28

    Unanswered: Identity column question

    Trying to create a custom dts package that imports data from excel spreadsheet to db. One of the issues is that the columns in the main entity tables are not identity columns. So how do you get the appropriate PK?

    Well I thought the following would work but it doesn't. Any ideas?

    Basically trying to use the variable as the starting point in the temp identity declaration. Is this a syntax error or a "no-no".

    declare @maxid int
    select @maxid = (select max(objectid)+1 from object)



    create table #service (
    ObjectId int identity (@maxid,1),
    ModifiedAt datetime,
    ModifiedBy int,
    ObjectTypeId int,
    [Name] nvarchar(100),
    ServiceType nvarchar(100),
    CategoryId int,
    IsVisible int)



    insert into #service (ModifiedAt,ModifiedBy,ObjectTypeId,[Name],ServiceType,IsVisible)
    select getdate(),1,1,service,ServiceType,1 from import

  2. #2
    Join Date
    Mar 2003
    Location
    Indiana, USA
    Posts
    100
    create table #service (
    ObjectId int identity (1,1),
    ModifiedAt datetime,
    ModifiedBy int,
    ObjectTypeId int,
    [Name] nvarchar(100),
    ServiceType nvarchar(100),
    CategoryId int,
    IsVisible int)

    DBCC CHECKIDENT (#service, RESEED, @maxid)

  3. #3
    Join Date
    Oct 2004
    Posts
    28
    thank-you very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •