Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在使用数据类型BirthDate的表中有一个列。datetime目前,这些值类似于 format 1987-12-30 00:00:00.000。
BirthDate
datetime
1987-12-30 00:00:00.000
我想更新该表的所有行,将它们更改为以下date数据类型的格式:1987-12-30
date
1987-12-30
我可以运行 SELECT ...
SELECT CONVERT(date, BirthDate) FROM CUSTOMERLIST
但这只是影响显示。我希望它更新整个列并更改该属性的数据类型。任何帮助将不胜感激!
您将需要到ALTER表:
ALTER
ALTER TABLE CUSTOMERLIST ALTER COLUMN BirthDate date not null
请参阅带有演示的 Sql Fiddle