I am fairly new to SQL, but here it goes.
What I am trying to do is run two different procedures within one.
One sets a value within existing rows to show that someone is working on the records, and the other copies those records to another table, where editing can be done.
The reason it has to be this way, is that when the user has finished with the updating, another procedure is run that records and captures the changes made, and by who.
This works purfect.
Anyway, here is my problem: -
What I want to do is to use the 'TOP ** PERCENT' type arguement, like you can with a simple select statement, but this time I want it to say something like -
UPDATE the Top ** Percent Admin_Table SET edited_by=suser_name() where admintag='1' and edited_by = null.
The code is (With bits changed to protect the origin): -
begin tran
update admin_TABLE set currently_edited_by=suser_sname()
where currently_edited_by is null and admintag=1
insert edited_logs ( ## FIELD CODES ## )
select ## FIELD CODES ##
from admin_TABLE
where currently_edited_by=suser_sname() and admintag=1
commit tran
But in this arguement it doesn't like the Top ** Percent, is there another way, either to re-word this part, or to change it so that it updates the first so many records instead of a percentage.
I am using server 2000, and Access 2000.
Bit vaugue I know but any help is appreciated.
What I am trying to do is run two different procedures within one.
One sets a value within existing rows to show that someone is working on the records, and the other copies those records to another table, where editing can be done.
The reason it has to be this way, is that when the user has finished with the updating, another procedure is run that records and captures the changes made, and by who.
This works purfect.
Anyway, here is my problem: -
What I want to do is to use the 'TOP ** PERCENT' type arguement, like you can with a simple select statement, but this time I want it to say something like -
UPDATE the Top ** Percent Admin_Table SET edited_by=suser_name() where admintag='1' and edited_by = null.
The code is (With bits changed to protect the origin): -
begin tran
update admin_TABLE set currently_edited_by=suser_sname()
where currently_edited_by is null and admintag=1
insert edited_logs ( ## FIELD CODES ## )
select ## FIELD CODES ##
from admin_TABLE
where currently_edited_by=suser_sname() and admintag=1
commit tran
But in this arguement it doesn't like the Top ** Percent, is there another way, either to re-word this part, or to change it so that it updates the first so many records instead of a percentage.
I am using server 2000, and Access 2000.
Bit vaugue I know but any help is appreciated.