Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Incorrect Syntax for FOREIGN KEY

Author  Topic 

divyajoshi12
Starting Member

2 Posts

Posted - 2012-04-29 : 00:55:52
When executing the following query on MS-Sql Server-2005 i am not able to run this query successfully. Here's the code:

create table saving_deposit
(ac_no varchar(11)constraint FOREIGN KEY(ac_no) references account_master(ac_no)on delete cascade,
deposit_amt int,
deposit_date Date,
mode_of_deposit varchar(10),
cheque_no varchar(15),
draft_no varchar(15 ),
bank_name varchar(20),
status_update varchar(15),
remarks varchar(10));

And ERROR IS :


Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'FOREIGN'.


Anyonw please correct it.
Thanks in advance.

:)

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2012-04-29 : 01:22:03
[code]
use below code ..There was syntax issue in ur code..
create table saving_deposit
(ac_no varchar(11)constraint fk references account_master(ac_no)on delete cascade,
deposit_amt int,
deposit_date Date,
mode_of_deposit varchar(10),
cheque_no varchar(15),
draft_no varchar(15 ),
bank_name varchar(20),
status_update varchar(15),
remarks varchar(10));[/code]
Go to Top of Page
   

- Advertisement -