Click here to Skip to main content
15,867,889 members
Home / Discussions / Database
   

Database

 
AnswerRe: Stored Procedure or Trigger for Autogenerate Colunm Pin
Mycroft Holmes2-Jul-08 20:56
professionalMycroft Holmes2-Jul-08 20:56 
I am going to assume you are trying to create a key field for your employee, if so then:
DO NOT ADD INTELLIGENCE TO A PRIMARY ID/KEY FIELD, you are doing this by adding the first character of the surname. This is wrong, it should simply be the record identifier, use the surname field for search/sorting NOT the ID field.

Generating an employee number for human consumption (timecards or something) is a different matter. I would put it in the inserting stored procedure (I never use triggers)

Before the insert get the count of existing surnames with the 1st char
Select @N = (count(*) + 1) From Employee where Surname like 'A%' (this fails when the employee changes surnames - gets married and is the reason for the initial comment)
or
Select top 1 employee where ENO like 'A%'
order by ENO desc

Add the text to the ENO field


Never underestimate the power of human stupidity
RAH

GeneralRe: Stored Procedure or Trigger for Autogenerate Colunm Pin
rrrriiizz2-Jul-08 21:34
rrrriiizz2-Jul-08 21:34 
GeneralRe: Stored Procedure or Trigger for Autogenerate Colunm Pin
rrrriiizz3-Jul-08 1:09
rrrriiizz3-Jul-08 1:09 
GeneralRe: Stored Procedure or Trigger for Autogenerate Colunm Pin
Mycroft Holmes4-Jul-08 0:26
professionalMycroft Holmes4-Jul-08 0:26 
GeneralRe: Stored Procedure or Trigger for Autogenerate Colunm Pin
rrrriiizz5-Jul-08 1:35
rrrriiizz5-Jul-08 1:35 
QuestionTrigger with Time Pin
obarahmeh2-Jul-08 20:08
obarahmeh2-Jul-08 20:08 
AnswerRe: Trigger with Time Pin
Mycroft Holmes2-Jul-08 21:00
professionalMycroft Holmes2-Jul-08 21:00 
GeneralRe: Trigger with Time Pin
obarahmeh2-Jul-08 22:50
obarahmeh2-Jul-08 22:50 
QuestionsqlDataReader Execution in a Function Pin
IlseBrase2-Jul-08 18:29
IlseBrase2-Jul-08 18:29 
AnswerRe: sqlDataReader Execution in a Function Pin
Vimalsoft(Pty) Ltd3-Jul-08 4:03
professionalVimalsoft(Pty) Ltd3-Jul-08 4:03 
QuestionSQL image data Pin
nelsonpaixao2-Jul-08 14:02
nelsonpaixao2-Jul-08 14:02 
AnswerRe: SQL image data Pin
Giorgi Dalakishvili2-Jul-08 21:58
mentorGiorgi Dalakishvili2-Jul-08 21:58 
AnswerRe: SQL image data Pin
Hesham Amin2-Jul-08 22:08
Hesham Amin2-Jul-08 22:08 
QuestionConnection-string [modified] Pin
nelsonpaixao2-Jul-08 13:59
nelsonpaixao2-Jul-08 13:59 
AnswerRe: Connection-string Pin
rrrriiizz2-Jul-08 19:31
rrrriiizz2-Jul-08 19:31 
GeneralRe: Connection-string Pin
Mycroft Holmes2-Jul-08 21:12
professionalMycroft Holmes2-Jul-08 21:12 
QuestionOracle instant client Pin
Muammar©2-Jul-08 1:00
Muammar©2-Jul-08 1:00 
QuestionFinaly I Found it. Compare and synchronize SQL Server database structures and data. Pin
dingoishere2-Jul-08 0:12
dingoishere2-Jul-08 0:12 
AnswerRe: Finaly I Found it. Compare and synchronize SQL Server database structures and data. Pin
Syed Mehroz Alam2-Jul-08 18:44
Syed Mehroz Alam2-Jul-08 18:44 
QuestionPerformance Issue Pin
sujithkumarsl1-Jul-08 19:43
sujithkumarsl1-Jul-08 19:43 
AnswerRe: Performance Issue Pin
Paul Conrad1-Jul-08 20:03
professionalPaul Conrad1-Jul-08 20:03 
GeneralRe: Performance Issue Pin
sujithkumarsl1-Jul-08 20:24
sujithkumarsl1-Jul-08 20:24 
AnswerRe: Performance Issue Pin
N a v a n e e t h1-Jul-08 20:36
N a v a n e e t h1-Jul-08 20:36 
GeneralRe: Performance Issue Pin
sujithkumarsl1-Jul-08 22:04
sujithkumarsl1-Jul-08 22:04 
GeneralRe: Performance Issue Pin
N a v a n e e t h1-Jul-08 22:51
N a v a n e e t h1-Jul-08 22:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.