SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Constraint syntax error?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Megidolaon
Starting Member

2 Posts

Posted - 11/01/2010 :  17:57:43  Show Profile  Reply with Quote
I'm trying to add a foreign key column to an existing table and I get a syntax error.
To me it looks like the syntax is exactly the same as in the msdn example, can you tell me what the problem is?

ALTER TABLE t_invoice 
ADD customer_id integer 
CONSTRAINT FK_customer_id FOREIGN KEY (customer_id) 
REFERENCES t_customer (customer_id)


Thanks!

Sachin.Nand
Flowing Fount of Yak Knowledge

2937 Posts

Posted - 11/02/2010 :  01:01:28  Show Profile  Reply with Quote
What is the error?Can you post it?

I dont get any syntax errors with the below sample test query.



create table a(id int primary key)
create table b(id1 int)

ALTER TABLE b 
ADD idtest integer 
CONSTRAINT FK_test_id FOREIGN KEY (id1) 
REFERENCES a (id)

select * from a
select * from b


drop table b
drop table a



PBUH

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000