May 4, 2008 at 6:41 pm
I am using SQL Server Mgmt Studio Express 2005 and I have the following tables
tbl_Styles with columns
StyleID
tbl_Material with columns
MaterialID
StyleID
This is an existing database that someone gave to me.
tbl_Styles was already there, tbl_Material is new, I just added it.
I want to do the following:
1. set tbl_Material.StyleID to be a foreign key so I can use it to link the two tables. I want to query tbl_Styles and tbl_Material to find the materials that each style contains.
2. I want to set tbl_Material.MaterialID to be the primary key for that table.
3. I want to check to see if tbl_Styles.StyleID is the primary key for that table.
How do I do this graphically?
thanks
May 5, 2008 at 11:13 am
Using SSMS
Expand the database which contains the 2 tables
Right click on the table name
In the drop down menu left click on "Design"
In the resulting pane click row with "StyleId" as the column name
On the "Table Design" menu bar click on the key icon
Close the design window and if asked click on "Yes" to save
Repeat above for the next table.
Still using SSMS left click on the database name
Right click on "Database diagrams" - if you recieve a message about some items not being loaded, click on load you may have to go back and click on "Database diagrams" after the load completes.
Select "New database diagram"
In the pop up window select the tbl_Material and tbl_Styles
Drag and drop the primary key from one table to the other
This should do it for you
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply