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
 Transact-SQL (2000)
 Moving a column value to a new column on Insert

Author  Topic 

mattpand
Starting Member

1 Post

Posted - 2005-02-17 : 10:29:17
Is there a simple way to copy the value from one column to another within the same table when an insert is perform. Can I use a trigger or something to achieve this.

Example

One someone inserts a record jobid is populate and I want projectid in the same table to be the same value.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-02-17 : 10:42:33
If the insert is done through an SP, simply use the @jobid parameter for both columns.

If the projectid will always be the same as jobid (even after jobid is updated) you could make projectid a calculated field.

If you want to be able to (optionaly) enter a different value, you could define a Default. (nulls would be changed to jobid)

And of course a trigger can also do the trick.

These are your main options, define your rules and make an 'informed' decision :)

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -