PDA

Click to See Complete Forum and Search --> : SQL CREATE TABLE


Geoff Gunson
Oct 10th, 1999, 09:46 PM
Hi

I have the code to create a table dynamically but I need to know how to link a feild in one table to another table. I think I need to use the REFERENCES part but I have no idea how it works.

Also does any body know of a good reference manual / book for SQL (so I don't bother U lot as much! :) )


Cheers Guys and Gals

Geoff ;)

------------------

Ludmila
Oct 11th, 1999, 04:22 AM
You can do it like this:
Dim NewRelation As Relation
Set NewRelation = db.CreateRelation("ReferralContactsTransactions", _
"ReferralContacts", "Transactions", dbRelationDontEnforce)
NewRelation.Fields.Append NewRelation.CreateField("RefContactID")
NewRelation.Fields("RefContactID").ForeignName = "RefContactID"
db.Relations.Append NewRelation

Jamppa
Oct 11th, 1999, 02:57 PM
Hi Geoff

You should determine references while creating a table.

CREATE TABLE "dbo"."TableX" (
"Id" "int" IDENTITY (1, 1) NOT NULL ,
"StringValue" varchar (20) NOT NULL ,
) REFERENCES "dbo"."Join" (
"Join_Id"
)
)
GO

Clunietp
Oct 13th, 1999, 12:12 PM
I have this document beside my desk:
http://w3.one.net/~jhoffman/sqltut.htm