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

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

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

問題描述

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

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 ?

我現(xiàn)在使用 nvarchar 來存儲日期時間.

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

推薦答案

是的,您仍然可以比較它們,但這肯定是一個不好的做法,因?yàn)槟枰獙⒋俗址D(zhuǎn)換為日期數(shù)據(jù)類型才能進(jìn)行比較它們之間.如果您在列上定義了索引,則它們將不再使用,因?yàn)樵摿袑⒈晦D(zhuǎn)換,并且會導(dǎo)致大型數(shù)據(jù)庫的性能下降.

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 是存儲為字符串的日期的當(dāng)前格式.

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

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

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

相關(guān)文檔推薦

Modify Existing decimal places info(修改現(xiàn)有小數(shù)位信息)
The correlation name #39;CONVERT#39; is specified multiple times(多次指定相關(guān)名稱“CONVERT)
T-SQL left join not returning null columns(T-SQL 左連接不返回空列)
remove duplicates from comma or pipeline operator string(從逗號或管道運(yùn)算符字符串中刪除重復(fù)項)
Change an iterative query to a relational set-based query(將迭代查詢更改為基于關(guān)系集的查詢)
concatenate a zero onto sql server select value shows 4 digits still and not 5(將零連接到 sql server 選擇值仍然顯示 4 位而不是 5)
主站蜘蛛池模板: 中文字幕亚洲一区二区va在线 | 黄免费看| 成人在线视频免费观看 | 国产欧美一区二区三区国产幕精品 | 国产91在线 | 亚洲 | 日韩一区二区三区在线 | 免费污视频 | 国产成人99久久亚洲综合精品 | 日韩av免费在线电影 | 亚洲国产视频一区二区 | 久久久久久久久中文字幕 | 日本三级电影在线看 | 国产精品久久久久久久久久久久午夜片 | 911精品国产 | 久草热8精品视频在线观看 午夜伦4480yy私人影院 | 国产精品久久久久久模特 | 黑人巨大精品欧美一区二区免费 | 亚洲精品国产成人 | 久草精品视频 | www.欧美视频 | 天天干天天操天天爽 | 欧美福利 | 操人视频在线观看 | 97偷拍视频 | 日韩久久网 | 美女黄网站视频免费 | 亚洲视频在线一区 | 欧美一区二区三区 | 二区亚洲 | 91成人精品 | 九九色综合 | 999精品视频在线观看 | 中文字幕在线二区 | 国产精品视频二区三区 | 在线黄av| 精品国产乱码久久久久久丨区2区 | 中文字幕日韩欧美一区二区三区 | 久久国产成人 | 亚洲精品久久久一区二区三区 | av日韩在线播放 | 久久久久久黄 |