From: Max2006 on
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


From: TheSQLGuru on
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

....

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


"Max2006" <alanalan1(a)newsgroup.nospam> wrote in message
news:A421B773-DF24-4D1C-BAE2-BB199C6E43C7(a)microsoft.com...
> 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
>
>


From: Max2006 on

Thanks Kevin for help.
Is there any existing tool to so such tasks?

Max

"TheSQLGuru" <kgboles(a)earthlink.net> wrote in message
news:LdWdnUAyaeVk3PDVnZ2dnUVZ_rrinZ2d(a)earthlink.com...
> 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
>
> ...
>
> --
> Kevin G. Boles
> Indicium Resources, Inc.
> SQL Server MVP
> kgboles a earthlink dt net
>
>
> "Max2006" <alanalan1(a)newsgroup.nospam> wrote in message
> news:A421B773-DF24-4D1C-BAE2-BB199C6E43C7(a)microsoft.com...
>> 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
>>
>>
>
>
From: TheSQLGuru on
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.

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


"Max2006" <alanalan1(a)newsgroup.nospam> wrote in message
news:1F3A5A35-D99C-4A14-98B6-7E42C13F640A(a)microsoft.com...
>
> Thanks Kevin for help.
> Is there any existing tool to so such tasks?
>
> Max
>
> "TheSQLGuru" <kgboles(a)earthlink.net> wrote in message
> news:LdWdnUAyaeVk3PDVnZ2dnUVZ_rrinZ2d(a)earthlink.com...
>> 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
>>
>> ...
>>
>> --
>> Kevin G. Boles
>> Indicium Resources, Inc.
>> SQL Server MVP
>> kgboles a earthlink dt net
>>
>>
>> "Max2006" <alanalan1(a)newsgroup.nospam> wrote in message
>> news:A421B773-DF24-4D1C-BAE2-BB199C6E43C7(a)microsoft.com...
>>> 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
>>>
>>>
>>
>>