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 |
|
aniketyadav7
Starting Member
2 Posts |
Posted - 2011-05-02 : 16:06:58
|
| Sr No Description 01-04-2011 02-04-2011 03-04-2011...So On-----------------Today Cumm Today Cumm Today Cumm..So On1---- PKPP------ 35---- 119-- 40----200-- 25----100.. So On2---- DPK------ 120---- 130--150---160-- 130-- 140..So OnThe Hypens are used just to arrange the data in proper manner.Dates are dynamic. Today and cumulative values are from the tables.Any Help will be appreciated...mailto:aniketyadav7@gmail.com |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-02 : 16:15:58
|
| Not sure what you're looking for.Do you have a table with those columns and want a string with the hyphens added?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
aniketyadav7
Starting Member
2 Posts |
Posted - 2011-05-03 : 01:39:40
|
| Sr No Description 01-04-2011 02-04-2011 03-04-2011...So On-----------------Today Cumm Today Cumm Today Cumm..So On1---- PKPP------ 35---- 119-- 40----200-- 25----100.. So On2---- DPK------ 120---- 130--150---160-- 130-- 140..So Oni want the horizontal headers specifying the Sr. no, Description, and dates of the month starting from 1st of the month to 30/31st of month.so that i can fill the data as per the days.The hypens are not part of it... it is just to arrange the data in grid format so that i can explain u. they are not included.i have one option for this but it is not dynamic...create table #temp1 (parameter nvarchar(20),target nvarchar(20),d01 nvarchar(20),c01 nvarchar(20),d02 nvarchar(20),c02 nvarchar(20),d03 nvarchar(20),c03 nvarchar(20),d04 nvarchar(20),c04 nvarchar(20),d05 nvarchar(20),c05 nvarchar(20),d06 nvarchar(20),c06 nvarchar(20),d07 nvarchar(20),c07 nvarchar(20),d08 nvarchar(20),c08 nvarchar(20),d09 nvarchar(20),c09 nvarchar(20),d10 nvarchar(20),c10 nvarchar(20))But it is not dynamic... and i dont want hard coded.If my date range is 01/04/2011 to 03/04/2011 then the header should be like thisSr no.,Description, 01/04/2011, 02/04/2011, 03/04/2011 |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-03 : 03:51:51
|
| From the description it looks like you want a series of strings (varchar(max)) of which the first will be the header, the second the column headings followed by the data - all space filled. No idea where the data should come from or what you want to do with it but maybe this will give you some ideas.Therefore I would create a temp tablecreate table #a (id int identity, s varchar(max))theninsert #a(s) select 'Sr no.,Description, 01/04/2011, 02/04/2011, 03/04/2011'insert #a(s) select space(30)+'Today' + space(2)+'CUMM'+...insert #a(s) select left(convert(varchar(20),id)+space(5),5)+left(decription+space(10),10)+right(space(10)+convert(varchar(10),today),10)+right(space(10)+convert(varchar(10),cumm),10)+...from tbl==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|