a little help with an ALTER TABLE statement, please

a little help with an ALTER TABLE statement, please

Post by odmon » Thu, 06 Dec 2001 23:07:53



I am trying to write an Alter table statment that will change the mask

I have:

ALTER TABLE [tblName]      
Modify [clmName] to [clmName] format 999.9;

Something is wrong....  I'm kind of new to this.  Could any help me
with the correct syntax?

thanks,
ori

 
 
 

a little help with an ALTER TABLE statement, please

Post by Ross Neilso » Thu, 06 Dec 2001 23:55:24


Ori,

I would suggest checking out ALTER TABLE in Books Online, however something
like this may be what you need:

ALTER TABLE <TblName> ALTER COLUMN <ClmName> VARCHAR(5) NOT NULL
CONSTRAINT <ConName> CHECK <ClmName> LIKE '[0-9][0-9][0-9].[0-9]'

I am assuming you want three digits, then a decimal point, then another
digit. If not then change the LIKE clause to suit your needs. The syntax
might not be spot on so I suggest you read up in BOL.

HTH,

Ross Neilson
System Administrator
National Kidney Research Fund

 
 
 

1. multiple ALTER COLUMNs in one ALTER TABLE statement?

Hello,

I am afraid the answer is no but is there a way to do something like this:

ALTER TABLE mytable
    ALTER COLUMN col1 int,
    col2 float

I am taking a database that has been created by an upsizing wizard from
Visual FoxPro and all the numerics are set to float in SQL Server and I want
to use varchar on longer text fields (I'll ask about that in another post).
since many of the tables have 10 or more fields that need changing I just
used Enterprise Manager to Generate SQL for the database and used my text
editor to change the column values and change from CREATE to ALTER.

What I have now is a script with a lot of ALTER TABLEs that look like the
above but Query Analyzer is not liking it.

Thanks, Tom

2. Calling Corba Servers through Transact-SQL code

3. Alter ALTER TABLE statement ...

4. can we restrict a user from executing a stored procedure

5. scripting problem - ALTER statements are before the create table statements

6. info on FoxPro

7. Help using a variable in the ALTER TABLE SQL statement

8. Handling special characters ($,{,}) with DAO and ODBC

9. Help with ALTER TABLE Please

10. Alter Table help needed please.

11. How to Alter tables with ARRAY? Help PLease

12. Help with Alter Table Alter Column