Hello,
these tables belong to differnt locations all over the world. They have
same fields, but ofcourse with differnt values.
Also if you could guide me on the way to check the structure of acess
tables.
E.g
table_1 contains 7 columns, how can I find out if other tables also
contain same 7 columns. Incase there ar eany missing i should insert
them and in case there are any more, I should delete them.
Is there any programming technique to loop through all the tables or
something like that?
thanks
Diva
[quoted text, click to view] Aaron Bertrand [SQL Server MVP] wrote:
> Well, it sounded like you needed to run the update ONCE. The easiest way to
> do what you are suggesting in a more routine way is to take the 2000 UPDATE
> statements that are generated, wrap them in a stored procedure, and call
> that from your ASP code instead of ad hoc SQL.
>
> However, it is troubling to me that you need to update 2000 tables in the
> exact same way as a normal operation in your application. What are you
> storing 2000 times, in an identical way, that you could store once?
>
>
>
>
> <divaof_7@yahoo.com> wrote in message
> news:1151900255.088962.67980@h44g2000cwa.googlegroups.com...
> > Hello Aaron,
> >
> > Thanks,
> >
> > However can you eeplain with an example the above statement. Because I
> > need to embed the statement in an .asp page.
> >
> > My update statement runs as follows:
> > "UPDATE dbo.tblAntwort_2006_BAA SET Massnahmen='" & strmassnahmen & "',
> > Erledig_von='" & strErledig_von & "', Prio='" & strPrio & "',
> > erledigt='" & strerledigt & "', Erledigt_am='" & strErledigt_am & "'
> > WHERE Frage = " & frage & " AND Zuord=" & objzuord & ""
> >
> > Can you tell me how do I apply based on above update statement.
> > Regards
> > Diva
> >
> > Aaron Bertrand [SQL Server MVP] wrote:
> >> SELECT 'UPDATE ' + TABLE_NAME + ' SET foo = ''bar'' WHERE ...;'
> >> FROM INFORMATION_SCHEMA.TABLES
> >> -- WHERE TABLE_NAME [matches some pattern]
> >>
> >> This will generate an update statement for every table in your database,
> >> which you can copy and paste form the results pane into a new window, and
> >> edit before running if necessary.
> >>
> >>
> >>
> >>
> >> <divaof_7@yahoo.com> wrote in message
> >> news:1151897657.355671.215990@v61g2000cwv.googlegroups.com...
> >> > Hi,
> >> >
> >> > I need to update about 2000 database tables, for which update statement
> >> > (which I already have run on one table) for each remains the same.
> >> > Which is the effective SQL query method to do the same.
> >> > Thanks
> >> >
> >
SELECT 'UPDATE ' + TABLE_NAME + ' SET foo = ''bar'' WHERE ...;'
FROM INFORMATION_SCHEMA.TABLES
-- WHERE TABLE_NAME [matches some pattern]
This will generate an update statement for every table in your database,
which you can copy and paste form the results pane into a new window, and
edit before running if necessary.
[quoted text, click to view] <divaof_7@yahoo.com> wrote in message
news:1151897657.355671.215990@v61g2000cwv.googlegroups.com...
> Hi,
>
> I need to update about 2000 database tables, for which update statement
> (which I already have run on one table) for each remains the same.
> Which is the effective SQL query method to do the same.
> Thanks
>
Well, it sounded like you needed to run the update ONCE. The easiest way to
do what you are suggesting in a more routine way is to take the 2000 UPDATE
statements that are generated, wrap them in a stored procedure, and call
that from your ASP code instead of ad hoc SQL.
However, it is troubling to me that you need to update 2000 tables in the
exact same way as a normal operation in your application. What are you
storing 2000 times, in an identical way, that you could store once?
[quoted text, click to view] <divaof_7@yahoo.com> wrote in message
news:1151900255.088962.67980@h44g2000cwa.googlegroups.com...
> Hello Aaron,
>
> Thanks,
>
> However can you eeplain with an example the above statement. Because I
> need to embed the statement in an .asp page.
>
> My update statement runs as follows:
> "UPDATE dbo.tblAntwort_2006_BAA SET Massnahmen='" & strmassnahmen & "',
> Erledig_von='" & strErledig_von & "', Prio='" & strPrio & "',
> erledigt='" & strerledigt & "', Erledigt_am='" & strErledigt_am & "'
> WHERE Frage = " & frage & " AND Zuord=" & objzuord & ""
>
> Can you tell me how do I apply based on above update statement.
> Regards
> Diva
>
> Aaron Bertrand [SQL Server MVP] wrote:
>> SELECT 'UPDATE ' + TABLE_NAME + ' SET foo = ''bar'' WHERE ...;'
>> FROM INFORMATION_SCHEMA.TABLES
>> -- WHERE TABLE_NAME [matches some pattern]
>>
>> This will generate an update statement for every table in your database,
>> which you can copy and paste form the results pane into a new window, and
>> edit before running if necessary.
>>
>>
>>
>>
>> <divaof_7@yahoo.com> wrote in message
>> news:1151897657.355671.215990@v61g2000cwv.googlegroups.com...
>> > Hi,
>> >
>> > I need to update about 2000 database tables, for which update statement
>> > (which I already have run on one table) for each remains the same.
>> > Which is the effective SQL query method to do the same.
>> > Thanks
>> >
>