Showing posts with label objects. Show all posts
Showing posts with label objects. Show all posts

Tuesday, March 20, 2012

Automatic script out database objects to file

Hi champs,

It is possible to script the databases , tables and all other objects, out to a SQL file.

Is there a way to control this with a script?

For instance, want to run a script that schripts only all the tables out to a result -SQL script.

Or a script that scripts out all the constraints and user defined variables to a SQL result script.

Is this possible to do in a SQL script?

/Many thanks

YOu can use the SMO classes for that with iterating through the information of the object collections, but you can′t do that in TSQL easily.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

automatic rename in FROM clause of dependant objects ?

I have a problem.
I should rename some tables which are referenced in numerous stored
procedures.
Is there any way to automatically replace old table name with new one in all
dependant stored procedures,
instead of manual replacement in every stored procedure ehich would be
time-consuming?

Thank you in advance.Hi

No. You need to do it by hand for all Functions, Triggers and Stored
Procedures.
People will really get cross is SQL server would go and change scripts.

Regards
----------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mike@.epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

"Zlatko Mati" <zlatko.matic1@.sb.t-com.hr> wrote in message
news:d1ieos$nno$1@.ls219.htnet.hr...
> I have a problem.
> I should rename some tables which are referenced in numerous stored
> procedures.
> Is there any way to automatically replace old table name with new one in
all
> dependant stored procedures,
> instead of manual replacement in every stored procedure ehich would be
> time-consuming?
> Thank you in advance.|||On Sun, 20 Mar 2005 01:07:22 +0100, "Zlatko Mati" <zlatko.matic1@.sb.t-com.hr>
wrote:

>I have a problem.
>I should rename some tables which are referenced in numerous stored
>procedures.
>Is there any way to automatically replace old table name with new one in all
>dependant stored procedures,
> instead of manual replacement in every stored procedure ehich would be
>time-consuming?
>Thank you in advance.

2 words - Speed Ferret.

http://www.moshannon.com/|||Zlatko Mati wrote:
> I have a problem.
> I should rename some tables which are referenced in numerous stored
> procedures.
> Is there any way to automatically replace old table name with new one
in all
> dependant stored procedures,
> instead of manual replacement in every stored procedure ehich would
be
> time-consuming?
> Thank you in advance.

One word. View.

--
David Rowland
http://dbmonitor.tripod.com|||Hi

Scripting the procedure to a file(s) and globally replacing should make all
the necessary changes. Having your code in a source code control system
would help you identify what needs to be changed.

John

"Zlatko Mati" <zlatko.matic1@.sb.t-com.hr> wrote in message
news:d1ieos$nno$1@.ls219.htnet.hr...
>I have a problem.
> I should rename some tables which are referenced in numerous stored
> procedures.
> Is there any way to automatically replace old table name with new one in
> all dependant stored procedures,
> instead of manual replacement in every stored procedure ehich would be
> time-consuming?
> Thank you in advance.

Wednesday, March 7, 2012

Automate inclusion of new tables?

I'm running snapshot replication, and there will often be new tables (and
other objects) added to the publisher that I'd like to automatically include
in the subscription. Any ideas on how to do this? I've thought about creating
a script that lists all the tables, etc., in a publisher, and then including
each of those in the subscription, but I have no idea if/how it would work.
Any help would be appreciated. Thanks!
You could use sp_addarticle and sp_addsubscription for each new table.
Finding the new tables depends on how you have this set up. If it is all the
tables, you could find tables from information_schema.tables which are not
in sysarticles, and use a cursor to iterate through and run the stored procs
ablve.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)