sql server - Setting up a Foreign Key - transact SQL -


i'm experiencing issue following tsql in sql server 2014 when assigning foreign key. can me in understanding incorrect? - jt

    create table dbo.tbl_util_cost     (     chr_grade   nchar(10)    not null primary key,     pct_target  decimal(18, 2)  not null,     mon_cost_per_hour   money   not null,     dec_daily_hours decimal(18, 1)  not null     );      create table dbo.tbl_team_details    (      num_personal_number    numeric(18, 0)  not null,      chr_name   nchar(30)    not null,      chr_employee_grade nchar(10)    not null ,      dt_start_date date not null,      dt_end_date date   not null,      foreign key fk_team_details1  ( chr_employee_grade) references dbo.tbl_util_cost (chr_grade)        ); 

i getting following error on foreign key -

msg 102, level 15, state 1, line 11 incorrect syntax near 'fk_team_details1'

please advice!

your syntax wrong. here example of correct syntax:

constraint fk_team_details1 foreign key (chr_employee_grade) references dbo.tbl_util_cost (chr_grade)

for more: create foreign key relationships


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -