This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQL - SERVER Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL - SERVER" Watch "SQL - SERVER" New topic
Author

SQL - SERVER

sreedhar meda
Greenhorn

Joined: Dec 09, 2000
Posts: 7
HELLO,
my problem is i'm unable to create a child table with reference key to the composite key in the parent table in sql-server. how can i make
up a query to do the above.
give me an example queries.
with warm regards,
sreedhar m
E
Greenhorn

Joined: Dec 11, 2000
Posts: 6
Check SQL Server Books Online for this database specific question and examples. Specifically research the create table statement. Here is how to set up the foreign key (which is what you call a reference). Add this at the end of your column list:
CONSTRAINT FK_fkey_name FOREIGN KEY (person_id, ord_id, chicken_id)
REFERENCES barnyard (person_id, ord_id, chicken_id)

The first column list (after the foreign key) is the list of columns in the new table corresponding to the primary key columns in the 'parent' table. The references is of course, the parent table.
It should look something like this:
...
feed_type int,
farmer_name varchar(50),
CONSTRAINT ...
 
 
subject: SQL - SERVER
 
Similar Threads
updating records, for a table without primary key.
Entity Bean CMP 1.1 Primary Key [Binary]
DB2
Oracle Forign Key Basic .
creating backup tables