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
 Updating SQL Server 2008 R2 Table

Author  Topic 

ladowali
Starting Member

16 Posts

Posted - 2014-04-20 : 17:20:39
Hi Group,
I am still learning SQL programming.
I am writing a dash board kind of screen browsing program where I have a parent and child kind of setup in browsing program. For each record in the parent I need to update my temp table ( with appx 30 fields ) coming from different tables for child table and it should be done so fast that user can easily move their record in browsing screen up and down and each up/down should delete record from the temp table and recreate the records by collecting from different tables. The main key for the parent record is order number and for each order number there may be hundred or little more records to display in child screen. I believe the SQL can do this really fast compare to the programming language I using.
I am using below king of sql statement:

BEGIN

INSERT INTO dash_board_screen_child
(a,b,c,d.......z..)
SELECT
(0,0,0,0.......0..)
FROM abc
WHERE

END

Now the question is can I use multiple different select statement here for my insert because all select may or may not be from same table. I need to complete this in SQL because the same update in my programming language is really slow and users does not like it.

Can some one suggest any sample to start so I can try to build my store procedure. I have written some simple store procedure but have not written something this kind.

Thanks
Lado

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-04-21 : 13:59:32
You can use multiple SELECT statements if they project the same number and types of columns and you UNION ALL them together. However, it's not really better than three INSERT commands and will probably result in harder-to-read code.
Go to Top of Page
   

- Advertisement -