home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,282 of 19,505   
   Henk van den Berg to Henk van den Berg   
   Re: How can I check out the reason a db    
   28 Apr 11 20:28:29   
   
   From: hvandenberg@xs4all.nl   
      
   Remember: create index scripts and all the other relevant stuff (PK, FK)   
   is not addressed in this example.   
   Also make sure that you execute your INSERT INTO scripts in the correct   
   order.   
   Foreign key data in tableX can't be inserted if tableY with the matching   
   primary key hasn't been filled yet!   
      
   Best,   
   Henk   
      
   On 28-04-2011 20:14, Henk van den Berg wrote:   
      
   > On 28-04-2011 17:44, mat wrote:   
   >> I don't think there is a way using tools included with SSMS to export an   
   >> entire db (minus log) to a script and then recreate by executing the   
   >> script? Do you have any recommondation for such a utility? The data file   
   >> is about 500mb.   
   >   
   > -- Yeah there is.   
   >   
   > -- First thing to do: generate the CREATE TABLE script from SSMS   
   > -- Generate a INSERT INTO script for the data   
   >   
   > -- Here' a very simple example that you can adapt to your situation:   
   > -- Let's say you have on your production box Table1   
   >   
   > create table Table1 (f1 char(20), f2 int)   
   >   
   > insert into Table1 ( f1, f2) values ('v1', 12)   
   > insert into Table1 (f1, f2) values ('v2', 13)   
   >   
   > -- Create Table2 on your production box:   
   > create table Table2 (f1 char(20), f2 int)   
   >   
   > -- Generate the "insert into" script for Table2 based on the data of Table1   
   >   
   > -- Make sure that you have output to text by hitting ctrl-t   
   >   
   > SELECT ' insert into Table2 (f1, f2) values( ''' + ltrim(rtrim(f1)) +   
   > ''',' + ltrim(rtrim(cast( f2 as char(30))) ) + ')' from Table1   
   >   
   > -- Now you can select the generated output and copy it to a query window   
   >   
   > -- One caveat: If you have big tables, you may want to use this trick   
   > with 1000 records at a time perhaps!   
   >   
   >   
   > -- Oh yeah, remember that this example uses two different tables on the   
   > same box! Copy the generated script to your dev box and replace "Table2"   
   > with "Table1" before executing.   
   >   
   > Hope this helps,   
   > Henk   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca