Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Creating a pin number when a record is inserted

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-08-01 : 07:48:04
Mark writes "I am trying to create a procedure that insert a sequencetial or random pin number when a record is inserted to my contact table.

Here is the table

contactid
firstname
lastname
pin number

After the insert has been executed the pun should be created and inserted to the pin number column. One other obastacle is the pin number should not be changed if the record is updated.

Sparky

SQL 2000
Windows Advanced Server SP4"

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2003-08-01 : 07:59:45
search for RANDOM or IDENTITY or GUID in this site....one, other or all of the topics linked to these keywords would be a step in the right direction for you.


stopping the value being changed is seperate matter from getting it there in the 1st place....but a GUID would go someway towards that goal.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-08-01 : 08:09:06
You can DENY update permission on that column:

DENY UPDATE (Pin) ON Contact TO Public

Any attempt to update that column will throw an error and cancel the entire update statement. If you want a more graceful handling, you'd have to write a trigger instead of using DENY, and it won't be as secure.
Go to Top of Page
   

- Advertisement -