Showing posts with label changing. Show all posts
Showing posts with label changing. Show all posts

Saturday, February 25, 2012

Question on changing startup parameters

I'm new to SQL Server...running SQL Server 2000. Had to move the system database logs to a different drive. Used EM, Server properties, Startup parameters. Changed the transaction log designation. Closed that window. Stopped the server.

Server won't start as I messed up and did not include the file name in the new designated path...just down to directory level.

From what I've seen, I have to be able to start the server service to change the parameters and the server won't start.

Is there a file that contains these parameters I may edit or should I try using the command line options.

Many thanks in advance.Was able to do a reg edit on the parameters and have it running.|||You can also start it from a command line with parameters.

sqlservr [-sinstance_name] [-c] [-dmaster_path] [-f]
[-eerror_log_path] [-lmaster_log_path] [-m]
[-n] [-Ttrace#] [-v] [-x] [-g number] [-O] [-y number]

Look at SQL BOL for the complete reference. It's a handy thing to know at 2:00am.

Regards,

hmscott|||I'm new to SQL Server...running SQL Server 2000. Had to move the system database logs to a different drive. Used EM, Server properties, Startup parameters. Changed the transaction log designation. Closed that window. Stopped the server.

Server won't start as I messed up and did not include the file name in the new designated path...just down to directory level.

From what I've seen, I have to be able to start the server service to change the parameters and the server won't start.

Is there a file that contains these parameters I may edit or should I try using the command line options.

Many thanks in advance.
Just a note: sometimes the paramters, when used in conjunction with other parameters, will act in an unpredicatable way. use google for more info|||just another reason to script everything.|||just another reason to script everything.
a real reason to script everything? all these sex ads (http://www.napstergirl.com) floating around the internets. I once thought that it was cool, but think of all the space this is wasting? anyway, this one ad kinda made sense to show cause look at the website: it is so advanced and could be used for other things

question on changing recovery model on DB

Hi,
I've got several production DBs that I want to change the recovery model
on from simple to full. Are there any caveats I need to be aware of in
making this change? Or is it just a matter of selecting the 'Full' recovery
model under the 'Options' tab of the DBs Properties and hitting the 'OK'
button? Thanks.
Make sure you set up log backup jobs for the databases to prevent the log
file sizes getting out of hand.
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"mb" <mb@.discussions.microsoft.com> wrote in message
news:2547FAF9-8BB6-407C-AFCA-E5D2F9082EB0@.microsoft.com...
> Hi,
> I've got several production DBs that I want to change the recovery model
> on from simple to full. Are there any caveats I need to be aware of in
> making this change? Or is it just a matter of selecting the 'Full'
> recovery
> model under the 'Options' tab of the DBs Properties and hitting the 'OK'
> button? Thanks.
|||mb wrote:
> Hi,
> I've got several production DBs that I want to change the recovery
> model on from simple to full. Are there any caveats I need to be
> aware of in making this change? Or is it just a matter of selecting
> the 'Full' recovery model under the 'Options' tab of the DBs
> Properties and hitting the 'OK' button? Thanks.
You must immediately perform a Full Backup or your t-logs will still get
truncated every checkpoint.
David Gugick
Quest Software
www.imceda.com
www.quest.com
|||Hi,
Once you change your database from SIMPLE to FULL recovery model, you need
to recreate your backup chain by doing:-
1. A Full databaase backup
2. Schedule a transaction log backup frequently
In FULL recovery you need to perform the log backup, this will be helpful to
recover the database point-in-time as
well as help you to keep your LDF file size in control.
Have a look into Recovery model topic in books online for more detail.
Thanks
Hari
SQL SERVER MVP
"mb" <mb@.discussions.microsoft.com> wrote in message
news:2547FAF9-8BB6-407C-AFCA-E5D2F9082EB0@.microsoft.com...
> Hi,
> I've got several production DBs that I want to change the recovery model
> on from simple to full. Are there any caveats I need to be aware of in
> making this change? Or is it just a matter of selecting the 'Full'
> recovery
> model under the 'Options' tab of the DBs Properties and hitting the 'OK'
> button? Thanks.

question on changing recovery model on DB

Hi,
I've got several production DBs that I want to change the recovery model
on from simple to full. Are there any caveats I need to be aware of in
making this change? Or is it just a matter of selecting the 'Full' recovery
model under the 'Options' tab of the DBs Properties and hitting the 'OK'
button? Thanks.Make sure you set up log backup jobs for the databases to prevent the log
file sizes getting out of hand.
--
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"mb" <mb@.discussions.microsoft.com> wrote in message
news:2547FAF9-8BB6-407C-AFCA-E5D2F9082EB0@.microsoft.com...
> Hi,
> I've got several production DBs that I want to change the recovery model
> on from simple to full. Are there any caveats I need to be aware of in
> making this change? Or is it just a matter of selecting the 'Full'
> recovery
> model under the 'Options' tab of the DBs Properties and hitting the 'OK'
> button? Thanks.|||mb wrote:
> Hi,
> I've got several production DBs that I want to change the recovery
> model on from simple to full. Are there any caveats I need to be
> aware of in making this change? Or is it just a matter of selecting
> the 'Full' recovery model under the 'Options' tab of the DBs
> Properties and hitting the 'OK' button? Thanks.
You must immediately perform a Full Backup or your t-logs will still get
truncated every checkpoint.
--
David Gugick
Quest Software
www.imceda.com
www.quest.com|||Hi,
Once you change your database from SIMPLE to FULL recovery model, you need
to recreate your backup chain by doing:-
1. A Full databaase backup
2. Schedule a transaction log backup frequently
In FULL recovery you need to perform the log backup, this will be helpful to
recover the database point-in-time as
well as help you to keep your LDF file size in control.
Have a look into Recovery model topic in books online for more detail.
Thanks
Hari
SQL SERVER MVP
"mb" <mb@.discussions.microsoft.com> wrote in message
news:2547FAF9-8BB6-407C-AFCA-E5D2F9082EB0@.microsoft.com...
> Hi,
> I've got several production DBs that I want to change the recovery model
> on from simple to full. Are there any caveats I need to be aware of in
> making this change? Or is it just a matter of selecting the 'Full'
> recovery
> model under the 'Options' tab of the DBs Properties and hitting the 'OK'
> button? Thanks.

question on changing recovery model on DB

Hi,
I've got several production DBs that I want to change the recovery model
on from simple to full. Are there any caveats I need to be aware of in
making this change? Or is it just a matter of selecting the 'Full' recovery
model under the 'Options' tab of the DBs Properties and hitting the 'OK'
button? Thanks.Make sure you set up log backup jobs for the databases to prevent the log
file sizes getting out of hand.
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"mb" <mb@.discussions.microsoft.com> wrote in message
news:2547FAF9-8BB6-407C-AFCA-E5D2F9082EB0@.microsoft.com...
> Hi,
> I've got several production DBs that I want to change the recovery model
> on from simple to full. Are there any caveats I need to be aware of in
> making this change? Or is it just a matter of selecting the 'Full'
> recovery
> model under the 'Options' tab of the DBs Properties and hitting the 'OK'
> button? Thanks.|||mb wrote:
> Hi,
> I've got several production DBs that I want to change the recovery
> model on from simple to full. Are there any caveats I need to be
> aware of in making this change? Or is it just a matter of selecting
> the 'Full' recovery model under the 'Options' tab of the DBs
> Properties and hitting the 'OK' button? Thanks.
You must immediately perform a Full Backup or your t-logs will still get
truncated every checkpoint.
David Gugick
Quest Software
www.imceda.com
www.quest.com|||Hi,
Once you change your database from SIMPLE to FULL recovery model, you need
to recreate your backup chain by doing:-
1. A Full databaase backup
2. Schedule a transaction log backup frequently
In FULL recovery you need to perform the log backup, this will be helpful to
recover the database point-in-time as
well as help you to keep your LDF file size in control.
Have a look into Recovery model topic in books online for more detail.
Thanks
Hari
SQL SERVER MVP
"mb" <mb@.discussions.microsoft.com> wrote in message
news:2547FAF9-8BB6-407C-AFCA-E5D2F9082EB0@.microsoft.com...
> Hi,
> I've got several production DBs that I want to change the recovery model
> on from simple to full. Are there any caveats I need to be aware of in
> making this change? Or is it just a matter of selecting the 'Full'
> recovery
> model under the 'Options' tab of the DBs Properties and hitting the 'OK'
> button? Thanks.

Question on Changing Jobs in SQL Server 2000

We have a bunch of databases on this SQL Server 2000 and for each
database we pretty much have the same kind of job running daily and
weekly. We are running out of disk space where we used to normally
backup the databases so we now have a new drive which will be used only
for backups so I need to change all my jobs to backup the databases to
the new drive. I can do that manually by going into each job to change
the drive path, but I was wondering if there was a way to update the
system table so that I did not have to manually change all my jobs.
Any help, ideas in this regard will be greatly appreciated.
ThanksHi
This is where having devices would make the task easier! But you can script
the jobs from Enterprise manager and then globally edit the file created.
John
"shub" wrote:

> We have a bunch of databases on this SQL Server 2000 and for each
> database we pretty much have the same kind of job running daily and
> weekly. We are running out of disk space where we used to normally
> backup the databases so we now have a new drive which will be used only
> for backups so I need to change all my jobs to backup the databases to
> the new drive. I can do that manually by going into each job to change
> the drive path, but I was wondering if there was a way to update the
> system table so that I did not have to manually change all my jobs.
> Any help, ideas in this regard will be greatly appreciated.
> Thanks
>|||John
Thanks for your response. Wouldnt the script drop the existing job and
create a brand new one which would cause me to lose all my job history?
Is there a way to get around that?
Thanks|||Hi
Yes it would, the jobs would have different Ids when re-created so you would
have to export everything before doing the scripting. Another reason for
using devices.
John
"shub" wrote:

> John
> Thanks for your response. Wouldnt the script drop the existing job and
> create a brand new one which would cause me to lose all my job history?
> Is there a way to get around that?
> Thanks
>|||John,
If we had devices in place would't we still need to change tha path off
all the devices that we set up for all the different databases? Also
can you set up devices if the physical location of the back up files
are in different computers in the network, basically does it support
UNC? I will look it up myself, but I would sure appreciate your input
as well.
Thanks again|||Hi
If you need to change the job to make it use a device it will not change the
problems of loosing the history, only make it more flexible in the future.
You should only be keeping a certain amount of history as this information
will bloat your msdb, if you need to retain this for a prolonged period then
you may want to put into place a system that will copy it elsewhere.
Devices can use UNC paths, there is an example of sp_adddumpdevice in books
online that shows exactly this. If you are backing up to another machine it
is worth considering a dedicated (1GB) subnet and adding extra cards to
improve performance.
John
"shub" wrote:

> John,
> If we had devices in place would't we still need to change tha path off
> all the devices that we set up for all the different databases? Also
> can you set up devices if the physical location of the back up files
> are in different computers in the network, basically does it support
> UNC? I will look it up myself, but I would sure appreciate your input
> as well.
> Thanks again
>|||I believe when all our jobs were created originally they were all
created by The maintenance plan wizard and I don't see you have an
option of backing up databases to devices.
Maybe in the near future we need to look at redoing all our jobs to use
the devices.
Thank you for all your help.

Question on Changing Jobs in SQL Server 2000

We have a bunch of databases on this SQL Server 2000 and for each
database we pretty much have the same kind of job running daily and
weekly. We are running out of disk space where we used to normally
backup the databases so we now have a new drive which will be used only
for backups so I need to change all my jobs to backup the databases to
the new drive. I can do that manually by going into each job to change
the drive path, but I was wondering if there was a way to update the
system table so that I did not have to manually change all my jobs.
Any help, ideas in this regard will be greatly appreciated.
ThanksHi
This is where having devices would make the task easier! But you can script
the jobs from Enterprise manager and then globally edit the file created.
John
"shub" wrote:
> We have a bunch of databases on this SQL Server 2000 and for each
> database we pretty much have the same kind of job running daily and
> weekly. We are running out of disk space where we used to normally
> backup the databases so we now have a new drive which will be used only
> for backups so I need to change all my jobs to backup the databases to
> the new drive. I can do that manually by going into each job to change
> the drive path, but I was wondering if there was a way to update the
> system table so that I did not have to manually change all my jobs.
> Any help, ideas in this regard will be greatly appreciated.
> Thanks
>|||John
Thanks for your response. Wouldnt the script drop the existing job and
create a brand new one which would cause me to lose all my job history?
Is there a way to get around that?
Thanks|||Hi
Yes it would, the jobs would have different Ids when re-created so you would
have to export everything before doing the scripting. Another reason for
using devices.
John
"shub" wrote:
> John
> Thanks for your response. Wouldnt the script drop the existing job and
> create a brand new one which would cause me to lose all my job history?
> Is there a way to get around that?
> Thanks
>|||John,
If we had devices in place would't we still need to change tha path off
all the devices that we set up for all the different databases? Also
can you set up devices if the physical location of the back up files
are in different computers in the network, basically does it support
UNC? I will look it up myself, but I would sure appreciate your input
as well.
Thanks again|||Hi
If you need to change the job to make it use a device it will not change the
problems of loosing the history, only make it more flexible in the future.
You should only be keeping a certain amount of history as this information
will bloat your msdb, if you need to retain this for a prolonged period then
you may want to put into place a system that will copy it elsewhere.
Devices can use UNC paths, there is an example of sp_adddumpdevice in books
online that shows exactly this. If you are backing up to another machine it
is worth considering a dedicated (1GB) subnet and adding extra cards to
improve performance.
John
"shub" wrote:
> John,
> If we had devices in place would't we still need to change tha path off
> all the devices that we set up for all the different databases? Also
> can you set up devices if the physical location of the back up files
> are in different computers in the network, basically does it support
> UNC? I will look it up myself, but I would sure appreciate your input
> as well.
> Thanks again
>|||I believe when all our jobs were created originally they were all
created by The maintenance plan wizard and I don't see you have an
option of backing up databases to devices.
Maybe in the near future we need to look at redoing all our jobs to use
the devices.
Thank you for all your help.

Question on changing data types on a table

Hi Guys,
I have always wondered what SQL Server actually does when I try to change
the data type on any column in a table. I know that SQL Server will rebuild
the whole table when its changing the data type, so if I had multiple columns
that I wanted to change data types for, this is the only way I have been able
to do it using TSQL:
ALTER TABLE TEST
ALTER COLUMN A (char(4))
ALTER TABLE TEST
ALTER COLUMN B (INT)
ALTER TABLE TEST
ALTER COLUMN C (FLOAT)
Does the above mean that SQL Server has to rebuild my table 3 different
times? How could I rewrite this code so that SQL Server can convert all my
columns with one rebuild? Thanks guys!well! u dont have that flexibility :(
u can add multiple columns using ALTER
--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
---
"Shishir Viriyala" wrote:
> Hi Guys,
> I have always wondered what SQL Server actually does when I try to change
> the data type on any column in a table. I know that SQL Server will rebuild
> the whole table when its changing the data type, so if I had multiple columns
> that I wanted to change data types for, this is the only way I have been able
> to do it using TSQL:
> ALTER TABLE TEST
> ALTER COLUMN A (char(4))
> ALTER TABLE TEST
> ALTER COLUMN B (INT)
> ALTER TABLE TEST
> ALTER COLUMN C (FLOAT)
> Does the above mean that SQL Server has to rebuild my table 3 different
> times? How could I rewrite this code so that SQL Server can convert all my
> columns with one rebuild? Thanks guys!
>|||Okay, how about doing it in Enterprise Manager's Design Table section? I can
see all the columns with their data types at once... if I changed multiple
data types there, does SQL Server rebuild the table for each column, or does
do everything in one shot? Appreciate the help!
"Chandra" wrote:
> well! u dont have that flexibility :(
> u can add multiple columns using ALTER
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://groups.msn.com/SQLResource/
> ---
>
> "Shishir Viriyala" wrote:
> > Hi Guys,
> >
> > I have always wondered what SQL Server actually does when I try to change
> > the data type on any column in a table. I know that SQL Server will rebuild
> > the whole table when its changing the data type, so if I had multiple columns
> > that I wanted to change data types for, this is the only way I have been able
> > to do it using TSQL:
> >
> > ALTER TABLE TEST
> > ALTER COLUMN A (char(4))
> >
> > ALTER TABLE TEST
> > ALTER COLUMN B (INT)
> >
> > ALTER TABLE TEST
> > ALTER COLUMN C (FLOAT)
> >
> > Does the above mean that SQL Server has to rebuild my table 3 different
> > times? How could I rewrite this code so that SQL Server can convert all my
> > columns with one rebuild? Thanks guys!
> >|||it rebuilds for each column.
--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
---
"Shishir Viriyala" wrote:
> Okay, how about doing it in Enterprise Manager's Design Table section? I can
> see all the columns with their data types at once... if I changed multiple
> data types there, does SQL Server rebuild the table for each column, or does
> do everything in one shot? Appreciate the help!
> "Chandra" wrote:
> > well! u dont have that flexibility :(
> > u can add multiple columns using ALTER
> >
> > --
> > best Regards,
> > Chandra
> > http://chanduas.blogspot.com/
> > http://groups.msn.com/SQLResource/
> > ---
> >
> >
> >
> > "Shishir Viriyala" wrote:
> >
> > > Hi Guys,
> > >
> > > I have always wondered what SQL Server actually does when I try to change
> > > the data type on any column in a table. I know that SQL Server will rebuild
> > > the whole table when its changing the data type, so if I had multiple columns
> > > that I wanted to change data types for, this is the only way I have been able
> > > to do it using TSQL:
> > >
> > > ALTER TABLE TEST
> > > ALTER COLUMN A (char(4))
> > >
> > > ALTER TABLE TEST
> > > ALTER COLUMN B (INT)
> > >
> > > ALTER TABLE TEST
> > > ALTER COLUMN C (FLOAT)
> > >
> > > Does the above mean that SQL Server has to rebuild my table 3 different
> > > times? How could I rewrite this code so that SQL Server can convert all my
> > > columns with one rebuild? Thanks guys!
> > >|||Check and see :-). Press the "save change script" button and you will see the SQL that EM is about
to execute.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Shishir Viriyala" <ShishirViriyala@.discussions.microsoft.com> wrote in message
news:F183A811-5BBF-4BA0-9E6D-BE671FDB8837@.microsoft.com...
> Okay, how about doing it in Enterprise Manager's Design Table section? I can
> see all the columns with their data types at once... if I changed multiple
> data types there, does SQL Server rebuild the table for each column, or does
> do everything in one shot? Appreciate the help!
> "Chandra" wrote:
>> well! u dont have that flexibility :(
>> u can add multiple columns using ALTER
>> --
>> best Regards,
>> Chandra
>> http://chanduas.blogspot.com/
>> http://groups.msn.com/SQLResource/
>> ---
>>
>> "Shishir Viriyala" wrote:
>> > Hi Guys,
>> >
>> > I have always wondered what SQL Server actually does when I try to change
>> > the data type on any column in a table. I know that SQL Server will rebuild
>> > the whole table when its changing the data type, so if I had multiple columns
>> > that I wanted to change data types for, this is the only way I have been able
>> > to do it using TSQL:
>> >
>> > ALTER TABLE TEST
>> > ALTER COLUMN A (char(4))
>> >
>> > ALTER TABLE TEST
>> > ALTER COLUMN B (INT)
>> >
>> > ALTER TABLE TEST
>> > ALTER COLUMN C (FLOAT)
>> >
>> > Does the above mean that SQL Server has to rebuild my table 3 different
>> > times? How could I rewrite this code so that SQL Server can convert all my
>> > columns with one rebuild? Thanks guys!
>> >|||Aha! Thanks for the tip Tibor! I have included what the change script was
showing me. The two columns for which I changed data types were CASEID and
DX. Note that both those columns are being converted in one statement.
Using EP is definitely the way to go!
Thanks to you and Chandra for the input......
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
CREATE TABLE dbo.Tmp_ip_adm_dx
(
CASEID int NULL,
DX varchar(5) NULL,
DXNO int NOT NULL
) ON [PRIMARY]
GO
IF EXISTS(SELECT * FROM dbo.ip_adm_dx)
EXEC('INSERT INTO dbo.Tmp_ip_adm_dx (CASEID, DX, DXNO)
SELECT CONVERT(int, CASEID), CONVERT(varchar(5), DX), DXNO FROM
dbo.ip_adm_dx TABLOCKX')
GO
DROP TABLE dbo.ip_adm_dx
GO
EXECUTE sp_rename N'dbo.Tmp_ip_adm_dx', N'ip_adm_dx', 'OBJECT'
GO
COMMIT
"Tibor Karaszi" wrote:
> Check and see :-). Press the "save change script" button and you will see the SQL that EM is about
> to execute.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Shishir Viriyala" <ShishirViriyala@.discussions.microsoft.com> wrote in message
> news:F183A811-5BBF-4BA0-9E6D-BE671FDB8837@.microsoft.com...
> > Okay, how about doing it in Enterprise Manager's Design Table section? I can
> > see all the columns with their data types at once... if I changed multiple
> > data types there, does SQL Server rebuild the table for each column, or does
> > do everything in one shot? Appreciate the help!
> >
> > "Chandra" wrote:
> >
> >> well! u dont have that flexibility :(
> >> u can add multiple columns using ALTER
> >>
> >> --
> >> best Regards,
> >> Chandra
> >> http://chanduas.blogspot.com/
> >> http://groups.msn.com/SQLResource/
> >> ---
> >>
> >>
> >>
> >> "Shishir Viriyala" wrote:
> >>
> >> > Hi Guys,
> >> >
> >> > I have always wondered what SQL Server actually does when I try to change
> >> > the data type on any column in a table. I know that SQL Server will rebuild
> >> > the whole table when its changing the data type, so if I had multiple columns
> >> > that I wanted to change data types for, this is the only way I have been able
> >> > to do it using TSQL:
> >> >
> >> > ALTER TABLE TEST
> >> > ALTER COLUMN A (char(4))
> >> >
> >> > ALTER TABLE TEST
> >> > ALTER COLUMN B (INT)
> >> >
> >> > ALTER TABLE TEST
> >> > ALTER COLUMN C (FLOAT)
> >> >
> >> > Does the above mean that SQL Server has to rebuild my table 3 different
> >> > times? How could I rewrite this code so that SQL Server can convert all my
> >> > columns with one rebuild? Thanks guys!
> >> >
>|||On Fri, 5 Aug 2005 08:15:38 -0700, Shishir Viriyala wrote:
>Okay, how about doing it in Enterprise Manager's Design Table section? I can
>see all the columns with their data types at once... if I changed multiple
>data types there, does SQL Server rebuild the table for each column, or does
>do everything in one shot? Appreciate the help!
Hi Shishir,
Neither. Enterprise Manager will simply create a new table, copy over
the data, then drop the old table. If the table is involved in any
foreign key relationships, it will drop and recreate them as well. And
if the table has any triggers, they too will be recreated.
Copying the data over to a new table might be the best strategy in your
specific case, but in general, the methods chosen by EM to apply changes
tend to be overkill. (And very slow on large tables!)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

Question on changing data types on a table

Hi Guys,
I have always wondered what SQL Server actually does when I try to change
the data type on any column in a table. I know that SQL Server will rebuild
the whole table when its changing the data type, so if I had multiple column
s
that I wanted to change data types for, this is the only way I have been abl
e
to do it using TSQL:
ALTER TABLE TEST
ALTER COLUMN A (char(4))
ALTER TABLE TEST
ALTER COLUMN B (INT)
ALTER TABLE TEST
ALTER COLUMN C (FLOAT)
Does the above mean that SQL Server has to rebuild my table 3 different
times? How could I rewrite this code so that SQL Server can convert all my
columns with one rebuild? Thanks guys!well! u dont have that flexibility
u can add multiple columns using ALTER
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
---
"Shishir Viriyala" wrote:

> Hi Guys,
> I have always wondered what SQL Server actually does when I try to change
> the data type on any column in a table. I know that SQL Server will rebui
ld
> the whole table when its changing the data type, so if I had multiple colu
mns
> that I wanted to change data types for, this is the only way I have been a
ble
> to do it using TSQL:
> ALTER TABLE TEST
> ALTER COLUMN A (char(4))
> ALTER TABLE TEST
> ALTER COLUMN B (INT)
> ALTER TABLE TEST
> ALTER COLUMN C (FLOAT)
> Does the above mean that SQL Server has to rebuild my table 3 different
> times? How could I rewrite this code so that SQL Server can convert all m
y
> columns with one rebuild? Thanks guys!
>|||Okay, how about doing it in Enterprise Manager's Design Table section? I ca
n
see all the columns with their data types at once... if I changed multiple
data types there, does SQL Server rebuild the table for each column, or does
do everything in one shot? Appreciate the help!
"Chandra" wrote:
[vbcol=seagreen]
> well! u dont have that flexibility
> u can add multiple columns using ALTER
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://groups.msn.com/SQLResource/
> ---
>
> "Shishir Viriyala" wrote:
>|||it rebuilds for each column.
--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
---
"Shishir Viriyala" wrote:
[vbcol=seagreen]
> Okay, how about doing it in Enterprise Manager's Design Table section? I
can
> see all the columns with their data types at once... if I changed multipl
e
> data types there, does SQL Server rebuild the table for each column, or do
es
> do everything in one shot? Appreciate the help!
> "Chandra" wrote:
>|||Check and see :-). Press the "save change script" button and you will see th
e SQL that EM is about
to execute.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Shishir Viriyala" <ShishirViriyala@.discussions.microsoft.com> wrote in mess
age
news:F183A811-5BBF-4BA0-9E6D-BE671FDB8837@.microsoft.com...[vbcol=seagreen]
> Okay, how about doing it in Enterprise Manager's Design Table section? I
can
> see all the columns with their data types at once... if I changed multipl
e
> data types there, does SQL Server rebuild the table for each column, or do
es
> do everything in one shot? Appreciate the help!
> "Chandra" wrote:
>|||Aha! Thanks for the tip Tibor! I have included what the change script was
showing me. The two columns for which I changed data types were CASEID and
DX. Note that both those columns are being converted in one statement.
Using EP is definitely the way to go!
Thanks to you and Chandra for the input......
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
CREATE TABLE dbo.Tmp_ip_adm_dx
(
CASEID int NULL,
DX varchar(5) NULL,
DXNO int NOT NULL
) ON [PRIMARY]
GO
IF EXISTS(SELECT * FROM dbo.ip_adm_dx)
EXEC('INSERT INTO dbo.Tmp_ip_adm_dx (CASEID, DX, DXNO)
SELECT CONVERT(int, CASEID), CONVERT(varchar(5), DX), DXNO FROM
dbo.ip_adm_dx TABLOCKX')
GO
DROP TABLE dbo.ip_adm_dx
GO
EXECUTE sp_rename N'dbo.Tmp_ip_adm_dx', N'ip_adm_dx', 'OBJECT'
GO
COMMIT
"Tibor Karaszi" wrote:

> Check and see :-). Press the "save change script" button and you will see
the SQL that EM is about
> to execute.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Shishir Viriyala" <ShishirViriyala@.discussions.microsoft.com> wrote in me
ssage
> news:F183A811-5BBF-4BA0-9E6D-BE671FDB8837@.microsoft.com...
>|||On Fri, 5 Aug 2005 08:15:38 -0700, Shishir Viriyala wrote:

>Okay, how about doing it in Enterprise Manager's Design Table section? I c
an
>see all the columns with their data types at once... if I changed multiple
>data types there, does SQL Server rebuild the table for each column, or doe
s
>do everything in one shot? Appreciate the help!
Hi Shishir,
Neither. Enterprise Manager will simply create a new table, copy over
the data, then drop the old table. If the table is involved in any
foreign key relationships, it will drop and recreate them as well. And
if the table has any triggers, they too will be recreated.
Copying the data over to a new table might be the best strategy in your
specific case, but in general, the methods chosen by EM to apply changes
tend to be overkill. (And very slow on large tables!)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

Question on changing data types on a table

Hi Guys,
I have always wondered what SQL Server actually does when I try to change
the data type on any column in a table. I know that SQL Server will rebuild
the whole table when its changing the data type, so if I had multiple columns
that I wanted to change data types for, this is the only way I have been able
to do it using TSQL:
ALTER TABLE TEST
ALTER COLUMN A (char(4))
ALTER TABLE TEST
ALTER COLUMN B (INT)
ALTER TABLE TEST
ALTER COLUMN C (FLOAT)
Does the above mean that SQL Server has to rebuild my table 3 different
times? How could I rewrite this code so that SQL Server can convert all my
columns with one rebuild? Thanks guys!
well! u dont have that flexibility
u can add multiple columns using ALTER
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
"Shishir Viriyala" wrote:

> Hi Guys,
> I have always wondered what SQL Server actually does when I try to change
> the data type on any column in a table. I know that SQL Server will rebuild
> the whole table when its changing the data type, so if I had multiple columns
> that I wanted to change data types for, this is the only way I have been able
> to do it using TSQL:
> ALTER TABLE TEST
> ALTER COLUMN A (char(4))
> ALTER TABLE TEST
> ALTER COLUMN B (INT)
> ALTER TABLE TEST
> ALTER COLUMN C (FLOAT)
> Does the above mean that SQL Server has to rebuild my table 3 different
> times? How could I rewrite this code so that SQL Server can convert all my
> columns with one rebuild? Thanks guys!
>
|||Okay, how about doing it in Enterprise Manager's Design Table section? I can
see all the columns with their data types at once... if I changed multiple
data types there, does SQL Server rebuild the table for each column, or does
do everything in one shot? Appreciate the help!
"Chandra" wrote:
[vbcol=seagreen]
> well! u dont have that flexibility
> u can add multiple columns using ALTER
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://groups.msn.com/SQLResource/
>
> "Shishir Viriyala" wrote:
|||it rebuilds for each column.
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
"Shishir Viriyala" wrote:
[vbcol=seagreen]
> Okay, how about doing it in Enterprise Manager's Design Table section? I can
> see all the columns with their data types at once... if I changed multiple
> data types there, does SQL Server rebuild the table for each column, or does
> do everything in one shot? Appreciate the help!
> "Chandra" wrote:
|||Check and see :-). Press the "save change script" button and you will see the SQL that EM is about
to execute.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Shishir Viriyala" <ShishirViriyala@.discussions.microsoft.com> wrote in message
news:F183A811-5BBF-4BA0-9E6D-BE671FDB8837@.microsoft.com...[vbcol=seagreen]
> Okay, how about doing it in Enterprise Manager's Design Table section? I can
> see all the columns with their data types at once... if I changed multiple
> data types there, does SQL Server rebuild the table for each column, or does
> do everything in one shot? Appreciate the help!
> "Chandra" wrote:
|||Aha! Thanks for the tip Tibor! I have included what the change script was
showing me. The two columns for which I changed data types were CASEID and
DX. Note that both those columns are being converted in one statement.
Using EP is definitely the way to go!
Thanks to you and Chandra for the input......
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
CREATE TABLE dbo.Tmp_ip_adm_dx
(
CASEID int NULL,
DX varchar(5) NULL,
DXNO int NOT NULL
) ON [PRIMARY]
GO
IF EXISTS(SELECT * FROM dbo.ip_adm_dx)
EXEC('INSERT INTO dbo.Tmp_ip_adm_dx (CASEID, DX, DXNO)
SELECT CONVERT(int, CASEID), CONVERT(varchar(5), DX), DXNO FROM
dbo.ip_adm_dx TABLOCKX')
GO
DROP TABLE dbo.ip_adm_dx
GO
EXECUTE sp_rename N'dbo.Tmp_ip_adm_dx', N'ip_adm_dx', 'OBJECT'
GO
COMMIT
"Tibor Karaszi" wrote:

> Check and see :-). Press the "save change script" button and you will see the SQL that EM is about
> to execute.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Shishir Viriyala" <ShishirViriyala@.discussions.microsoft.com> wrote in message
> news:F183A811-5BBF-4BA0-9E6D-BE671FDB8837@.microsoft.com...
>
|||On Fri, 5 Aug 2005 08:15:38 -0700, Shishir Viriyala wrote:

>Okay, how about doing it in Enterprise Manager's Design Table section? I can
>see all the columns with their data types at once... if I changed multiple
>data types there, does SQL Server rebuild the table for each column, or does
>do everything in one shot? Appreciate the help!
Hi Shishir,
Neither. Enterprise Manager will simply create a new table, copy over
the data, then drop the old table. If the table is involved in any
foreign key relationships, it will drop and recreate them as well. And
if the table has any triggers, they too will be recreated.
Copying the data over to a new table might be the best strategy in your
specific case, but in general, the methods chosen by EM to apply changes
tend to be overkill. (And very slow on large tables!)
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)