SQL修改日期類型字段為字符串類型


select * from test1
--添加行
ALTER TABLE test1 ADD startdate varchar(200)
--將轉換格式后的數據放到列中
update test1 set startdate1=CONVERT(varchar,startdate ,23)
--刪除老的字段
alter table test1 drop column startdate 
--修改字段名
execute sp_rename 'test1.startdate1','startdate '

 以上是將test1表中的startdate字段改為字符串字段,並不丟失數據。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM