久久久久久久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)
主站蜘蛛池模板: 一区二区三区视频在线 | 国产精品资源在线观看 | 亚洲国产精品久久 | 日韩一及片 | 三级视频久久 | 国产精品jizz在线观看老狼 | 一区二区三区欧美 | 国产欧美精品区一区二区三区 | av一级| 国内自拍偷拍 | 欧美久久一区 | 免费黄色av | 国产精品免费视频一区 | 久久影音先锋 | 日韩精品一区二区三区 | 欧美日韩亚洲三区 | 午夜一级大片 | 99爱在线视频 | 亚洲黄色av| 亚洲天天干 | 日韩中文字幕一区二区 | 欧美一区二区三区视频 | av国产精品 | 精品久久久久久亚洲精品 | 欧美亚洲网站 | 亚洲欧美久久 | 91精品国产综合久久久久 | 国产精品欧美一区二区 | 狠狠干狠狠插 | 91精品国产91久久久久久吃药 | 秋霞a级毛片在线看 | www国产亚洲精品久久网站 | 亚洲一区二区三区在线播放 | 91视频一区 | 欧美二三区 | 日韩插插 | 91xxx在线观看 | 日韩精品一区二区三区在线 | 成年无码av片在线 | 国产91网址 | 亚洲精品在线看 |