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
 Referencing tables

Author  Topic 

BStarbuck
Starting Member

4 Posts

Posted - 2009-04-07 : 07:59:12
First I would like to say thank you to everyone who will soon be unknowingly helping me out a lot. Cheers!

So I can't seem to figure out how to reference tables together. Just to make up a quick example:

Create table Awesome
(ID Numeric(5) Primary Key,
Name Varchar(10));

Create table Sweet
(Date varchar(8) Primary Key,
ID Numeric(5) Reference Awesome(ID));

Would this not be the correct syntax in 2008? It's been several months but I could have sworn that's what I used in Oracle. As it sits, I get a syntax error right at "Awesome" and Reference is not turning blue.

Thanks for the help. It's the little things that really boggle me.

BStarbuck
Starting Member

4 Posts

Posted - 2009-04-07 : 08:01:30
Also I tried doing a search but I don't know if I used the correct key words because nothing was showing up
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-07 : 08:21:18
[code]CREATE TABLE tblAwesome
(
ID INT PRIMARY KEY,
Name VARCHAR(10)
)

CREATE TABLE tblSweet
(
Date DATETIME PRIMARY KEY,
ID INT REFERENCES tblAwesome(ID)
)[/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

BStarbuck
Starting Member

4 Posts

Posted - 2009-04-07 : 08:48:24
hahahaha wow.....go me

Thanks a lot man!
Go to Top of Page
   

- Advertisement -