久久久久久久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?)
主站蜘蛛池模板: 国产精品中文字幕一区二区三区 | 亚洲国产精品一区二区三区 | 91国内在线观看 | 国产美女精品视频 | 97av视频| 欧美日韩亚洲系列 | 韩国主播午夜大尺度福利 | 国产免费一区 | 欧美a级成人淫片免费看 | 99精品99| 中文字幕一区二区三区四区五区 | 四虎永久免费黄色影片 | 国产精品久久久久久久久动漫 | 国产亚洲网站 | 少妇久久久久 | 国产成人在线一区二区 | 成人国产精品久久久 | 国产精品69毛片高清亚洲 | 在线免费观看a级片 | 中文字幕精品一区久久久久 | 亚洲麻豆| a级片www| 伊人在线 | 美女久久久久 | 中文字幕av在线播放 | 国产电影一区二区在线观看 | 成人伊人网 | 人人鲁人人莫人人爱精品 | 国产成人精品久久二区二区91 | 精品久久久久久久 | 久久久久久免费毛片精品 | 日本三级全黄三级三级三级口周 | 精品久久久久久一区二区 | 日韩成人免费视频 | 精品乱码一区二区三四区视频 | 狠狠亚洲 | 欧美成人精品 | 91精品国产综合久久久久久蜜臀 | 黄色综合 | aa级毛片毛片免费观看久 | 免费国产一区二区 |