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
 General SQL Server Forums
 New to SQL Server Programming
 Insert field from calculation of other field

Author  Topic 

ArcSlayer
Starting Member

4 Posts

Posted - 2011-05-18 : 02:01:45
i want to insert into temp table that 1 of the field is calculation of 2 field and the field i use for calculation is from selecting another table.
ex:
insert into (field1, field2, field3)
values (
(select ....),
(select ....),
((field1*8)/field2)
)

the problem is if i use the same select for each field1 and 2 on my calculation for field3, it require alot of time to execute because i hava alot of data.

is there any way that i can just call new value of field1 and field2 without reapeting the select command?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-05-18 : 02:08:07
Yes. Don't do that using subselects. You have to create one select with joins to all needed tables and the you can do what you want with all columns.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -