Andrew Scott wrote:
> 
> I have the following script, that I created to copy and create a table. I
> want to modify the created index field and create a new primary key field.
> 
> Can someone point me in the right direction here.
> 
> drop table [dbo].[MealsMapping]
> GO
> 
> SELECT                ME_ID, ME_Operator
> INTO          MealsMapping
> FROM          Meals
> where         ME_Operator is not null
> go
> 
> ALTER TABLE [dbo].[MealsMapping] add
>  [MealsMappingId] [int] NOT NULL IDENTITY(1, 1)
> go

BEGIN;
CREATE TABLE MealsMapping (
  MealsMappingId IDENTITY(1, 1),
  ME_ID INTEGER NOT NULL,
  ME_Operator VARCHAR NOT NULL,
  CONSTRAINT MealsMapping_PK PRIMARY KEY (MealsMappingId)
);
INSERT INTO MealsMapping (ME_ID, ME_Operator)
SELECT ME_ID, ME_Operator
FROM Meals
WHERE ME_Operator IS NOT NULL;
COMMIT;

Jochem


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: http://www.houseoffusion.com/groups/SQL/message.cfm/messageid:2638
Subscription: http://www.houseoffusion.com/groups/SQL/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.6

Reply via email to