久久久久久久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)
主站蜘蛛池模板: 日本不卡一区 | 日韩手机在线看片 | 日日骚视频| 午夜爽爽男女免费观看hd | 久久一 | 草久视频| 欧美精品在线观看 | 男人久久天堂 | 久久久123 | 亚洲 中文 欧美 日韩 在线观看 | 国产一级在线 | 伊人色综合久久久天天蜜桃 | 久久久爽爽爽美女图片 | 先锋资源亚洲 | 国产精品伦理一区二区三区 | 一本久久a久久精品亚洲 | 一区二区三区回区在观看免费视频 | 中文字幕91av | 日本欧美国产在线观看 | 91婷婷韩国欧美一区二区 | 天天操天天射天天舔 | 精品国产乱码久久久久久果冻传媒 | 成人av鲁丝片一区二区小说 | 中文字幕成人网 | 8x国产精品视频一区二区 | 在线国产一区 | 美日韩精品 | 久久国产精品偷 | 日日操夜夜摸 | 日韩av高清 | 日韩一区二区三区在线 | 在线观看成人av | 久久久一二三区 | 亚洲国产精品人人爽夜夜爽 | 欧美日韩国产一区二区三区 | 午夜精品久久久久久久久久久久久 | 亚洲一区二区三区 | 国精品一区 | 91精品在线看 | 玖玖视频 | 日韩区 |