all groups > visual c libraries > november 2003 >
You're in the

visual c libraries

group:

HOWTO create a copy of one database



Re: HOWTO create a copy of one database oj
11/9/2003 11:39:55 PM
visual c libraries: Yes. Create a script and deploy it.

--
-oj
RAC v2.2 & QALite!
http://www.rac4sql.net



[quoted text, click to view]

HOWTO create a copy of one database Lars Grøtteland
11/10/2003 8:31:25 AM
Hello!

Was wondering how I can create a copy of one database? FYI I'm not
interrested in the data, just the fields and triggers, and so on.

Which way is the easiest? Do I create a script and run it from there? Is it
smart to have it inside a SP?

Any idea would be greatly appreciated.

I'm programming SQL 2k and VC7.0

--


- Lars


Re: HOWTO create a copy of one database Lars Grøtteland
11/10/2003 9:02:07 AM
Yes I know I can do this in QA, but how to do it in my application?

Was thinking of making a SP, inside the model database. I think I've read of
this database once - that if I create one SP inside this, this should be
copied to the new database that's been created. Is this a solution?

--


- Lars


[quoted text, click to view]

Re: HOWTO create a copy of one database Uri Dimant
11/10/2003 9:36:57 AM
Lars
Right click on the database then All tasks then Generate SQL Script.
Save it as .sql (or whatever) file and you can run it from QA or later if
you need from the file.





[quoted text, click to view]

Re: HOWTO create a copy of one database Jacco Schalkwijk
11/10/2003 9:37:09 AM
If you want to do it from inside you application, use SQL-DMO. You can copy
the complete database without using a script with the Database.Transfer
method, or you can generate a script with the Database.Script method. Both
method have a rather long list of parameters, which is a bit too much to
mention here, but whihc you can find in Books Online. The parameters
basically allow you all the options you have when copying a database or
generating a script from Enterprise Manager.

--
Jacco Schalkwijk
SQL Server MVP


[quoted text, click to view]

Re: HOWTO create a copy of one database Tibor Karaszi
11/10/2003 10:20:33 AM
Yes, stuff from model are copied to a new database. But this seems to be a
real awkward way of doing it. Just generate the scrip and have your
application loop the script file and for each "GO" it encounters in the file
is executes what you have built in the buffer so far.

--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver


[quoted text, click to view]

Re: HOWTO create a copy of one database Lars Grøtteland
11/10/2003 11:09:05 AM
Then I have another trick for you!

I have "GOTO" inside the script. What should I do then?

--


- Lars


"Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@cornerstone.se>
[quoted text, click to view]

Re: HOWTO create a copy of one database Tibor Karaszi
11/10/2003 11:41:25 AM
No problem. Just check that the first character after GO (i.e., the third
character as GO must be first two characters on the line) is either blank,
tab or CR or NL (new line).

--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver


[quoted text, click to view]

Re: HOWTO create a copy of one database Jacco Schalkwijk
11/10/2003 11:52:26 AM
In the Books Online index:
objects-SQL-DMO, Database
methods-SQL-DMO, Transfer
objects-SQL-DMO, Transfer
objects-SQL-DMO, Transfer2

I couldn't find any examples in C++, but here is one in VB:
http://sqldev.net/download/sqldmo/80/vb6/TransferEvent.cls.txt

--
Jacco Schalkwijk
SQL Server MVP


[quoted text, click to view]

Re: HOWTO create a copy of one database Lars Grøtteland
11/10/2003 12:27:43 PM
What's the syntax - or where can I find it in SQL-DMO bol


--


- Lars


[quoted text, click to view]

Re: HOWTO create a copy of one database Lars Grøtteland
11/10/2003 1:12:32 PM
THanks!



--


- Lars


[quoted text, click to view]

AddThis Social Bookmark Button