2017-07-28 51 views
0

並請在將此標記爲重複之前,我已閱讀此帖多次,多次the first thing that always pops up in google,但我不認爲它解決了我的問題。SQL Server 2008 R2 - convert()工作,但鑄造()不 - 任何建議?

在通過ODBC到SQL Server 2008 R2傳遞查詢...

這不作品:

(SELECT x, convert(date, y) FROM so_q1); 

但這不起作用:

(SELECT x, (cast y as date) FROM so_q1); 

知道爲什麼?

+9

'(投Ÿ如日期)'?你的意思是'鑄(y作爲日期)' - 如果那不是它請分享錯誤細節。 –

+0

@ AlexK.-/snort - 謝謝 - 它不起作用,因爲它是不正確的語法。 – RichardAdams

回答

3
(SELECT x, (cast y as date) FROM so_q1);-- does not work because it is the incorrect syntax. 

(SELECT x, cast(y as date) FROM so_q1); --works just fine. 

謝謝@AlexK