Showing posts with label programatically. Show all posts
Showing posts with label programatically. Show all posts

Saturday, February 25, 2012

Clone DB

Helloo

Can I backup DB programatically, and then restore it with different name also programatically?

meaning:
I have db2006, can I backup this db then restore it as db2007 programatically?using a stored procedure for example?

So by doing this the user will be using db2007 @. the begininng of the year and so on each year

I'm using sql2000

Please I need your help
Thank you

hi,

you can use sp_attach and sp_detach.

notice you can attach it with different db_name

Examples

EXEC sp_detach_db 'pubs', 'true'

copy the files and attach it with different dbname

EXEC sp_attach_db @.dbname = N'pubs1', 

@.filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf',

@.filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log.ldf'

|||

Thank you for your reply

but I had explained in a wrong way

I need to create a dublicate for this database programatically
meaning if i have db2004, I need to create db2005 programatically same as db2004(tables and procedures, only structure)

Is that possible?

thank you

|||

you can right click the database in the Enterprise manager or management studio

and clcik on task>generate scripts

|||

Look into the smo objects in books online. You could probably build a program to do this pretty easily to script out the database, create a clone database, and apply the script.

If this is a production database, if you have maintain scripts of the database, that is probably the best way to go, just by applying the scripts (but that takes a good amount of discipline on all developers, which can be hard to maintain depending on corporate culture)

Thursday, February 16, 2012

Client Network Utility

Guys,
Anybody knows how the client network utility can be configured PROGRAMATICALLY.
What I wanna do ultimately, is to run a batch file and set an alias for the client network utility.
Thanks,
Regards,Any possibilities thru OSQL? I haven't found anything yet.|||Double posting. :)|||I'm pretty sure that you can do it with a registry file... don't have SQL Server on my new laptop yet so I can't tell you what key, but it should be in HKEY_LOCAL_MACHINE somewhere

all you should have to do is set it up, do a search in the registry (using regedit) for the alias or whatever you added, export that key to a *.reg file, clean up the file a bit (to get rid of duplicate or extraneous keys) and import it on a test machine to check it out.

I use that method to add system ODBC data sources all the time, never done it with the Client Network Utility though... standard disclaimer however... if you mess up the registry it's your fault and don't forget to back it up before importing anything|||Hey thanx Drew. Interesting idea. I'll give it a try and let you know what happened.|||sure thing... I'll be in the office tomorrow and will post it up if I get to it before you, been meaning to do it for a long time to make client config as dummy proof as possible so I don't have to sit on the phone t-shooting stupid crap like that

Client Network Utility

Is it possible to create an alias under Client Network Utility
Programatically using SQL Server or MSDE
The problem I have is to install msde at a client and setup replication with
my main server.
I need the alais to inteprut the name into ip address for the replication to
work.
--
----
Robert Craill
Web Development
USP Designs (Pty) Ltd
E: robert@.cyberprop.com
T: +27 11 955 9100
F: +27 11 955 9110
W: www.cyberprop.com
W: www.cyberagent.co.za
W: www.cyberbonds.co.za
USP Designs (Pty) Ltd is Proudly South African!
This message and any attachments are confidential and intended solely for
the addressee. Any unauthorized use, alteration or dissemination is
prohibited. USP Designs (Pty) Ltd. accepts no liability whatsoever for any
loss, whether it be direct, indirect or consequential, arising from
information made available and actions resulting there from.The aliases are stored as registry keys under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo
Create them on a source machine, export the keys, and import/create them
during setup.
--
Geoff N. Hiten
Senior Database Administrator
Microsoft SQL Server MVP
"Robert Craill" <robert@.cyberprop.com> wrote in message
news:OMYk7P$zFHA.2652@.TK2MSFTNGP14.phx.gbl...
> Is it possible to create an alias under Client Network Utility
> Programatically using SQL Server or MSDE
> The problem I have is to install msde at a client and setup replication
> with my main server.
> I need the alais to inteprut the name into ip address for the replication
> to work.
>
> --
> ----
> Robert Craill
> Web Development
> USP Designs (Pty) Ltd
> E: robert@.cyberprop.com
> T: +27 11 955 9100
> F: +27 11 955 9110
> W: www.cyberprop.com
> W: www.cyberagent.co.za
> W: www.cyberbonds.co.za
> USP Designs (Pty) Ltd is Proudly South African!
> This message and any attachments are confidential and intended solely for
> the addressee. Any unauthorized use, alteration or dissemination is
> prohibited. USP Designs (Pty) Ltd. accepts no liability whatsoever for any
> loss, whether it be direct, indirect or consequential, arising from
> information made available and actions resulting there from.
>