| Account_Open_Date |
|---|
| 19931122 |
| 20041102 |
所以我想將日期轉換為
| Account_Open_Date |
|---|
| 199311 |
| 200411 |
SELECT CAST(convert(varchar(6),a.Account_Open_Date,112) as int) FROM [tempdb].[dbo].[SQL Test Data] a WHERE Account_Open_Date is NOT NULL;
此選擇陳述句以我想要的方式提取日期,但我想將表格更新為相同的格式,并且很難更新。我沒有一個很好的例子來說明我嘗試過的事情。
update x.Account_Open_Date SET a.Account_Open_Date = CAST(convert(varchar(6),Account_Open_Date,112) as int) FROM ( [tempdb].[dbo].[SQL Test Data] ) x WHERE Account_Open_Date is NOT NULL;
uj5u.com熱心網友回復:
評論提出了很好的觀點。看到您在臨時表上執行此操作,我會假設您正在測驗并且不會深入研究提出的要點。
修復了您的更新宣告。你很親密。
update x
SET
x.Account_Open_Date = CAST(convert(varchar(6),Account_Open_Date,112) as int)
FROM
[tempdb].[dbo].[SQL Test Data] x
WHERE
Account_Open_Date is NOT NULL;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/411236.html
標籤:
上一篇:我可以在運算式switch案例中重新拋出現有例外嗎?
下一篇:執行存盤程序只列印最后一條記錄
