0

I have a database created in Microsoft SQL 2000 Enterprise Manager. I need to change the datatype for a column name EngrMultiplier in the table ProjectReCapParameter. The current datatype is INT and I would like to replace it to FLOAT. What should I do? Write a query or change the datatype in the table design view? How? Also which version of Visual Studio will be useful to modify the client user web form currently built with .NET Framework 1.1.4322? Please Advise me.

3
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by DanielGreen
0

You can do that with a simple query:

ALTER TABLE ProjectReCapParameter ALTER COLUMN EngrMultiplier float

Here is a full example using temporary tables:

IF OBJECT_ID('tempdb..#ProjectReCapParameter', 'U') IS NOT NULL DROP TABLE #ProjectReCapParameter
Create Table #ProjectReCapParameter
(
  EngrMultiplier int
)

Insert Into #ProjectReCapParameter (EngrMultiplier) Values (1)
Insert Into #ProjectReCapParameter (EngrMultiplier) Values (2)
Insert Into #ProjectReCapParameter (EngrMultiplier) Values (3)

GO

Select *
From #ProjectReCapParameter

GO

ALTER TABLE #ProjectReCapParameter ALTER COLUMN EngrMultiplier float

GO

Select *
From #ProjectReCapParameter
0

Thanks for quick reply.
I have tried the first option.
ALTER TABEL ProjectReCapParameter
ALTER COLUMN EngrMultiplier float
The result gives me the following errors:
(1)
Server: Msg 5074, Level 16, State 1, Line 1
The object 'DF_ ProjectReCapParameter_EngrMultiplier' is dependent on column 'EngrMultiplier'.
(2)
Server: Msg 4922, Level 16, State 1, Line 1
ALTER TABLE ALTER COLUMN EngrMultiplier failed because one or more object access this column.

I do not understand the second option you mentioned as
"Here is a full example using temporary tables:"

Also I tried to change other column datatype from FLOAT to INT (within the same table) and it works.

0

hi!

I don't know it exactly, but if the column "EngrMultiplier" is used as foreign-key (constraints) in other tables, this error can occure.
Be sure, that the column you want to modify is not used as foreign-key!

if column is a foreign-key, remove all constraints using this column, change datatype in ALL tables and finally you can add all contraints again.

Daniel

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.