本文介绍了如何在不丢失数据的情况下更改表中的数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,专家, 我的桌子上有1000条记录. 表名称:stores(store_id(int),start_date(datetime),end_date(smalldatetime)) 现在我想将start_date的数据类型从datetime更改为smalldatetime,而不丢失现有数据. 谁能为我提供脚本. 在此先感谢.
Hi Experts, I have table having 1000 records. Table name : stores( store_id(int),start_date(datetime), end_date(smalldatetime)) now i want to change the data type of start_date from datetime to smalldatetime without loosing existing data. Can anyone please provide me script for it. Thanks in Advance.
推荐答案ALTER TABLE [dbo].[stores] Alter Column [start_date] [smalldatetime] GO
试试吧.
Try this.
您可以轻松地将数据类型从smalldatetime更改为datetime.他们没有数据丢失 因为datetime比smalldatetime更大的数据类型. 如果您的sql不授予权限,则必须创建datetime的新列,并在该列中处理数据,然后可以删除空列. You can change data type from smalldatetime to datetime easily. their no data lose because datetime is bigger datatype than smalldatetime. if your sql not give permission then you must create new column of datetime, data cope in that column and then you can delete empty column.
更多推荐
如何在不丢失数据的情况下更改表中的数据类型?
发布评论