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

SQL Server 中是否每條記錄都有唯一的字段?

Does every record has an unique field in SQL Server?(SQL Server 中是否每條記錄都有唯一的字段?)
本文介紹了SQL Server 中是否每條記錄都有唯一的字段?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我在 Visual Studio - VB.NET 中工作.

I'm working in Visual Studio - VB.NET.

我的問題是我想刪除 SQL Server 中的特定行,但我唯一的唯一列是一個自動遞增的標識.

My problem is that I want to delete a specific row in SQL Server but the only unique column I have is an Identity that increments automatically.

我的工作流程:
1.我在列中添加了一行(身份正在遞增,但我不知道數字)
2.我想刪除上一行

My process of work:
1. I add a row in the column (the identity is being incremented, but I don't know the number)
2. I want to delete the previous row

是否存在每條新記錄都有的唯一 ID?可能我的表有 2 條完全相同的記錄,只是序列(身份)不同.

Is there a sort of unique ID that every new record has? It's possible that my table has 2 exactly the same records, just the sequence (identity) is different.

任何想法如何處理這個問題?

Any ideas how to handle this problem?

推薦答案

SQL Server 有幾個函數可以返回最后一行的生成 ID,每個函數都有自己特定的優點和缺點.

SQL Server has a few functions that return the generated ID for the last rows, each with it's own specific strengths and weaknesses.

基本上:

  • @@IDENTITY 如果您不使用觸發器
  • SCOPE_IDENTITY() 適用于您明確調用的代碼.
  • IDENT_CURRENT(‘tablename’) 適用于所有范圍的特定表.
  • @@IDENTITY works if you do not use triggers
  • SCOPE_IDENTITY() works for the code you explicitly called.
  • IDENT_CURRENT(‘tablename’) works for a specific table, across all scopes.

在幾乎所有情況下,SCOPE_IDENTITY() 都是您所需要的,并且使用它是一個好習慣,而不是其他選項.
此處.

In almost all scenarios SCOPE_IDENTITY() is what you need, and it's a good habit to use it, opposed to the other options.
A good discussion on the pros and cons of the approaches is also available here.

這篇關于SQL Server 中是否每條記錄都有唯一的字段?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

What SQL Server Datatype Should I Use To Store A Byte[](我應該使用什么 SQL Server 數據類型來存儲字節 [])
Interpreting type codes in sys.objects in SQL Server(解釋 SQL Server 中 sys.objects 中的類型代碼)
Typeorm .loadRelationCountAndMap returns zeros(Typeorm .loadRelationCountAndMap 返回零)
MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否應該返回“1?什么時候不能投射為日期?)
Converting the name of a day to its integer representation(將一天的名稱轉換為其整數表示)
How to convert nvarchar m/d/yy to mm/dd/yyyy in SQL Server?(如何在 SQL Server 中將 nvarchar m/d/yy 轉換為 mm/dd/yyyy?)
主站蜘蛛池模板: 精品乱码一区二区三四区视频 | 成人免费视频 | 黑人巨大精品欧美一区二区免费 | 亚洲免费网 | 久操福利 | 欧美日本韩国一区二区三区 | 久草在线 | 欧美精品一区三区 | 日本特黄特色aaa大片免费 | 欧美高清视频 | 国产一区二区三区四区三区四 | 国产色婷婷精品综合在线手机播放 | 国产精品美女久久久久久免费 | 精品久久久久久 | 中国毛片免费 | 99视频免费播放 | 欧美成人免费在线视频 | 久久机热 | 风间由美一区二区三区在线观看 | 羞羞的视频在线看 | 欧美成人激情视频 | 一级毛片黄片 | 免费性视频 | 欧美成人免费电影 | www.久久久久久久久久久 | 日本精品久久 | 欧美精品一区在线发布 | 成人精品鲁一区一区二区 | 成人在线中文字幕 | 欧美三级免费观看 | 中文字幕一区二区三区在线观看 | 精品国产鲁一鲁一区二区张丽 | 中文字幕国产视频 | 久久精品视频12 | 日韩视频在线免费观看 | 欧美精品久久久 | v片网站 | 四虎影院在线观看免费视频 | 国产精品海角社区在线观看 | 看羞羞视频 | 国产精品久久久久永久免费观看 |