Results 1 to 2 of 2

Thread: Script Primary Key Problem

  1. #1

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Question Script Primary Key Problem

    Hi all
    I am making my database script using script wizard of microsoft sql server 2005.
    I set option Script Primary Key=flase

    Now I run this script on my main server and then export data. Problem is this that how I can set again primary key on sever databse.


    If I set option Script Primary Key=true then my primary key data start from 1,2,3... and data export will not work correctly.

    Hope you people got my problem exactly.

    Suppose I have data in table
    ID Name
    11 Shakti
    12 Rahul


    if Script Primary Key=true then after exporting data will change into
    ID Name
    1 Shakti
    2 Rahul


    if Script Primary Key=false then data will transfer correctly bu how I can set primary key again on ID

    I have 257 tables in my database

    Thanks

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Script Primary Key Problem

    Can you just create the primary key code, and execute it?
    Code:
    ALTER TABLE [IdName] ADD  CONSTRAINT [PK_IdName] PRIMARY KEY CLUSTERED 
    (
    	[ID] ASC
    ) ON [PRIMARY]

Posting Permissions

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



Click Here to Expand Forum to Full Width