I'd like to convert an existing table into the 1st normal form (simplest normalization possible; see the example).
Do you happen to know what is the T-SQL is for this sort of problem? Many thanks!
Update
Tried the answer below, it worked perfectly. Here is the steps I used to test the answer:
- Start up Microsoft SQL Management Studio.
- Create the tables, with the data below.
- Make sure that the ID in "Customer" is set to "Primary Key", and "identity".
- Make sure that the ID in "Order" has no special settings (its a foreign key).
- Open up a database diagram, then create a 1:* relationship between the "Customer" and "Order" tables.
- Execute the script on the "Customer" table and the "Order" table, it will automatically normalize the data properly for you.
- This is very useful if you are starting from a flat .csv file that has just been imported, and you want to copy the information into a normalized form in the database.
задан Contango 13 February 2011 в 18:46
поделиться