Sunday, February 26, 2012

Does Alter Column do work if column already the same as desired?

I have a table with a column defined thus: LOCNumber Varchar(100) in a
table called Bookdata.

If I execute ALTER TABLE BookData ALTER COLUMN LOCNumber varchar(100)
on the table, does any work get done on the table and column?
Or does SqlServer know that the column is already varchar(100) and
nothing
needs to be done?
If it does do some work, how do you tell it not to run this as it is
already a varchar(100) column. Right now my program just blindly does
this ALTER TABLE
statement regardless of any conditions. Is this a potential problem?
Thanks for any help.SQL 2000 only needs to update meta data when the new varchar column length
is >= the specified length. Consequently, you can skip the length check.

--
Hope this helps.

Dan Guzman
SQL Server MVP

<sdowney717@.msn.com> wrote in message
news:1107370345.836079.312700@.z14g2000cwz.googlegr oups.com...
>I have a table with a column defined thus: LOCNumber Varchar(100) in a
> table called Bookdata.
> If I execute ALTER TABLE BookData ALTER COLUMN LOCNumber varchar(100)
> on the table, does any work get done on the table and column?
> Or does SqlServer know that the column is already varchar(100) and
> nothing
> needs to be done?
> If it does do some work, how do you tell it not to run this as it is
> already a varchar(100) column. Right now my program just blindly does
> this ALTER TABLE
> statement regardless of any conditions. Is this a potential problem?
> Thanks for any help.|||Thanks
It is 2000, so everything is fine.

No comments:

Post a Comment