|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Create Relationship between Tables
Hello,
How do I create a script that have a relationship between two tables from the two tables I successfully created below. Dim addTable1 As String = "CREATE TABLE t1(idT1 int IDENTITY(1,1) PRIMARY KEY, tField1 nvarchar(50))" Dim addTable2 As String = "CREATE TABLE t2(idT2 int IDENTITY(1,1) PRIMARY KEY, tField2 nvarchar(50), idT1 int)" A relationship between idT1 in t1 table and idT1 in t2 table. cheers, asptips |
|
#2
|
||||
|
||||
|
Have a look at this example: http://msdn2.microsoft.com/en-us/li...za0(VS.80).aspx
__________________
jmurrayhead Did I help you out? Make me popular by clicking the icon!New Members:Proper way to post a question Powered by ASP.Net |
|
#3
|
|||
|
|||
|
Quote:
What if the table already exist? I receive this error "Incorrect syntax near '('." Dim addTable1 As String = "CREATE TABLE t1(idT1 int IDENTITY(1,1) PRIMARY KEY, tField1 nvarchar(50))" Dim addTable2 As String = "CREATE TABLE t2(idT2 int IDENTITY(1,1) PRIMARY KEY, tField2 nvarchar(50), idT1 int)" Dim relateTable As String = "ALTER TABLE t2(FOREIGN KEY idT1 TAG idT1 REFERENCES t1)" Is my syntax correct? cheers, asptips |
|
#4
|
||||
|
||||
|
Here's an example:
Code:
ALTER TABLE ORDERS ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID); |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Create Relationship between Tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|