Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Programming / SQL / July 2008

Tip: Looking for answers? Try searching our database.

Automation Script

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Max2006 - 03 Jul 2008 22:06 GMT
Hi,

I have to go to all tables within a database and assign a default value to
the column DATE_CREATED. I am considering creating an automated script to do
that. Is there any existing tool for these kinds of global changes?

Thank you,
Max
TheSQLGuru - 03 Jul 2008 22:18 GMT
do some dynamic script generation by joining the relevant system tables.
Here is an example of this that I just now did for a work requirement:

select 'select ''' + s.name + '.' + o.name + ''' as ''tblname'', count(*)
from [' + s.name + '].[' + o.name + ']

go'

from sys.objects o inner join sys.schemas s on o.schema_id = s.schema_id

where type = 'u'

order by s.name, o.name

grab the output and paste it and execute:

select 'audit.BookedLoanApplications' as 'tblname', count(*) from
[audit].[BookedLoanApplications]

go

select 'audit.DealerApplications' as 'tblname', count(*) from
[audit].[DealerApplications]

go

...

Signature

Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net

> Hi,
>
[quoted text clipped - 4 lines]
> Thank you,
> Max
Max2006 - 04 Jul 2008 13:57 GMT
Thanks Kevin for help.
Is there any existing tool to so such tasks?

Max

> do some dynamic script generation by joining the relevant system tables.
> Here is an example of this that I just now did for a work requirement:
[quoted text clipped - 32 lines]
>> Thank you,
>> Max
TheSQLGuru - 05 Jul 2008 16:03 GMT
I think there may be tools that will allow you to make a change to a table
and apply it to other tables somehow.  but such things are so variant you
best and most appropriate option (imho) is to simply script them yourselves
using the mechanism I proposed.  I use this form of build-it scripting very
frequently to do all sorts of things.

Signature

Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net

> Thanks Kevin for help.
> Is there any existing tool to so such tasks?
[quoted text clipped - 38 lines]
>>> Thank you,
>>> Max
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.