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'