lovejaeeun
Technical User
Hi, I have a question.
Im making an ASP page that would allow a user to change the primary key of a database table. I have a form that takes in two inputs (the old PK, the new PK).
Right now Im just openning two recordsets.
1) SELECT * FROM mytable WHERE pk = 'oldPK'
2) SELECT * FROM mytable WHERE pk = 'newPK'
I do a EOF check on the first recordset to make sure it exists. And I do the same for the second except I check to make sure it DOESNT exist.
I was wondering if there was a better way to do this? I want the least amount of work for the server. I was thinking I could just open a single recordset:
SELECT PrimaryKey FROM mytable
And iterate through each record to check if the newPK or oldPK exist? Is this faster than openning two recordsets like above?
Where can I learn about writing efficient code that gets the most work done while using the least amount of server resoures?
Im making an ASP page that would allow a user to change the primary key of a database table. I have a form that takes in two inputs (the old PK, the new PK).
Right now Im just openning two recordsets.
1) SELECT * FROM mytable WHERE pk = 'oldPK'
2) SELECT * FROM mytable WHERE pk = 'newPK'
I do a EOF check on the first recordset to make sure it exists. And I do the same for the second except I check to make sure it DOESNT exist.
I was wondering if there was a better way to do this? I want the least amount of work for the server. I was thinking I could just open a single recordset:
SELECT PrimaryKey FROM mytable
And iterate through each record to check if the newPK or oldPK exist? Is this faster than openning two recordsets like above?
Where can I learn about writing efficient code that gets the most work done while using the least amount of server resoures?