Help I am new to SQL server 
Author Message
 Help I am new to SQL server

Is it possible in a trigger (update or insert) to assign a value to a
column from the value of another column in the same table?

(ie. SecondID = FirstID + '2')

So if FirstID = 111.1 then SecondID = 111.12



Wed, 17 Nov 1999 03:00:00 GMT
 Help I am new to SQL server

Sure, you can modify the table upon which the trigger is based, using the
'inserted' table to know which rows in the base table have changed.

create trigger tr1 on table1
for insert, update
as

update table1
set SecondID = FirstID + '2'
where primary_key_col  in  (select primary_key_col from inserted)

--
Kalen Delaney
MCSE, SQL Server MCT, MVP
For SQL Server Technical Seminars: Check out www.sqlinc.com


Quote:
> Is it possible in a trigger (update or insert) to assign a value to a
> column from the value of another column in the same table?

> (ie. SecondID = FirstID + '2')

> So if FirstID = 111.1 then SecondID = 111.12



Thu, 18 Nov 1999 03:00:00 GMT
 Help I am new to SQL server


than is necessary.  

For example, create a HEADER/DETAIL.

Within the boundaries of a transaction...

BEGIN
  sql1
  sql2
  ...
  etc.
COMMIT/ROLLBACK

Use the stored procedure "mechanism" to


3) that's it




- so forget it)

//eof
//kn
// please respond to "newsgroup" not e-mail



Sat, 20 Nov 1999 03:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. New line break - ( I am new to the world of sql server)

2. Please help, I am new to Jet Engine and SQL

3. Help. I am new to database administration

4. HELP!!!, I am so new that I do

5. HELP!!!, I AM SO NEW THAT

6. Please help, I am new here

7. HELP ME - I AM NEW !!!!

8. I am very new at this and need help

9. I am New.Can you help me?

10. New to SQL, easy question I am sure

11. Linked Servers Help I am going crazy


 
Powered by phpBB® Forum Software