| 
                
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 |  
                                    | kaniaStarting Member
 
 
                                        4 Posts | 
                                            
                                            |  Posted - 2011-01-21 : 02:03:03 
 |  
                                            | Hi AllI am newbie in SQL server 2000 and i do really need ur guidance to solve this problemi have a table named TIDlistwhich look like this...TID    item1    item21        a        b2        a3        bwhat i need to be doing is to convert this table into binary formatbelowTID     a      b1       1       12       1       03       0       1MY PROBLEM IS:a) how to create the table with query result as the column?i've tried:Create table TIDbinary(TID integer,Select distinct(prodID) from order details integer) and it absolutely didn't workb) after creating the table of TIDbinary,,how to fill it with 1,indicating TID consist of the product or 0 otherwiseI really appreciate any suggestion,or comment to this problemMay god bless u for ur kindnessBest regardsthanks |  |  
                                    | khtanIn (Som, Ni, Yak)
 
 
                                    17689 Posts | 
                                        
                                          |  Posted - 2011-01-21 : 02:20:29 
 |  
                                          | [code]select TID,        case when item1 = 'a' then 1 else 0 end as a,       case when item2 = 'b' then 1 else 0 end as bfrom   yourtable[/code] KH[spoiler]Time is always against us[/spoiler]
 |  
                                          |  |  |  
                                    | kaniaStarting Member
 
 
                                    4 Posts | 
                                        
                                          |  Posted - 2011-01-21 : 02:44:41 
 |  
                                          | thanks 4 giving me an idea khtananyway,i am still having the problem to create the table TIDbinary i want to create the column of TIDbinary with query selectionis that possible if let's say i write this onecreate table TIDbinary (TID integer,select distinct(productid) from order details)i have tried it and it didn't work at all:(is there any other SQL query to create the table whose name of column comes from query result"select"???Thanks in advance for advice:) |  
                                          |  |  |  
                                    | khtanIn (Som, Ni, Yak)
 
 
                                    17689 Posts | 
                                        
                                          |  Posted - 2011-01-21 : 03:19:17 
 |  
                                          | [code]select TID,        case when item1 = 'a' then 1 else 0 end as a,       case when item2 = 'b' then 1 else 0 end as binto   TIDbinary from   yourtable[/code] KH[spoiler]Time is always against us[/spoiler]
 |  
                                          |  |  |  
                                    | kaniaStarting Member
 
 
                                    4 Posts | 
                                        
                                          |  Posted - 2011-01-21 : 03:50:53 
 |  
                                          | ohy,i've just known that select into will work with this...but..i am so sorry i forgot to tell u a very important things earlierthe number of item column is less than the number of productid(a,b)so here is the real data:TID   item1  item2  item3 item41     a      b2     b      c       d      e3     c      d4     d      eit has to be converted like thisTID   a   b   c   d   e1     1   1   0   0   02     0   1   1   1   13     0   0   1   1   04     0   0   0   1   1i've also tried the query u given to me select TID,        case when item1 = 'a' then 1 else 0 end as a,       case when item2 = 'b' then 1 else 0 end as binto   TIDbinary from   yourtablebut there is an error message says:"incorrect syntact near a":(what's wrong..thanks |  
                                          |  |  |  
                                    | kaniaStarting Member
 
 
                                    4 Posts | 
                                        
                                          |  Posted - 2011-01-21 : 08:46:37 
 |  
                                          | it works!!!! thank u so much khtan^_^ |  
                                          |  |  |  
                                |  |  |  |  |  |