May 2, 2012 at 12:38 pm
Hi ,
table A:
Prop_name Prop_type STR_value Num value Date_value Bin_value
Comment_1 D NULL Null 01/02/2012 NULL
Comment_2 L asdbce Null Null Null
Comment_3 B NUll Null Null 123
Comment_4 S NULL 2 Null Null
Table B:
Comment_1 Comment_2 Comment_3 Comment_4
01/02/2012 asdbce 123 2
Need something like below???
Any help would be appreciated.
May 2, 2012 at 12:44 pm
We can.. but tell me this, if there were more than one non-null value for each comment, wchich one should be used for pivoting?
And also, do u always only 4 rows or what the base for the pivot?
What happens to the prop_type column?
May 2, 2012 at 12:54 pm
here based on pop_typr if it is "s" then need to get the str_val
"d" then date_val
"B" then bin_val
for taht comment
can we use cursor ? if so how?
May 2, 2012 at 1:16 pm
This looks an EAV type of system with the addition of datatype?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply