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.
| Author |
Topic |
|
ann
Posting Yak Master
220 Posts |
Posted - 2009-07-25 : 16:12:22
|
| I have a sp (inserting new record) whereby one of the fields is ContactNumber made up of the Month,Year & RecordID(Table Record, field RecordID) - so when a new reocrd is created we end up with something like this (assuming todays date and record ID 10) 250910.Currently in my app., I add my new record, use the returned ID (Scope_ Identity), create the contactNumber using the requirements outlined above, and update the record.I am trying to figure out how to do this all within the inserting of the new record, but keep running into problems - can anyone help on this?Thanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2009-07-26 : 13:12:55
|
There's a month "25"???--Jeff Moden "Your lack of planning DOES constitute an emergency on my part... SO PLAN BETTER! ""RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row" |
 |
|
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2009-07-26 : 13:16:11
|
quote: ContactNumber made up of the Month,Year & RecordID(Table Record, field RecordID) - so when a new reocrd is created we end up with something like this (assuming todays date and record ID 10) 250910.
Actually, that's a pretty bad way to do things... it denormalizes the column by having two types of data (date/time and sequence) in the same table and it's just the wrong way to do things as you're finding out right now. It'll be a PITA for the rest of the life of the program, to boot.Can't you just use an IDENTITY column?--Jeff Moden "Your lack of planning DOES constitute an emergency on my part... SO PLAN BETTER! ""RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row" |
 |
|
|
|
|
|