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 2005 Forums
 Transact-SQL (2005)
 geting a data from one table and inserting

Author  Topic 

soorma
Yak Posting Veteran

52 Posts

Posted - 2009-12-17 : 23:57:17
I am trying to get specific data from a table and insert into another table. The second table structure is exactly the same. actually i am importing a excel file into the first table.

The table structure looks like this

CREATE TABLE [dbo].[temp](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Interval] [varchar](250) NULL,
[calls_accepted] [varchar](150) NULL,
[calls_answered] [varchar](150) NULL,
[calls_abandoned] [varchar](150) NULL,
[Avg_talk_time] [varchar](150) NULL,
[DNIS_calls_abandoned] [varchar](150) NULL,
[Avg_wait_time] [varchar](150) NULL,
[TSF] [varchar](150) NULL,
[Longest_wait_time] [varchar](150) NULL,
[DNIS] [varchar](50) NULL
) ON [PRIMARY].

Right now the data is grouped by dnis number 3393(that number will change) that would be under column namecalls_abandoned in the table.
Row 11 It is kind of a header file in the table (DNIS Name Billing DNIS Number 3393 ).


11 DNIS Name Billing DNIS Number 3393 NULL NULL NULL NULL NULL NULL

12 08:30 1.00 1.00 0.00 0:03:08 0.00 0:00:02 100.00 0:00:02 NULL

13 10:00 1.00 1.00 0.00 0:02:01 0.00 0:00:02 100.00 0:00:02 NULL

14 15:00 1.00 1.00 0.00 0:06:24 0.00 0:00:04 100.00 0:00:04 NULL

15 DNISTotal 3.00 3.00 0.00 0:03:51 0.00 0:00:03 100.00 0:00:04 NULL

--------------------------------------------------------------------------------------------------------------------------------------------

16 DNIS Name Customer Service DNIS Number 3398 NULL NULL NULL NULL NULL NULL

17 04:00 3.00 2.00 1.00 0:00:05 33.33 0:00:02 100.00 0:00:02 NULL

18 04:30 5.00 3.00 2.00 0:00:38 40.00 0:00:02 100.00 0:00:02 NULL

19 Total: 1046.00 779.00 267.00 0:03:54 25.53 0:00:11 86.14 0:02:39 NULL
-----------------------------------------------------------------------------------------------------------------------------------------------

For example the data for 3393 is from 12 to 14 and data for 3398 is from 17 to 18. i need to insert that data in the second table.

So i want to show the data like this for specific DNIS number. The table for the second table is exactly the same. I need to grab the dnis number and its data from the table and insert into the second table like this

1 08:30 1.00 1.00 0.00 0:03:08 0.00 0:00:02 100.00 0:00:02 3393

2 10:00 1.00 1.00 0.00 0:02:01 0.00 0:00:02 100.00 0:00:02 3393

3 15:00 1.00 1.00 0.00 0:06:24 0.00 0:00:04 100.00 0:00:04 3393

4 04:00 3.00 2.00 1.00 0:00:05 33.33 0:00:02 100.00 0:00:02 3398

5 04:30 5.00 3.00 2.00 0:00:38 40.00 0:00:02 100.00 0:00:02 3398

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-12-20 : 04:29:53
actually i think what you need is just to exclude records with DNIS Name & DNISTotal while inserting to new table. the order in which you insert is not matter here as you can always retrieve it in order you want.
Go to Top of Page
   

- Advertisement -