Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Script to Insert data
Message
 
 
À
12/11/2004 09:05:41
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
00960451
Message ID:
01409553
Vues:
69
Take a look at http://www.sqlservercentral.com/articles/T-SQL/66987/

It's an interesting approach, that's why I'm sharing in the old thread of yours.

>Thank you.
>
>So if I want to preserve my test data in table Table1 before I restore from a backup in which Table1 will be empty, I can create a database to hold the backup tables, create a table1 in database2 and fill it with test data copied from database1 as shown below ( assume I just prefix the tablename with the database name database1!table1 ?) And then after restoring backup for database1, reverse the process filling table in database1 from database2. Is that the best approach?
>
>Now, suppose I want to send my test data to a collegue? Would I just backup my database2 and send him that or is there a better way?
>
>( If I wanted to send a collegue a totally new table structure, or a change in structure, I would just create a script that Enterprise manager would generate for me. I guess I was hoping for a similar way to create a script with insert into statements based on existing data which I would send to someone else and they could run from QA and fill their table with this data. In VFP I would create a delimited file they could append from, but I'm still floundering on figuring out the SQLServer equivalent. )
>
>Appreciate your insights on this as you are fluent in both languages ( and, I suspect, many others <g> )
>
>TIA
>
>>You can use INSERT INTO SELECT FROM command
INSERT INTO table2 SELECT * FROM table1
>>
>>>Thought I would point this directly at you since you will probably be the one to answer <s>
>>>
>>>I understand how to create a script to create a table. But how would I create a script to have insert commands to populate a table with data existing in a current table.
>>>
>>>I am working on a project with other developers. I periodically have to restore a backup of the common database we are using, but I have sometimes dummied up test data in one of the tables in my local installation. I would like to create a sql script that does inserts of this data into the same table once it has been restored from backup ( where it is probably empty )
>>>
>>>Hope the question makes sense. I am sure there is some easy way to accomplish this, but short of writing out the script manually the solution is eluding me
>>>
>>>TIA
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform