我有一個簡單的表。SQL Server使用like關鍵字選擇DateTime
我想下火在此表上選擇查詢。
select *
from booking
where bookingdate like '%11%'
在輸出中我希望顯示兩個記錄。但是,令我驚訝的是隻顯示了表中的最高記錄。
這種行爲很奇怪。 like
關鍵字在DateTime
列的類型上是否無法正常運行?
編輯:
但是如果我試試這個(轉換DateTime
到Varchar
)
select *
from booking
where convert(varchar(50), BookingDate, 120) like '%11%'
它的作品!
什麼'DATETIME'在SQL Server是*** ***不存儲爲* *串**!它存儲爲一個8字節的二進制值 - 因此,你不能只使用'LIKE'對付它,顯然...... – 2014-11-22 20:26:47