今天遇到了一個奇怪的問題。始終沒搞清楚是怎麼回事。先記一下函數
一、首先有張表a,包含字段 編號、日期(varchar(250)),數值spa
發生日期字段有非正常日期字符串,有NULL,空字符串,多是誤觸鍵盤致使的錄入的數字。code
使用語句查詢得出結果。blog
SELECT FID , FGrossBalanceTime1 , Fweight FROM a WHERE FID IN (243423,99188)
二、準備過濾掉異常時間數據字符串
增長了檢索條件過濾掉爲NULL,空字符串和非日期格式class
SELECT FID , FGrossBalanceTime1 , Fweight FROM a WHERE 1 = 1 AND FID IN (243423,99188) AND FGrossBalanceTime1 IS NOT NULL AND FGrossBalanceTime1 <> '' AND ISDATE(FGrossBalanceTime1) = 1
三、取指定時間內的數據date
SELECT FID , FGrossBalanceTime1 , Fweight FROM a WHERE 1 = 1 AND FID IN (243423,99188) AND FGrossBalanceTime1 IS NOT NULL AND FGrossBalanceTime1 <> '' AND ISDATE(FGrossBalanceTime1) = 1 AND FGrossBalanceTime1 <= GETDATE()
黑人問號im
將FID IN 中去掉243423這條數據後執行正常。。。數據
彷佛是isdate函數是最後執行致使的問題?查詢