Re: Alter table alter column

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Uri Dimant (urid_at_iscar.co.il)
Date: 03/09/04


Date: Tue, 9 Mar 2004 12:38:34 +0200

Hi
One more approach
DROP TABLE Table1
CREATE TABLE Table1
    (
    Col1 varchar(10) NOT NULL,
    CONSTRAINT PK_Table1 PRIMARY KEY (Col1)
    )
INSERT INTO Table1 VALUES('1')
GO

EXEC sp_rename 'Table1', 'Table1_Old'
GO
SELECT ISNULL(CAST(Col1 AS int), 0) AS Col1
    INTO Table1
    FROM Table1_Old
DROP TABLE Table1_Old
ALTER TABLE Table1
    ADD CONSTRAINT PK_Table1
    PRIMARY KEY (Col1)
GO
"khanhbui" <khanh@monterpoint.co.uk> wrote in message
news:edvQoCcBEHA.3796@TK2MSFTNGP10.phx.gbl...
> Hi All,
> I tried to use T-sql command alter table alter colum column_name to
change
> a column datatype (small int to int)
> It returned an error that some other objects using that column, I used the
> enterprise manager it's OK
> is there any tricks to alter a column without using Enterprise Manager ?
> Thanks in advance
>
>



Relevant Pages

  • replacing sp_MSinsTable1
    ... CREATE TABLE [Table1] ( ... CONSTRAINT PRIMARY KEY CLUSTERED ... The consolidated database looks like: ...
    (microsoft.public.sqlserver.replication)
  • Re: Subquery
    ... probably want a query that selects from, ... But if there is no row in table1 for a particular company_id, ... no col1 value, either. ... result using a left outer join. ...
    (microsoft.public.sqlserver.programming)
  • RE: inserting the max colum in the stored proc
    ... Inseret into table1 ( ... cost), or if col1 has a unique index, catch the duplicate key error and ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: simple stored procedure
    ... CREATE TABLE table1 (col1 int) ... INSERT INTO table1 VALUES ... CREATE TABLE table2 ...
    (microsoft.public.inetserver.asp.db)
  • RE: Problem with Where . . . . In clause
    ... > SELECT Col1 ... > FROM Table1 ... > Syntax error converting the nvarchar value '1,2,3' to a column of data type int. ... > Basically what I need to end up with is a SQL statement that looks like the following: ...
    (microsoft.public.sqlserver.programming)