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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-09-23 : 08:03:30
|
| Diwakar writes "HiI want to transform field into rows.I have table Weekly_Timesheet structure of the table is Emp_code Weekend_DtSUN_NTMON_NTTUE_NTWED_NTTHU_NTFRI_NTSAT_NTI want to get list on Daliy basis for particular weekend Date or Employee;i.e.,Emp_CodeDateNTThanx in advance" |
|
|
samsekar
Constraint Violating Yak Guru
437 Posts |
Posted - 2003-09-23 : 09:10:04
|
Are you looking something like this..select 'emp01' empcode, getdate() as date, 1+56+89+0 as NT Can you please explain us more on your requirement.Sekar~~~~Success is not a destination that you ever reach. Success is the quality of your journey. |
 |
|
|
TSQLMan
Posting Yak Master
160 Posts |
Posted - 2003-09-23 : 16:29:57
|
| I think you are looking for this. Create Proc _proc_EmpTime@EmpNo char(10) --or whatever datatype Employee is@Wdate datetimeASIF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '#EmpTime') DROP TABLE #EmpTimeCREATE TABLE #EmpTime(Emp_code char(10), --Or whatever datatypeWeekend_Dt smalldatetime,DAY_NT as decimal)INSERT INTO #EmpTimeSELECT Emp_Code, Weekend_Dt, SUN_NT FROM Weekly_Timesheet WHERE Weekend_dt = @Wdate and Emp_Code = @EmpNo--NextINSERT INTO #EmptTimeSELECT Emp_Code, Weekend_Dt, MON_NT FROM Weekly_Timesheet WHERE Weekend_dt = @Wdate and Emp_Code = @EmpNo--NextINSERT INTO #EmptTimeSELECT Emp_Code, Weekend_Dt, TUE_NT FROM Weekly_Timesheet WHERE Weekend_dt = @Wdate and Emp_Code = @EmpNo--Next--........... Paste the insert and change the DAY_NT field until ------you have all 7.Select * from #EmpTime Drop Table #EmpTime You could use a cursor and loop through the recordset, This is just to make sure what you are looking for. Did I get it? |
 |
|
|
|
|
|
|
|