This article is a mirror article of machine translation, please click here to jump to the original article.

View: 11260|Reply: 0

[New Issue] What is the difference between SCOPE_IDENTITY() being written before and after in t-sql?

[Copy link]
Posted on 5/5/2015 5:48:49 PM | | |
  1. select SCOPE_IDENTITY() insert into tb_GoodsInfo values('sd','电器','232131','7','222')
  2. go
  3. insert into tb_GoodsInfo values('sd','电器','232131','7','222') select SCOPE_IDENTITY()
  4. go
Copy code
If the normal ID is 1, then the SQL statement on the first line will return null.
The SQL statement on the second line will return 1,

What is the difference between writing SCOPE_IDENTITY () before and after ()? Why is there such a big effect?




Previous:sql gets the primary key value after waiting for INSERT
Next:asp.net simple three-layer architecture (purchase, sales and inventory management system) project source code
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com