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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-01-23 : 10:12:38
|
Hassan Rostami writes "Hi,I have a table called MyTable with three fields in it: ID (Primary Key, Field_1, and Field_2My record set should look like thisID Field_1 Field_21 1 1_12 1 1_23 2 2_14 2 2_2 I like to use trigger to update Field_2 as soon as a record is inserted into MyTable. It should get the value of Field_1 plus “_” plus assign number 1 to the first record, 2 to the second, etc. The reason is that I have to use Field_2 to call my record set not ID fieldI would appreciate you help. I am very new to SQL and do not know how to set the serial number for Field_ThanksHassan" |
|
|
andre
Constraint Violating Yak Guru
259 Posts |
Posted - 2002-01-23 : 10:20:36
|
| There's an article on it here:[url]http://www.sqlteam.com/item.asp?ItemID=6494[/url] |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-01-23 : 10:26:29
|
| follow the link Andre has provided , you will learn all about writing triggers.This should do what you are looking for.update m set m.field2=str(i.field1)+"-"+str(i.id) from mytable m inner join inserted ion m.id=i.id--------------------------------------------------------------Dont Tell God how big your Problem is , Tell the Problem how Big your God is |
 |
|
|
|
|
|