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.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | pnaszPosting Yak  Master
 
 
                                        101 Posts | 
                                            
                                            |  Posted - 2013-04-20 : 10:28:43 
 |  
                                            | EmpID	EmpName	EntryDate	Location	totaltime1234	test1	2013-04-08	Region1	00:001234	test1	2013-04-09	Region1	00:001234	test1	2013-04-10	Region1	06:471234	test1	2013-04-11	Region1	06:331234	test1	2013-04-12	Region1	06:221234	test1	2013-04-13	Region1	06:131235	test2	2013-04-08	Region2	00:001235	test2	2013-04-09	Region2	00:001235	test2	2013-04-10	Region2	06:471235	test2	2013-04-11	Region2	06:331235	test2	2013-04-12	Region2	06:221235	test2	2013-04-13	Region2	06:13How do i change the table to this format								EmpID	EmpName	2013-04-08	2013-04-09	2013-04-101234	test1	00:00	          00:00         06:4712345	test2	00:00	          00:00	        06:47 |  |  
                                    | James KMaster Smack Fu Yak Hacker
 
 
                                    3873 Posts | 
                                        
                                          |  Posted - 2013-04-20 : 12:55:09 
 |  
                                          | quote:I am not able to correlate between your input data and the output. Won't you have additional columns for 2013-04-11, 2013-04-12 etc.?  Assuming you do, what you will need to do is to pivot the source data.  If you have only a known number of dates, and if you know them in advance, you can use static pivot. If you don't, which probably is the case, you will need to use dynamic pivot. See Madhivanan's blog for code and example here: http://beyondrelational.com/modules/2/blogs/70/posts/10840/dynamic-pivot-in-sql-server-2005.aspxOriginally posted by pnasz
 EmpID	EmpName	EntryDate	Location	totaltime1234	test1	2013-04-08	Region1	00:001234	test1	2013-04-09	Region1	00:001234	test1	2013-04-10	Region1	06:471234	test1	2013-04-11	Region1	06:331234	test1	2013-04-12	Region1	06:221234	test1	2013-04-13	Region1	06:131235	test2	2013-04-08	Region2	00:001235	test2	2013-04-09	Region2	00:001235	test2	2013-04-10	Region2	06:471235	test2	2013-04-11	Region2	06:331235	test2	2013-04-12	Region2	06:221235	test2	2013-04-13	Region2	06:13How do i change the table to this format								EmpID	EmpName	2013-04-08	2013-04-09	2013-04-101234	test1	00:00	          00:00         06:4712345	test2	00:00	          00:00	        06:47
 
 |  
                                          |  |  |  
                                    | pnaszPosting Yak  Master
 
 
                                    101 Posts | 
                                        
                                          |  Posted - 2013-04-20 : 15:37:32 
 |  
                                          | Yes there will be additional column. Till 2012-04-30 |  
                                          |  |  |  
                                    | pnaszPosting Yak  Master
 
 
                                    101 Posts | 
                                        
                                          |  Posted - 2013-04-20 : 15:41:03 
 |  
                                          | Yes there will be additional column. Till 2012-04-30 |  
                                          |  |  |  
                                    | pnaszPosting Yak  Master
 
 
                                    101 Posts | 
                                        
                                          |  Posted - 2013-04-21 : 12:43:45 
 |  
                                          | How to I show totaltime for pivot coloumn entrydate |  
                                          |  |  |  
                                    | pnaszPosting Yak  Master
 
 
                                    101 Posts | 
                                        
                                          |  Posted - 2013-04-21 : 12:44:03 
 |  
                                          | How to I show totaltime for pivot coloumn entrydate |  
                                          |  |  |  
                                    | bandiMaster Smack Fu Yak Hacker
 
 
                                    2242 Posts |  |  
                                |  |  |  |