久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

SQL Server - 比較存儲為字符串或 nvarchar 的日期或日

SQL Server - Compare dates or datetime stored as a string or nvarchar?(SQL Server - 比較存儲為字符串或 nvarchar 的日期或日期時間?)
本文介紹了SQL Server - 比較存儲為字符串或 nvarchar 的日期或日期時間?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我按照日期時間格式做了一個日期.但是,我將其作為字符串/nvarchar 而不是日期時間存儲在我的數據庫中.我能比較這些日期嗎?這是一種不好的做法嗎?

I made a date according to the datetime format. But, I stored this in my DB as a string/nvarchar and not a datetime. Will I be able to compare such dates ? Is this a bad practice ?

我現在使用 nvarchar 來存儲日期時間.

I am using nvarchar to store a datetime as of now.

推薦答案

是的,您仍然可以比較它們,但這肯定是一個不好的做法,因為您需要將此字符串轉換為日期數據類型才能進行比較它們之間.如果您在列上定義了索引,則它們將不再使用,因為該列將被轉換,并且會導致大型數據庫的性能下降.

Yes you can still be able to compare them but this is certainly a bad practice because you will need to convert this strings into dates data type to be able to compare between them. If you have indexes define on the column, they will not be used anymore since the column will be converted and it will cuase slow performance on large database.

比較日期的例子是這樣的:

An example on comparing dates is like this:

SELECT *
FROM   tableName
WHERE  CONVERT(DATETIME, dateSTRColumn, XXX) > GETDATE()

其中 XXX 是存儲為字符串的日期的當前格式.

where XXX is the current format of the date stored as string.

這篇關于SQL Server - 比較存儲為字符串或 nvarchar 的日期或日期時間?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Modify Existing decimal places info(修改現有小數位信息)
The correlation name #39;CONVERT#39; is specified multiple times(多次指定相關名稱“CONVERT)
T-SQL left join not returning null columns(T-SQL 左連接不返回空列)
remove duplicates from comma or pipeline operator string(從逗號或管道運算符字符串中刪除重復項)
Change an iterative query to a relational set-based query(將迭代查詢更改為基于關系集的查詢)
concatenate a zero onto sql server select value shows 4 digits still and not 5(將零連接到 sql server 選擇值仍然顯示 4 位而不是 5)
主站蜘蛛池模板: 黄色a网站 | 美女免费视频网站 | 人人爽av | 91激情网| 天天操天天拍 | 久久免费精品 | 欧美日韩精品一区 | 欧美三级三级三级爽爽爽 | 亚洲综合激情网 | 欧美高清一区二区 | 中文字幕亚洲一区 | 韩国理论在线 | 日韩精品视频免费播放 | 长河落日电视连续剧免费观看 | 91激情网 | 国产永久免费视频 | 成人毛片在线观看 | 国产午夜视频 | 亚洲国产日本 | 国产精品成人免费视频 | 色综合久久88 | 欧美一区二区三区在线视频 | 在线免费观看黄色片 | 国产九九热 | 欧美操操操 | 久热精品在线观看 | 免费网站观看www在线观看 | av一级在线 | 福利视频网址 | 中文字幕丰满人伦在线 | 黄色一级大片在线免费看国产一 | 青青草在线免费视频 | 日韩免费高清 | 在线视频亚洲 | 日本黄色免费网站 | 视频一区在线观看 | 日本伊人 | 交换多p群乱高h文 | 国产女人18毛片18精品 | 日韩不卡在线观看 | 中文字字幕 |