0

I'm trying to create a table programmatically via VB.Net and two of the columns should have a primary key. I have the following T-SQL code and I basically need to translate it to SQL so I can execute it programmatically via vb.net :

CREATE TABLE [dbo].[Orders] 
(
    [OrderID] INT IDENTITY (1, 1) NOT NULL,
    [FoodID]  INT NOT NULL,
    [PriceID] INT NOT NULL,

    PRIMARY KEY CLUSTERED ([OrderID] ASC),
    CONSTRAINT [FK_Orders_Customer] 
       FOREIGN KEY ([FoodID]) REFERENCES [dbo].[Customer] ([FoodID])
)

This is what I currently have for my vb.net sql code:

 CREATE TABLE customer(OrderID INT NOT NULL,FoodID INT NOT NULL ,PriceID INT NOT NULL

Now I'm not sure how to declare the primary key and how to declare the foreign keys. Also if someone would show an example on how to declare a composite key I would also be grateful (ie. OrderID and FoodID both primary keys). Thank you.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Quattro
  • 19
  • 3

0 Answers0