views:

45

answers:

3

I have SQL Server Express 2008. How can I set a table's relations in it?

+1  A: 

You need to install SQL Server Management Studio or run the SQL to create the FKs yourself.

Nate Bross
I have to install SQL Server Management Studio 2008 ? or I can install 2005 version ?
Mohammad
What ever version of DB server you have, your SSMS should match
Nate Bross
Actually, SSMS 2008 works fine with previous versions (back to 2000 at least).
tdammers
Thats true, but it doesn't work inversly. SSMS 2005 will not work for SQL Server 2008 for example.
Nate Bross
+3  A: 

You could run the ALTER TABLE statements necessary to add the foreign key relationships between tables either via:

OMG Ponies
Your link is for SQLServer2005 !!!
Mohammad
@Mohammad: Updated
OMG Ponies
+5  A: 

Just like with any other database:

ALTER TABLE [tablename] 
ADD CONSTRAINT [foreign_key_name] 
FOREIGN KEY [local_column] 
REFERENCES [foreign_table] ([foreign_column]) 
ON UPDATE RESTRICT 
ON DELETE RESTRICT;

SQL Server Management Studio gives you a graphical UI to do the same thing through a click-and-point interface, but internally, it executes queries like these.

tdammers
Can't I do it with Visual Studio, without just SQL Command!
Mohammad