The ID and data id of the saved data record are queried when the data is saved.

Source: Internet
Author: User

The ID and data id of the saved data record are queried when the data is saved.

The record ID of the data is retrieved when the data is saved.

Insert into Table (a, B) values (1, 2) select @ identity


How can I save the access database and return the id generated by the current storage immediately? I have a large header. Can anyone help me?

First, use the Statement on the first floor to query the largest ID number. Then, after the record is added successfully, then the ID number generated by the added data is equal to the maximum ID number + 1, because your ID is an automatic ID, + 1. Finally, you can return the value of ID + 1, which is your currently saved ID number.
After reading your question, if this statement reports an error, you can write it in another way.
Select top 1 * FROM indicates order by id desc
This is the largest ID in the Table. After you add the table successfully, the obtained ID number + 1 is returned.

Use SQL Server 2000 to filter data records from one table and save them to another table.

The same database:
Insert into B (name0, address0)
Select name, address from a where name = 'xx'
Different databases (assuming the database name is db ):
Insert into B (name0, address0)
Select name, address from db .. a where name = 'xx'
On different servers, run the sp_addmediaserver stored procedure to add a linked server:
EXEC master. dbo. sp_addmediaserver @ server = n'link ',
@ Srvproduct = n'sqlncli ',
@ Provider = n'sqlncli ',
@ Datasrc = n' IP address'
Then add the ing Login Name of the linked server:
EXEC master. dbo. sp_addmediasrvlogin @ rmtsrvname = n'link', @ useself = n'false', @ locallogin = n'local Username ', @ rmtuser = n' login name to connect to the server ', @ rmtpassword = 'logon password'
Then we need to insert the following:
Insert into B (name0, address0)
Select name, address from link. db... a where name = 'xx'

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.