By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,691 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,691 IT Pros & Developers. It's quick & easy.

HOWTO create a copy of one database

P: n/a
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

Nov 16 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
oj
Yes. Create a script and deploy it.

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

"Lars Grøtteland" <lars@nospam> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Nov 16 '05 #2

P: n/a
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.

"Lars Grøtteland" <lars@nospam> wrote in message
news:#B**************@TK2MSFTNGP11.phx.gbl...
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

Nov 16 '05 #3

P: n/a
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
"oj" <no**********@home.com> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
Yes. Create a script and deploy it.

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

"Lars Grøtteland" <lars@nospam> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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


Nov 16 '05 #4

P: n/a
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=d...blic.sqlserver
"Lars Grøtteland" <lars@nospam> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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
"oj" <no**********@home.com> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
Yes. Create a script and deploy it.

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

"Lars Grøtteland" <lars@nospam> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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



Nov 16 '05 #5

P: n/a
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
"Lars Grøtteland" <lars@nospam> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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
"oj" <no**********@home.com> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
Yes. Create a script and deploy it.

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

"Lars Grøtteland" <lars@nospam> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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



Nov 16 '05 #6

P: n/a
Then I have another trick for you!

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

--
- Lars
"Tibor Karaszi" <ti****************************************@corner stone.se>
wrote in message news:OM**************@TK2MSFTNGP10.phx.gbl...
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=d...blic.sqlserver

"Lars Grøtteland" <lars@nospam> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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
"oj" <no**********@home.com> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
Yes. Create a script and deploy it.

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

"Lars Grøtteland" <lars@nospam> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
> 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
>
>
>



Nov 16 '05 #7

P: n/a
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=d...blic.sqlserver
"Lars Grøtteland" <lars@nospam> wrote in message
news:uy**************@tk2msftngp13.phx.gbl...
Then I have another trick for you!

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

--
- Lars
"Tibor Karaszi" <ti****************************************@corner stone.se> wrote in message news:OM**************@TK2MSFTNGP10.phx.gbl...
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=d...blic.sqlserver


"Lars Grøtteland" <lars@nospam> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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
"oj" <no**********@home.com> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
> Yes. Create a script and deploy it.
>
> --
> -oj
> RAC v2.2 & QALite!
> http://www.rac4sql.net
>
>
>
> "Lars Grøtteland" <lars@nospam> wrote in message
> news:%2****************@TK2MSFTNGP11.phx.gbl...
> > 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
> >
> >
> >
>
>



Nov 16 '05 #8

P: n/a
What's the syntax - or where can I find it in SQL-DMO bol
--
- Lars
"Jacco Schalkwijk" <NO**********@eurostop.co.uk> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
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
"Lars Grøtteland" <lars@nospam> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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
"oj" <no**********@home.com> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
Yes. Create a script and deploy it.

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

"Lars Grøtteland" <lars@nospam> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
> 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
>
>
>



Nov 16 '05 #9

P: n/a
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...rEvent.cls.txt

--
Jacco Schalkwijk
SQL Server MVP
"Lars Grøtteland" <lars@nospam> wrote in message
news:uR*************@TK2MSFTNGP10.phx.gbl...
What's the syntax - or where can I find it in SQL-DMO bol
--
- Lars
"Jacco Schalkwijk" <NO**********@eurostop.co.uk> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
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
"Lars Grøtteland" <lars@nospam> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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
"oj" <no**********@home.com> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
> Yes. Create a script and deploy it.
>
> --
> -oj
> RAC v2.2 & QALite!
> http://www.rac4sql.net
>
>
>
> "Lars Grøtteland" <lars@nospam> wrote in message
> news:%2****************@TK2MSFTNGP11.phx.gbl...
> > 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
> >
> >
> >
>
>



Nov 16 '05 #10

P: n/a
THanks!

--
- Lars
"Jacco Schalkwijk" <NO**********@eurostop.co.uk> wrote in message
news:ub**************@TK2MSFTNGP09.phx.gbl...
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...rEvent.cls.txt

--
Jacco Schalkwijk
SQL Server MVP
"Lars Grøtteland" <lars@nospam> wrote in message
news:uR*************@TK2MSFTNGP10.phx.gbl...
What's the syntax - or where can I find it in SQL-DMO bol
--
- Lars
"Jacco Schalkwijk" <NO**********@eurostop.co.uk> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
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
"Lars Grøtteland" <lars@nospam> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
> 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
>
>
> "oj" <no**********@home.com> wrote in message
> news:uy**************@TK2MSFTNGP09.phx.gbl...
> > Yes. Create a script and deploy it.
> >
> > --
> > -oj
> > RAC v2.2 & QALite!
> > http://www.rac4sql.net
> >
> >
> >
> > "Lars Grøtteland" <lars@nospam> wrote in message
> > news:%2****************@TK2MSFTNGP11.phx.gbl...
> > > 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
> > >
> > >
> > >
> >
> >
>
>



Nov 16 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.