Please see:
ALTER TABLE [dbo].[TestData] ALTER COLUMN [MakeID] varchar(100) NOT NULL;
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, I want to change dataType from int to varchar for columns MakeID,ModelID.vahicleTypeID
Reason is sometimes we get the data as string.
As this table is already in Production, we just need to modify the datatype of the columns. How easy is this doing without impacting much. Please advise
CREATE TABLE [dbo].[TestData](
[ID] [int] IDENTITY(1,1) NOT NULL,
[MakeID] [int] NOT NULL,
[ModelID] [int] NOT NULL,
[Model] varchar NOT NULL,
[VehicleTypeID] [int] NOT NULL,
[VehicleType] varchar NOT NULL,
[Year] [int] NOT NULL,
[CreatedDate] [datetime] NOT NULL,
[UpdatedDate] [datetime] NULL,
CONSTRAINT [PK_TestData] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY]
) ON [PRIMARY]
GO
Please see:
ALTER TABLE [dbo].[TestData] ALTER COLUMN [MakeID] varchar(100) NOT NULL;
If you are not sure whether the modification is correct, you can check the final data type with the following code:
select sql_variant_property(columnname,basetype) from tablename
If you have any question, please feel free to let me know.
If the response is helpful, please click "Accept Answer" and upvote it.
Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our [documentation][1] to enable e-mail notifications if you want to receive the related email notification for this thread.
Hot issues October--https://video2.skills-academy.com/en-us/answers/questions/142427/users-always-get-connection-timeout-problem-when-u.html