View Single Post
  #1 (permalink)  
Old December 31st, 2013, 01:39 AM
Saif Ali Saif Ali is offline
Registered User
 
Join Date: Dec 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default primary n foreign key

I have 2 tables job order n estimate.............. job order is a primary key in its table

n estimate table include job order but in estimate table estimate order is the primary key so how estimate table job order can auto generate same as in job order table


CREATE TABLE [dbo].[Job_Order](
[JobNumber] [varchar](30) NOT NULL,
[Department] [nchar](30) NULL,
[Budget] [money] NOT NULL,
[Description] [nchar](200) NULL,
[FilledBy] [nchar](30) NOT NULL,
[Date] [date] NOT NULL,
CONSTRAINT [PK_Job_Order] PRIMARY KEY CLUSTERED
(
[JobNumber] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO


CREATE TABLE [dbo].[Estimate](
[JobNumber] [varchar](30) NOT NULL,
[EstimateNumber] [varchar](30) NOT NULL,
[Description] [varchar](200) NOT NULL,
[Amount] [money] NOT NULL,
[AmountInWords] [varchar](100) NOT NULL,
[date] [date] NOT NULL,
CONSTRAINT [PK_Estimate] PRIMARY KEY CLUSTERED
(
[EstimateNumber] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO