Hi All, If I add a column to a table how do I ensure its position? Through
the GUI via Ent. Mgr I can drag to the right place, is there a way to do
code wise?
TIAhttp://www.aspfaq.com/2528
"Vai2000" <nospam@.microsoft.com> wrote in message
news:%23AgGKg5cGHA.1792@.TK2MSFTNGP03.phx.gbl...
> Hi All, If I add a column to a table how do I ensure its position? Through
> the GUI via Ent. Mgr I can drag to the right place, is there a way to do
> code wise?
> TIA
>|||Without dropping and recreating the table, NO.
This is what EM does in the background.
"Vai2000" <nospam@.microsoft.com> wrote in message
news:%23AgGKg5cGHA.1792@.TK2MSFTNGP03.phx.gbl...
> Hi All, If I add a column to a table how do I ensure its position? Through
> the GUI via Ent. Mgr I can drag to the right place, is there a way to do
> code wise?
> TIA
>|||A 'position' in the table is irrelevant. You can select the columns in any
order you want. The only time a column order might matter is if you do
'select *' which is not recommended.
EM allows you to put a column in a particular 'position' by completely
recreating the entire table. This can be very inefficient if the table has
lots of data, plus indexes constraints and triggers will all have to be
rebuilt.
If you want the same result in code, you have to do a complete re-creation
of the table.
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"Vai2000" <nospam@.microsoft.com> wrote in message
news:%23AgGKg5cGHA.1792@.TK2MSFTNGP03.phx.gbl...
> Hi All, If I add a column to a table how do I ensure its position? Through
> the GUI via Ent. Mgr I can drag to the right place, is there a way to do
> code wise?
> TIA
>sql
Showing posts with label ent. Show all posts
Showing posts with label ent. Show all posts
Sunday, March 25, 2012
Thursday, March 22, 2012
Alter table via t-sql vs Ent Manager
Hello all!
What is the difference between running a alter table statement that adds a
new column to a sql server 2000 table using Query Analyser or Enterprise
Manager?
I noticed that if we do it using Ent. Manager it creates a big script that
copies the whole table to a temp table, adds the new column and than
renames it to the original table dropping the old one.
If we do it using QA we just need a "ALTER TABLE X ADD ..."
Question IS:
Is EM preferable, more reliable?
Is QA safe in the case of a server failure while running the query. What is
the fastest/reliable method if I want to add a column to a 13 milion record
table?. BOL states that alter table statements are logged a fully
recoverable. This recovery would be automatic or would require any manual
statements?
Very confused as you see...
TIA
mid
Hi.
Difference:
If you do change in table structure using EM then:-
1. Unload the data
2. Drop the table and dependants (indexes)
3. Create the table with new definition
4. Create dependant objects
5. Loads back the data and delete the file.
If You do it Query Analyzer using ALTER TABLE then:-
1. It just directly changes the definition or adds a new column.
So it is allways advisible to change the table definition using Query
ANalyzer -- ALTER TABLE command. Since this activity is
logged we can revert back if the database is set in FULL recovery model.
As well as it is very fast, only disadvantage is using alter Table you cann
add a new column only at the last.
Thanks
Hari
MCDBA
"mid" <midbarsinai@.midbarnospam.org> wrote in message
news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
> Hello all!
> What is the difference between running a alter table statement that adds a
> new column to a sql server 2000 table using Query Analyser or Enterprise
> Manager?
> I noticed that if we do it using Ent. Manager it creates a big script that
> copies the whole table to a temp table, adds the new column and than
> renames it to the original table dropping the old one.
> If we do it using QA we just need a "ALTER TABLE X ADD ..."
> Question IS:
> Is EM preferable, more reliable?
> Is QA safe in the case of a server failure while running the query. What
is
> the fastest/reliable method if I want to add a column to a 13 milion
record
> table?. BOL states that alter table statements are logged a fully
> recoverable. This recovery would be automatic or would require any manual
> statements?
> Very confused as you see...
> TIA
> mid
|||Thanks Hari.
My database is in Simple recovery model. Supose I am running a long alter
table statement via QA and sql server stops. When I bring SQL online again
will the structure of the table reflect the old structure? Will I have a
corrupted table?
When you say "we can revert back if the database is set in FULL recovery
model" I think you mean that if needed we can have the old structure back
again by aplying the last Transaction Log backup. Am I correct?
Thanks again,
mid
On Thu, 20 May 2004 15:14:17 +0530, Hari wrote:
[vbcol=seagreen]
> Hi.
> Difference:
> If you do change in table structure using EM then:-
> 1. Unload the data
> 2. Drop the table and dependants (indexes)
> 3. Create the table with new definition
> 4. Create dependant objects
> 5. Loads back the data and delete the file.
>
> If You do it Query Analyzer using ALTER TABLE then:-
> 1. It just directly changes the definition or adds a new column.
>
> So it is allways advisible to change the table definition using Query
> ANalyzer -- ALTER TABLE command. Since this activity is
> logged we can revert back if the database is set in FULL recovery model.
> As well as it is very fast, only disadvantage is using alter Table you cann
> add a new column only at the last.
> Thanks
> Hari
> MCDBA
>
>
>
> "mid" <midbarsinai@.midbarnospam.org> wrote in message
> news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
> is
> record
|||Hi,
Restarting while doing a ALTER TABLE (Any DDL statement) is bit risky. The
table might not get corrupted rather the change
will be rolled back once the SQL Server comes back. So you can get the old
image of table.
This scenario will be same for SIMPLE or FULL recovery model. In FULL
recovery model even if the ALTER TABLE succeedes you can roll back
to old shape.
But doing this is very risky.
Thanks
Hari
MCDBA
"mid" <midbarsinai@.midbarnospam.org> wrote in message
news:3ye70mka23ys$.dlg@.midbarnospam.org...[vbcol=seagreen]
> Thanks Hari.
> My database is in Simple recovery model. Supose I am running a long alter
> table statement via QA and sql server stops. When I bring SQL online again
> will the structure of the table reflect the old structure? Will I have a
> corrupted table?
> When you say "we can revert back if the database is set in FULL recovery
> model" I think you mean that if needed we can have the old structure back
> again by aplying the last Transaction Log backup. Am I correct?
> Thanks again,
> mid
> On Thu, 20 May 2004 15:14:17 +0530, Hari wrote:
cann[vbcol=seagreen]
adds a[vbcol=seagreen]
Enterprise[vbcol=seagreen]
that[vbcol=seagreen]
What[vbcol=seagreen]
manual[vbcol=seagreen]
sql
What is the difference between running a alter table statement that adds a
new column to a sql server 2000 table using Query Analyser or Enterprise
Manager?
I noticed that if we do it using Ent. Manager it creates a big script that
copies the whole table to a temp table, adds the new column and than
renames it to the original table dropping the old one.
If we do it using QA we just need a "ALTER TABLE X ADD ..."
Question IS:
Is EM preferable, more reliable?
Is QA safe in the case of a server failure while running the query. What is
the fastest/reliable method if I want to add a column to a 13 milion record
table?. BOL states that alter table statements are logged a fully
recoverable. This recovery would be automatic or would require any manual
statements?
Very confused as you see...
TIA
mid
Hi.
Difference:
If you do change in table structure using EM then:-
1. Unload the data
2. Drop the table and dependants (indexes)
3. Create the table with new definition
4. Create dependant objects
5. Loads back the data and delete the file.
If You do it Query Analyzer using ALTER TABLE then:-
1. It just directly changes the definition or adds a new column.
So it is allways advisible to change the table definition using Query
ANalyzer -- ALTER TABLE command. Since this activity is
logged we can revert back if the database is set in FULL recovery model.
As well as it is very fast, only disadvantage is using alter Table you cann
add a new column only at the last.
Thanks
Hari
MCDBA
"mid" <midbarsinai@.midbarnospam.org> wrote in message
news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
> Hello all!
> What is the difference between running a alter table statement that adds a
> new column to a sql server 2000 table using Query Analyser or Enterprise
> Manager?
> I noticed that if we do it using Ent. Manager it creates a big script that
> copies the whole table to a temp table, adds the new column and than
> renames it to the original table dropping the old one.
> If we do it using QA we just need a "ALTER TABLE X ADD ..."
> Question IS:
> Is EM preferable, more reliable?
> Is QA safe in the case of a server failure while running the query. What
is
> the fastest/reliable method if I want to add a column to a 13 milion
record
> table?. BOL states that alter table statements are logged a fully
> recoverable. This recovery would be automatic or would require any manual
> statements?
> Very confused as you see...
> TIA
> mid
|||Thanks Hari.
My database is in Simple recovery model. Supose I am running a long alter
table statement via QA and sql server stops. When I bring SQL online again
will the structure of the table reflect the old structure? Will I have a
corrupted table?
When you say "we can revert back if the database is set in FULL recovery
model" I think you mean that if needed we can have the old structure back
again by aplying the last Transaction Log backup. Am I correct?
Thanks again,
mid
On Thu, 20 May 2004 15:14:17 +0530, Hari wrote:
[vbcol=seagreen]
> Hi.
> Difference:
> If you do change in table structure using EM then:-
> 1. Unload the data
> 2. Drop the table and dependants (indexes)
> 3. Create the table with new definition
> 4. Create dependant objects
> 5. Loads back the data and delete the file.
>
> If You do it Query Analyzer using ALTER TABLE then:-
> 1. It just directly changes the definition or adds a new column.
>
> So it is allways advisible to change the table definition using Query
> ANalyzer -- ALTER TABLE command. Since this activity is
> logged we can revert back if the database is set in FULL recovery model.
> As well as it is very fast, only disadvantage is using alter Table you cann
> add a new column only at the last.
> Thanks
> Hari
> MCDBA
>
>
>
> "mid" <midbarsinai@.midbarnospam.org> wrote in message
> news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
> is
> record
|||Hi,
Restarting while doing a ALTER TABLE (Any DDL statement) is bit risky. The
table might not get corrupted rather the change
will be rolled back once the SQL Server comes back. So you can get the old
image of table.
This scenario will be same for SIMPLE or FULL recovery model. In FULL
recovery model even if the ALTER TABLE succeedes you can roll back
to old shape.
But doing this is very risky.
Thanks
Hari
MCDBA
"mid" <midbarsinai@.midbarnospam.org> wrote in message
news:3ye70mka23ys$.dlg@.midbarnospam.org...[vbcol=seagreen]
> Thanks Hari.
> My database is in Simple recovery model. Supose I am running a long alter
> table statement via QA and sql server stops. When I bring SQL online again
> will the structure of the table reflect the old structure? Will I have a
> corrupted table?
> When you say "we can revert back if the database is set in FULL recovery
> model" I think you mean that if needed we can have the old structure back
> again by aplying the last Transaction Log backup. Am I correct?
> Thanks again,
> mid
> On Thu, 20 May 2004 15:14:17 +0530, Hari wrote:
cann[vbcol=seagreen]
adds a[vbcol=seagreen]
Enterprise[vbcol=seagreen]
that[vbcol=seagreen]
What[vbcol=seagreen]
manual[vbcol=seagreen]
sql
Alter table via t-sql vs Ent Manager
Hello all!
What is the difference between running a alter table statement that adds a
new column to a sql server 2000 table using Query Analyser or Enterprise
Manager?
I noticed that if we do it using Ent. Manager it creates a big script that
copies the whole table to a temp table, adds the new column and than
renames it to the original table dropping the old one.
If we do it using QA we just need a "ALTER TABLE X ADD ..."
Question IS:
Is EM preferable, more reliable?
Is QA safe in the case of a server failure while running the query. What is
the fastest/reliable method if I want to add a column to a 13 milion record
table?. BOL states that alter table statements are logged a fully
recoverable. This recovery would be automatic or would require any manual
statements?
Very confused as you see...
TIA
midHi.
Difference:
If you do change in table structure using EM then:-
1. Unload the data
2. Drop the table and dependants (indexes)
3. Create the table with new definition
4. Create dependant objects
5. Loads back the data and delete the file.
If You do it Query Analyzer using ALTER TABLE then:-
1. It just directly changes the definition or adds a new column.
So it is allways advisible to change the table definition using Query
ANalyzer -- ALTER TABLE command. Since this activity is
logged we can revert back if the database is set in FULL recovery model.
As well as it is very fast, only disadvantage is using alter Table you cann
add a new column only at the last.
Thanks
Hari
MCDBA
"mid" <midbarsinai@.midbarnospam.org> wrote in message
news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
> Hello all!
> What is the difference between running a alter table statement that adds a
> new column to a sql server 2000 table using Query Analyser or Enterprise
> Manager?
> I noticed that if we do it using Ent. Manager it creates a big script that
> copies the whole table to a temp table, adds the new column and than
> renames it to the original table dropping the old one.
> If we do it using QA we just need a "ALTER TABLE X ADD ..."
> Question IS:
> Is EM preferable, more reliable?
> Is QA safe in the case of a server failure while running the query. What
is
> the fastest/reliable method if I want to add a column to a 13 milion
record
> table?. BOL states that alter table statements are logged a fully
> recoverable. This recovery would be automatic or would require any manual
> statements?
> Very confused as you see...
> TIA
> mid|||Thanks Hari.
My database is in Simple recovery model. Supose I am running a long alter
table statement via QA and sql server stops. When I bring SQL online again
will the structure of the table reflect the old structure? Will I have a
corrupted table?
When you say "we can revert back if the database is set in FULL recovery
model" I think you mean that if needed we can have the old structure back
again by aplying the last Transaction Log backup. Am I correct?
Thanks again,
mid
On Thu, 20 May 2004 15:14:17 +0530, Hari wrote:
> Hi.
> Difference:
> If you do change in table structure using EM then:-
> 1. Unload the data
> 2. Drop the table and dependants (indexes)
> 3. Create the table with new definition
> 4. Create dependant objects
> 5. Loads back the data and delete the file.
>
> If You do it Query Analyzer using ALTER TABLE then:-
> 1. It just directly changes the definition or adds a new column.
>
> So it is allways advisible to change the table definition using Query
> ANalyzer -- ALTER TABLE command. Since this activity is
> logged we can revert back if the database is set in FULL recovery model.
> As well as it is very fast, only disadvantage is using alter Table you cann
> add a new column only at the last.
> Thanks
> Hari
> MCDBA
>
>
>
> "mid" <midbarsinai@.midbarnospam.org> wrote in message
> news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
>> Hello all!
>> What is the difference between running a alter table statement that adds a
>> new column to a sql server 2000 table using Query Analyser or Enterprise
>> Manager?
>> I noticed that if we do it using Ent. Manager it creates a big script that
>> copies the whole table to a temp table, adds the new column and than
>> renames it to the original table dropping the old one.
>> If we do it using QA we just need a "ALTER TABLE X ADD ..."
>> Question IS:
>> Is EM preferable, more reliable?
>> Is QA safe in the case of a server failure while running the query. What
> is
>> the fastest/reliable method if I want to add a column to a 13 milion
> record
>> table?. BOL states that alter table statements are logged a fully
>> recoverable. This recovery would be automatic or would require any manual
>> statements?
>> Very confused as you see...
>> TIA
>> mid|||Hi,
Restarting while doing a ALTER TABLE (Any DDL statement) is bit risky. The
table might not get corrupted rather the change
will be rolled back once the SQL Server comes back. So you can get the old
image of table.
This scenario will be same for SIMPLE or FULL recovery model. In FULL
recovery model even if the ALTER TABLE succeedes you can roll back
to old shape.
But doing this is very risky.
Thanks
Hari
MCDBA
"mid" <midbarsinai@.midbarnospam.org> wrote in message
news:3ye70mka23ys$.dlg@.midbarnospam.org...
> Thanks Hari.
> My database is in Simple recovery model. Supose I am running a long alter
> table statement via QA and sql server stops. When I bring SQL online again
> will the structure of the table reflect the old structure? Will I have a
> corrupted table?
> When you say "we can revert back if the database is set in FULL recovery
> model" I think you mean that if needed we can have the old structure back
> again by aplying the last Transaction Log backup. Am I correct?
> Thanks again,
> mid
> On Thu, 20 May 2004 15:14:17 +0530, Hari wrote:
> > Hi.
> >
> > Difference:
> >
> > If you do change in table structure using EM then:-
> >
> > 1. Unload the data
> > 2. Drop the table and dependants (indexes)
> > 3. Create the table with new definition
> > 4. Create dependant objects
> > 5. Loads back the data and delete the file.
> >
> >
> > If You do it Query Analyzer using ALTER TABLE then:-
> >
> > 1. It just directly changes the definition or adds a new column.
> >
> >
> > So it is allways advisible to change the table definition using Query
> > ANalyzer -- ALTER TABLE command. Since this activity is
> > logged we can revert back if the database is set in FULL recovery model.
> > As well as it is very fast, only disadvantage is using alter Table you
cann
> > add a new column only at the last.
> >
> > Thanks
> > Hari
> > MCDBA
> >
> >
> >
> >
> >
> >
> > "mid" <midbarsinai@.midbarnospam.org> wrote in message
> > news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
> >> Hello all!
> >>
> >> What is the difference between running a alter table statement that
adds a
> >> new column to a sql server 2000 table using Query Analyser or
Enterprise
> >> Manager?
> >>
> >> I noticed that if we do it using Ent. Manager it creates a big script
that
> >> copies the whole table to a temp table, adds the new column and than
> >> renames it to the original table dropping the old one.
> >>
> >> If we do it using QA we just need a "ALTER TABLE X ADD ..."
> >>
> >> Question IS:
> >> Is EM preferable, more reliable?
> >> Is QA safe in the case of a server failure while running the query.
What
> > is
> >> the fastest/reliable method if I want to add a column to a 13 milion
> > record
> >> table?. BOL states that alter table statements are logged a fully
> >> recoverable. This recovery would be automatic or would require any
manual
> >> statements?
> >>
> >> Very confused as you see...
> >>
> >> TIA
> >> mid
What is the difference between running a alter table statement that adds a
new column to a sql server 2000 table using Query Analyser or Enterprise
Manager?
I noticed that if we do it using Ent. Manager it creates a big script that
copies the whole table to a temp table, adds the new column and than
renames it to the original table dropping the old one.
If we do it using QA we just need a "ALTER TABLE X ADD ..."
Question IS:
Is EM preferable, more reliable?
Is QA safe in the case of a server failure while running the query. What is
the fastest/reliable method if I want to add a column to a 13 milion record
table?. BOL states that alter table statements are logged a fully
recoverable. This recovery would be automatic or would require any manual
statements?
Very confused as you see...
TIA
midHi.
Difference:
If you do change in table structure using EM then:-
1. Unload the data
2. Drop the table and dependants (indexes)
3. Create the table with new definition
4. Create dependant objects
5. Loads back the data and delete the file.
If You do it Query Analyzer using ALTER TABLE then:-
1. It just directly changes the definition or adds a new column.
So it is allways advisible to change the table definition using Query
ANalyzer -- ALTER TABLE command. Since this activity is
logged we can revert back if the database is set in FULL recovery model.
As well as it is very fast, only disadvantage is using alter Table you cann
add a new column only at the last.
Thanks
Hari
MCDBA
"mid" <midbarsinai@.midbarnospam.org> wrote in message
news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
> Hello all!
> What is the difference between running a alter table statement that adds a
> new column to a sql server 2000 table using Query Analyser or Enterprise
> Manager?
> I noticed that if we do it using Ent. Manager it creates a big script that
> copies the whole table to a temp table, adds the new column and than
> renames it to the original table dropping the old one.
> If we do it using QA we just need a "ALTER TABLE X ADD ..."
> Question IS:
> Is EM preferable, more reliable?
> Is QA safe in the case of a server failure while running the query. What
is
> the fastest/reliable method if I want to add a column to a 13 milion
record
> table?. BOL states that alter table statements are logged a fully
> recoverable. This recovery would be automatic or would require any manual
> statements?
> Very confused as you see...
> TIA
> mid|||Thanks Hari.
My database is in Simple recovery model. Supose I am running a long alter
table statement via QA and sql server stops. When I bring SQL online again
will the structure of the table reflect the old structure? Will I have a
corrupted table?
When you say "we can revert back if the database is set in FULL recovery
model" I think you mean that if needed we can have the old structure back
again by aplying the last Transaction Log backup. Am I correct?
Thanks again,
mid
On Thu, 20 May 2004 15:14:17 +0530, Hari wrote:
> Hi.
> Difference:
> If you do change in table structure using EM then:-
> 1. Unload the data
> 2. Drop the table and dependants (indexes)
> 3. Create the table with new definition
> 4. Create dependant objects
> 5. Loads back the data and delete the file.
>
> If You do it Query Analyzer using ALTER TABLE then:-
> 1. It just directly changes the definition or adds a new column.
>
> So it is allways advisible to change the table definition using Query
> ANalyzer -- ALTER TABLE command. Since this activity is
> logged we can revert back if the database is set in FULL recovery model.
> As well as it is very fast, only disadvantage is using alter Table you cann
> add a new column only at the last.
> Thanks
> Hari
> MCDBA
>
>
>
> "mid" <midbarsinai@.midbarnospam.org> wrote in message
> news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
>> Hello all!
>> What is the difference between running a alter table statement that adds a
>> new column to a sql server 2000 table using Query Analyser or Enterprise
>> Manager?
>> I noticed that if we do it using Ent. Manager it creates a big script that
>> copies the whole table to a temp table, adds the new column and than
>> renames it to the original table dropping the old one.
>> If we do it using QA we just need a "ALTER TABLE X ADD ..."
>> Question IS:
>> Is EM preferable, more reliable?
>> Is QA safe in the case of a server failure while running the query. What
> is
>> the fastest/reliable method if I want to add a column to a 13 milion
> record
>> table?. BOL states that alter table statements are logged a fully
>> recoverable. This recovery would be automatic or would require any manual
>> statements?
>> Very confused as you see...
>> TIA
>> mid|||Hi,
Restarting while doing a ALTER TABLE (Any DDL statement) is bit risky. The
table might not get corrupted rather the change
will be rolled back once the SQL Server comes back. So you can get the old
image of table.
This scenario will be same for SIMPLE or FULL recovery model. In FULL
recovery model even if the ALTER TABLE succeedes you can roll back
to old shape.
But doing this is very risky.
Thanks
Hari
MCDBA
"mid" <midbarsinai@.midbarnospam.org> wrote in message
news:3ye70mka23ys$.dlg@.midbarnospam.org...
> Thanks Hari.
> My database is in Simple recovery model. Supose I am running a long alter
> table statement via QA and sql server stops. When I bring SQL online again
> will the structure of the table reflect the old structure? Will I have a
> corrupted table?
> When you say "we can revert back if the database is set in FULL recovery
> model" I think you mean that if needed we can have the old structure back
> again by aplying the last Transaction Log backup. Am I correct?
> Thanks again,
> mid
> On Thu, 20 May 2004 15:14:17 +0530, Hari wrote:
> > Hi.
> >
> > Difference:
> >
> > If you do change in table structure using EM then:-
> >
> > 1. Unload the data
> > 2. Drop the table and dependants (indexes)
> > 3. Create the table with new definition
> > 4. Create dependant objects
> > 5. Loads back the data and delete the file.
> >
> >
> > If You do it Query Analyzer using ALTER TABLE then:-
> >
> > 1. It just directly changes the definition or adds a new column.
> >
> >
> > So it is allways advisible to change the table definition using Query
> > ANalyzer -- ALTER TABLE command. Since this activity is
> > logged we can revert back if the database is set in FULL recovery model.
> > As well as it is very fast, only disadvantage is using alter Table you
cann
> > add a new column only at the last.
> >
> > Thanks
> > Hari
> > MCDBA
> >
> >
> >
> >
> >
> >
> > "mid" <midbarsinai@.midbarnospam.org> wrote in message
> > news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
> >> Hello all!
> >>
> >> What is the difference between running a alter table statement that
adds a
> >> new column to a sql server 2000 table using Query Analyser or
Enterprise
> >> Manager?
> >>
> >> I noticed that if we do it using Ent. Manager it creates a big script
that
> >> copies the whole table to a temp table, adds the new column and than
> >> renames it to the original table dropping the old one.
> >>
> >> If we do it using QA we just need a "ALTER TABLE X ADD ..."
> >>
> >> Question IS:
> >> Is EM preferable, more reliable?
> >> Is QA safe in the case of a server failure while running the query.
What
> > is
> >> the fastest/reliable method if I want to add a column to a 13 milion
> > record
> >> table?. BOL states that alter table statements are logged a fully
> >> recoverable. This recovery would be automatic or would require any
manual
> >> statements?
> >>
> >> Very confused as you see...
> >>
> >> TIA
> >> mid
Alter table via t-sql vs Ent Manager
Hello all!
What is the difference between running a alter table statement that adds a
new column to a sql server 2000 table using Query Analyser or Enterprise
Manager?
I noticed that if we do it using Ent. Manager it creates a big script that
copies the whole table to a temp table, adds the new column and than
renames it to the original table dropping the old one.
If we do it using QA we just need a "ALTER TABLE X ADD ..."
Question IS:
Is EM preferable, more reliable?
Is QA safe in the case of a server failure while running the query. What is
the fastest/reliable method if I want to add a column to a 13 milion record
table?. BOL states that alter table statements are logged a fully
recoverable. This recovery would be automatic or would require any manual
statements?
Very confused as you see...
TIA
midHi.
Difference:
If you do change in table structure using EM then:-
1. Unload the data
2. Drop the table and dependants (indexes)
3. Create the table with new definition
4. Create dependant objects
5. Loads back the data and delete the file.
If You do it Query Analyzer using ALTER TABLE then:-
1. It just directly changes the definition or adds a new column.
So it is allways advisible to change the table definition using Query
ANalyzer -- ALTER TABLE command. Since this activity is
logged we can revert back if the database is set in FULL recovery model.
As well as it is very fast, only disadvantage is using alter Table you cann
add a new column only at the last.
Thanks
Hari
MCDBA
"mid" <midbarsinai@.midbarnospam.org> wrote in message
news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
> Hello all!
> What is the difference between running a alter table statement that adds a
> new column to a sql server 2000 table using Query Analyser or Enterprise
> Manager?
> I noticed that if we do it using Ent. Manager it creates a big script that
> copies the whole table to a temp table, adds the new column and than
> renames it to the original table dropping the old one.
> If we do it using QA we just need a "ALTER TABLE X ADD ..."
> Question IS:
> Is EM preferable, more reliable?
> Is QA safe in the case of a server failure while running the query. What
is
> the fastest/reliable method if I want to add a column to a 13 milion
record
> table?. BOL states that alter table statements are logged a fully
> recoverable. This recovery would be automatic or would require any manual
> statements?
> Very confused as you see...
> TIA
> mid|||Thanks Hari.
My database is in Simple recovery model. Supose I am running a long alter
table statement via QA and sql server stops. When I bring SQL online again
will the structure of the table reflect the old structure? Will I have a
corrupted table?
When you say "we can revert back if the database is set in FULL recovery
model" I think you mean that if needed we can have the old structure back
again by aplying the last Transaction Log backup. Am I correct?
Thanks again,
mid
On Thu, 20 May 2004 15:14:17 +0530, Hari wrote:
[vbcol=seagreen]
> Hi.
> Difference:
> If you do change in table structure using EM then:-
> 1. Unload the data
> 2. Drop the table and dependants (indexes)
> 3. Create the table with new definition
> 4. Create dependant objects
> 5. Loads back the data and delete the file.
>
> If You do it Query Analyzer using ALTER TABLE then:-
> 1. It just directly changes the definition or adds a new column.
>
> So it is allways advisible to change the table definition using Query
> ANalyzer -- ALTER TABLE command. Since this activity is
> logged we can revert back if the database is set in FULL recovery model.
> As well as it is very fast, only disadvantage is using alter Table you can
n
> add a new column only at the last.
> Thanks
> Hari
> MCDBA
>
>
>
> "mid" <midbarsinai@.midbarnospam.org> wrote in message
> news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
> is
> record|||Hi,
Restarting while doing a ALTER TABLE (Any DDL statement) is bit risky. The
table might not get corrupted rather the change
will be rolled back once the SQL Server comes back. So you can get the old
image of table.
This scenario will be same for SIMPLE or FULL recovery model. In FULL
recovery model even if the ALTER TABLE succeedes you can roll back
to old shape.
But doing this is very risky.
Thanks
Hari
MCDBA
"mid" <midbarsinai@.midbarnospam.org> wrote in message
news:3ye70mka23ys$.dlg@.midbarnospam.org...[vbcol=seagreen]
> Thanks Hari.
> My database is in Simple recovery model. Supose I am running a long alter
> table statement via QA and sql server stops. When I bring SQL online again
> will the structure of the table reflect the old structure? Will I have a
> corrupted table?
> When you say "we can revert back if the database is set in FULL recovery
> model" I think you mean that if needed we can have the old structure back
> again by aplying the last Transaction Log backup. Am I correct?
> Thanks again,
> mid
> On Thu, 20 May 2004 15:14:17 +0530, Hari wrote:
>
cann[vbcol=seagreen]
adds a[vbcol=seagreen]
Enterprise[vbcol=seagreen]
that[vbcol=seagreen]
What[vbcol=seagreen]
manual[vbcol=seagreen]
What is the difference between running a alter table statement that adds a
new column to a sql server 2000 table using Query Analyser or Enterprise
Manager?
I noticed that if we do it using Ent. Manager it creates a big script that
copies the whole table to a temp table, adds the new column and than
renames it to the original table dropping the old one.
If we do it using QA we just need a "ALTER TABLE X ADD ..."
Question IS:
Is EM preferable, more reliable?
Is QA safe in the case of a server failure while running the query. What is
the fastest/reliable method if I want to add a column to a 13 milion record
table?. BOL states that alter table statements are logged a fully
recoverable. This recovery would be automatic or would require any manual
statements?
Very confused as you see...
TIA
midHi.
Difference:
If you do change in table structure using EM then:-
1. Unload the data
2. Drop the table and dependants (indexes)
3. Create the table with new definition
4. Create dependant objects
5. Loads back the data and delete the file.
If You do it Query Analyzer using ALTER TABLE then:-
1. It just directly changes the definition or adds a new column.
So it is allways advisible to change the table definition using Query
ANalyzer -- ALTER TABLE command. Since this activity is
logged we can revert back if the database is set in FULL recovery model.
As well as it is very fast, only disadvantage is using alter Table you cann
add a new column only at the last.
Thanks
Hari
MCDBA
"mid" <midbarsinai@.midbarnospam.org> wrote in message
news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
> Hello all!
> What is the difference between running a alter table statement that adds a
> new column to a sql server 2000 table using Query Analyser or Enterprise
> Manager?
> I noticed that if we do it using Ent. Manager it creates a big script that
> copies the whole table to a temp table, adds the new column and than
> renames it to the original table dropping the old one.
> If we do it using QA we just need a "ALTER TABLE X ADD ..."
> Question IS:
> Is EM preferable, more reliable?
> Is QA safe in the case of a server failure while running the query. What
is
> the fastest/reliable method if I want to add a column to a 13 milion
record
> table?. BOL states that alter table statements are logged a fully
> recoverable. This recovery would be automatic or would require any manual
> statements?
> Very confused as you see...
> TIA
> mid|||Thanks Hari.
My database is in Simple recovery model. Supose I am running a long alter
table statement via QA and sql server stops. When I bring SQL online again
will the structure of the table reflect the old structure? Will I have a
corrupted table?
When you say "we can revert back if the database is set in FULL recovery
model" I think you mean that if needed we can have the old structure back
again by aplying the last Transaction Log backup. Am I correct?
Thanks again,
mid
On Thu, 20 May 2004 15:14:17 +0530, Hari wrote:
[vbcol=seagreen]
> Hi.
> Difference:
> If you do change in table structure using EM then:-
> 1. Unload the data
> 2. Drop the table and dependants (indexes)
> 3. Create the table with new definition
> 4. Create dependant objects
> 5. Loads back the data and delete the file.
>
> If You do it Query Analyzer using ALTER TABLE then:-
> 1. It just directly changes the definition or adds a new column.
>
> So it is allways advisible to change the table definition using Query
> ANalyzer -- ALTER TABLE command. Since this activity is
> logged we can revert back if the database is set in FULL recovery model.
> As well as it is very fast, only disadvantage is using alter Table you can
n
> add a new column only at the last.
> Thanks
> Hari
> MCDBA
>
>
>
> "mid" <midbarsinai@.midbarnospam.org> wrote in message
> news:1ar8ck4gwbl0l.dlg@.midbarnospam.org...
> is
> record|||Hi,
Restarting while doing a ALTER TABLE (Any DDL statement) is bit risky. The
table might not get corrupted rather the change
will be rolled back once the SQL Server comes back. So you can get the old
image of table.
This scenario will be same for SIMPLE or FULL recovery model. In FULL
recovery model even if the ALTER TABLE succeedes you can roll back
to old shape.
But doing this is very risky.
Thanks
Hari
MCDBA
"mid" <midbarsinai@.midbarnospam.org> wrote in message
news:3ye70mka23ys$.dlg@.midbarnospam.org...[vbcol=seagreen]
> Thanks Hari.
> My database is in Simple recovery model. Supose I am running a long alter
> table statement via QA and sql server stops. When I bring SQL online again
> will the structure of the table reflect the old structure? Will I have a
> corrupted table?
> When you say "we can revert back if the database is set in FULL recovery
> model" I think you mean that if needed we can have the old structure back
> again by aplying the last Transaction Log backup. Am I correct?
> Thanks again,
> mid
> On Thu, 20 May 2004 15:14:17 +0530, Hari wrote:
>
cann[vbcol=seagreen]
adds a[vbcol=seagreen]
Enterprise[vbcol=seagreen]
that[vbcol=seagreen]
What[vbcol=seagreen]
manual[vbcol=seagreen]
Thursday, February 9, 2012
All free memory gone...
Hi!
I am running MS SQL 2000 Ent sp3 + MS Windows 2000 Datacenter on a
server with 16Gb memory. Total available memory is typically ~200MB
and pretty stable. I use Max Server Memory of 15700MB. Today I could
see a very unusual behavior: the available memory gone from 200MB to
4MB in few seconds. I decreased the Max Server Memory by 200MB:
sp_configure [max server memory (MB)], 15500
reconfigure with override
go
It did not help much: it has 8MB available memory now. The server has
a lot of paging.
What is happening to the server?
Thanks.You should run Windows performance monitor and see who is using the
memory... It is in the processes section...
"Roust_m" <roustam@.hotbox.ru> wrote in message
news:a388fd78.0312010553.2bf2d450@.posting.google.com...
> Hi!
> I am running MS SQL 2000 Ent sp3 + MS Windows 2000 Datacenter on a
> server with 16Gb memory. Total available memory is typically ~200MB
> and pretty stable. I use Max Server Memory of 15700MB. Today I could
> see a very unusual behavior: the available memory gone from 200MB to
> 4MB in few seconds. I decreased the Max Server Memory by 200MB:
> sp_configure [max server memory (MB)], 15500
> reconfigure with override
> go
> It did not help much: it has 8MB available memory now. The server has
> a lot of paging.
> What is happening to the server?
> Thanks.|||AWE memory is not dynamic so changing max server memory won't have any
effect until you restart the service. You really need to leave more room for
the OS, try setting max server memory to 14 GB and monitoring its stability.
Also make sure the /3GB switch is not in boot.ini - just use the /PAE
switch. There is a fair bit of OS overhead in managing AWE memory so you
need to give the OS room to breathe.
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Roust_m" <roustam@.hotbox.ru> wrote in message
news:a388fd78.0312010553.2bf2d450@.posting.google.com...
Hi!
I am running MS SQL 2000 Ent sp3 + MS Windows 2000 Datacenter on a
server with 16Gb memory. Total available memory is typically ~200MB
and pretty stable. I use Max Server Memory of 15700MB. Today I could
see a very unusual behavior: the available memory gone from 200MB to
4MB in few seconds. I decreased the Max Server Memory by 200MB:
sp_configure [max server memory (MB)], 15500
reconfigure with override
go
It did not help much: it has 8MB available memory now. The server has
a lot of paging.
What is happening to the server?
Thanks.|||Performance monitor does not show processes that eat that much memory.
It does not show memory usage correctly with AWE enabled.
"Wayne Snyder" <wsnyder@.computeredservices.com> wrote in message news:<uZllf7BuDHA.3536@.tk2msftngp13.phx.gbl>...
> You should run Windows performance monitor and see who is using the
> memory... It is in the processes section...
>
> "Roust_m" <roustam@.hotbox.ru> wrote in message
> news:a388fd78.0312010553.2bf2d450@.posting.google.com...
> > Hi!
> >
> > I am running MS SQL 2000 Ent sp3 + MS Windows 2000 Datacenter on a
> > server with 16Gb memory. Total available memory is typically ~200MB
> > and pretty stable. I use Max Server Memory of 15700MB. Today I could
> > see a very unusual behavior: the available memory gone from 200MB to
> > 4MB in few seconds. I decreased the Max Server Memory by 200MB:
> >
> > sp_configure [max server memory (MB)], 15500
> > reconfigure with override
> > go
> >
> > It did not help much: it has 8MB available memory now. The server has
> > a lot of paging.
> >
> > What is happening to the server?
> >
> > Thanks.|||It did work fine for 3 months with 200MB available memory.
This article:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;274750
states that you need 1GB for OS only if you have 32+GB RAM:
"When you allocate SQL Server AWE memory on a 32 GB system, Windows
2000 may require at least 1 GB memory to manage AWE. "
As for /3G switch, I also seen an article stating that you need it for
up to 16GB RAM.
Anyway it did work fine...
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message news:<OFS92FEuDHA.3436@.tk2msftngp13.phx.gbl>...
> AWE memory is not dynamic so changing max server memory won't have any
> effect until you restart the service. You really need to leave more room for
> the OS, try setting max server memory to 14 GB and monitoring its stability.
> Also make sure the /3GB switch is not in boot.ini - just use the /PAE
> switch. There is a fair bit of OS overhead in managing AWE memory so you
> need to give the OS room to breathe.
> --
> HTH
> Jasper Smith (SQL Server MVP)
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "Roust_m" <roustam@.hotbox.ru> wrote in message
> news:a388fd78.0312010553.2bf2d450@.posting.google.com...
> Hi!
> I am running MS SQL 2000 Ent sp3 + MS Windows 2000 Datacenter on a
> server with 16Gb memory. Total available memory is typically ~200MB
> and pretty stable. I use Max Server Memory of 15700MB. Today I could
> see a very unusual behavior: the available memory gone from 200MB to
> 4MB in few seconds. I decreased the Max Server Memory by 200MB:
> sp_configure [max server memory (MB)], 15500
> reconfigure with override
> go
> It did not help much: it has 8MB available memory now. The server has
> a lot of paging.
> What is happening to the server?
> Thanks.|||Windows 2000 Datacenter Server Does Not Locate Memory Greater Than 16 GB
http://support.microsoft.com/default.aspx?scid=kb;EN-US;292934
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message news:<OFS92FEuDHA.3436@.tk2msftngp13.phx.gbl>...
> AWE memory is not dynamic so changing max server memory won't have any
> effect until you restart the service. You really need to leave more room for
> the OS, try setting max server memory to 14 GB and monitoring its stability.
> Also make sure the /3GB switch is not in boot.ini - just use the /PAE
> switch. There is a fair bit of OS overhead in managing AWE memory so you
> need to give the OS room to breathe.
> --
> HTH
> Jasper Smith (SQL Server MVP)
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "Roust_m" <roustam@.hotbox.ru> wrote in message
> news:a388fd78.0312010553.2bf2d450@.posting.google.com...
> Hi!
> I am running MS SQL 2000 Ent sp3 + MS Windows 2000 Datacenter on a
> server with 16Gb memory. Total available memory is typically ~200MB
> and pretty stable. I use Max Server Memory of 15700MB. Today I could
> see a very unusual behavior: the available memory gone from 200MB to
> 4MB in few seconds. I decreased the Max Server Memory by 200MB:
> sp_configure [max server memory (MB)], 15500
> reconfigure with override
> go
> It did not help much: it has 8MB available memory now. The server has
> a lot of paging.
> What is happening to the server?
> Thanks.
I am running MS SQL 2000 Ent sp3 + MS Windows 2000 Datacenter on a
server with 16Gb memory. Total available memory is typically ~200MB
and pretty stable. I use Max Server Memory of 15700MB. Today I could
see a very unusual behavior: the available memory gone from 200MB to
4MB in few seconds. I decreased the Max Server Memory by 200MB:
sp_configure [max server memory (MB)], 15500
reconfigure with override
go
It did not help much: it has 8MB available memory now. The server has
a lot of paging.
What is happening to the server?
Thanks.You should run Windows performance monitor and see who is using the
memory... It is in the processes section...
"Roust_m" <roustam@.hotbox.ru> wrote in message
news:a388fd78.0312010553.2bf2d450@.posting.google.com...
> Hi!
> I am running MS SQL 2000 Ent sp3 + MS Windows 2000 Datacenter on a
> server with 16Gb memory. Total available memory is typically ~200MB
> and pretty stable. I use Max Server Memory of 15700MB. Today I could
> see a very unusual behavior: the available memory gone from 200MB to
> 4MB in few seconds. I decreased the Max Server Memory by 200MB:
> sp_configure [max server memory (MB)], 15500
> reconfigure with override
> go
> It did not help much: it has 8MB available memory now. The server has
> a lot of paging.
> What is happening to the server?
> Thanks.|||AWE memory is not dynamic so changing max server memory won't have any
effect until you restart the service. You really need to leave more room for
the OS, try setting max server memory to 14 GB and monitoring its stability.
Also make sure the /3GB switch is not in boot.ini - just use the /PAE
switch. There is a fair bit of OS overhead in managing AWE memory so you
need to give the OS room to breathe.
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Roust_m" <roustam@.hotbox.ru> wrote in message
news:a388fd78.0312010553.2bf2d450@.posting.google.com...
Hi!
I am running MS SQL 2000 Ent sp3 + MS Windows 2000 Datacenter on a
server with 16Gb memory. Total available memory is typically ~200MB
and pretty stable. I use Max Server Memory of 15700MB. Today I could
see a very unusual behavior: the available memory gone from 200MB to
4MB in few seconds. I decreased the Max Server Memory by 200MB:
sp_configure [max server memory (MB)], 15500
reconfigure with override
go
It did not help much: it has 8MB available memory now. The server has
a lot of paging.
What is happening to the server?
Thanks.|||Performance monitor does not show processes that eat that much memory.
It does not show memory usage correctly with AWE enabled.
"Wayne Snyder" <wsnyder@.computeredservices.com> wrote in message news:<uZllf7BuDHA.3536@.tk2msftngp13.phx.gbl>...
> You should run Windows performance monitor and see who is using the
> memory... It is in the processes section...
>
> "Roust_m" <roustam@.hotbox.ru> wrote in message
> news:a388fd78.0312010553.2bf2d450@.posting.google.com...
> > Hi!
> >
> > I am running MS SQL 2000 Ent sp3 + MS Windows 2000 Datacenter on a
> > server with 16Gb memory. Total available memory is typically ~200MB
> > and pretty stable. I use Max Server Memory of 15700MB. Today I could
> > see a very unusual behavior: the available memory gone from 200MB to
> > 4MB in few seconds. I decreased the Max Server Memory by 200MB:
> >
> > sp_configure [max server memory (MB)], 15500
> > reconfigure with override
> > go
> >
> > It did not help much: it has 8MB available memory now. The server has
> > a lot of paging.
> >
> > What is happening to the server?
> >
> > Thanks.|||It did work fine for 3 months with 200MB available memory.
This article:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;274750
states that you need 1GB for OS only if you have 32+GB RAM:
"When you allocate SQL Server AWE memory on a 32 GB system, Windows
2000 may require at least 1 GB memory to manage AWE. "
As for /3G switch, I also seen an article stating that you need it for
up to 16GB RAM.
Anyway it did work fine...
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message news:<OFS92FEuDHA.3436@.tk2msftngp13.phx.gbl>...
> AWE memory is not dynamic so changing max server memory won't have any
> effect until you restart the service. You really need to leave more room for
> the OS, try setting max server memory to 14 GB and monitoring its stability.
> Also make sure the /3GB switch is not in boot.ini - just use the /PAE
> switch. There is a fair bit of OS overhead in managing AWE memory so you
> need to give the OS room to breathe.
> --
> HTH
> Jasper Smith (SQL Server MVP)
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "Roust_m" <roustam@.hotbox.ru> wrote in message
> news:a388fd78.0312010553.2bf2d450@.posting.google.com...
> Hi!
> I am running MS SQL 2000 Ent sp3 + MS Windows 2000 Datacenter on a
> server with 16Gb memory. Total available memory is typically ~200MB
> and pretty stable. I use Max Server Memory of 15700MB. Today I could
> see a very unusual behavior: the available memory gone from 200MB to
> 4MB in few seconds. I decreased the Max Server Memory by 200MB:
> sp_configure [max server memory (MB)], 15500
> reconfigure with override
> go
> It did not help much: it has 8MB available memory now. The server has
> a lot of paging.
> What is happening to the server?
> Thanks.|||Windows 2000 Datacenter Server Does Not Locate Memory Greater Than 16 GB
http://support.microsoft.com/default.aspx?scid=kb;EN-US;292934
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message news:<OFS92FEuDHA.3436@.tk2msftngp13.phx.gbl>...
> AWE memory is not dynamic so changing max server memory won't have any
> effect until you restart the service. You really need to leave more room for
> the OS, try setting max server memory to 14 GB and monitoring its stability.
> Also make sure the /3GB switch is not in boot.ini - just use the /PAE
> switch. There is a fair bit of OS overhead in managing AWE memory so you
> need to give the OS room to breathe.
> --
> HTH
> Jasper Smith (SQL Server MVP)
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "Roust_m" <roustam@.hotbox.ru> wrote in message
> news:a388fd78.0312010553.2bf2d450@.posting.google.com...
> Hi!
> I am running MS SQL 2000 Ent sp3 + MS Windows 2000 Datacenter on a
> server with 16Gb memory. Total available memory is typically ~200MB
> and pretty stable. I use Max Server Memory of 15700MB. Today I could
> see a very unusual behavior: the available memory gone from 200MB to
> 4MB in few seconds. I decreased the Max Server Memory by 200MB:
> sp_configure [max server memory (MB)], 15500
> reconfigure with override
> go
> It did not help much: it has 8MB available memory now. The server has
> a lot of paging.
> What is happening to the server?
> Thanks.
Subscribe to:
Posts (Atom)