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.
Author |
Topic |
bbxrider
Starting Member
37 Posts |
Posted - 2011-08-08 : 15:11:12
|
I'm making changes to an existing table, so far I used sql to generate a script to create a new table based on the existing table, but that did not include scripting to create an existing foreign key with restraint. I generated a script for the foreign key but it includes a hex looking id from the existing table, what do you put in the script in place of the that hex code? in the sample below the '__6FCE6818' id from the existing table foreign key needs to be replaced with something?it looks like a code generated by sql-server?USE [myDB]GOALTER TABLE [dbo].[myTable] WITH NOCHECK ADD CONSTRAINT [FK__myTable__6FCE6818] FOREIGN KEY([field01], [field02])REFERENCES [dbo].[myOtherTable] ([field01], [field02])GOALTER TABLE [dbo].[myTable] CHECK CONSTRAINT [FK__myTable__6FCE6818] |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
bbxrider
Starting Member
37 Posts |
Posted - 2011-08-08 : 17:30:44
|
thanks for the reply, I guess the original table provisioning was done with something other than the 2005 management express I'm using. when you say GUI, I'm guessing you meant the 'new foreign key' option when right clik the keys folder. When I invoked that the name of the FK that it generated was the table name and '1' rather than hex looking yucky style. It seemed odd that you wouldn't be able to pick a name of your choosing but now I see that with the GUI you don't have a choice, to pick a name use the script. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|
|