How to combine the results in a table

  • Hi

    I have a table like this:

    SRVNAME             VERSION

    SRV1                   SQL65

    SRV2                   SQL2K

    SRV3                   SQL70

    ......

    ......

    SRV100                 SQL2K

    I would like to create anoth table like this:

    SQL2K           SQL70           SQL65

    SRV1              SRV3            SRV2

    ........             .......            .....

    Can you gaive me some ideas?

    Thanks in advance.

     

     

     

  • select

        case when version = 'sql2k' then srvname

     end 'sql2k'

    ,

        case when version = 'sql70' then srvname

     end 'sql70'

    ,

        case when version = 'sql65' then srvname

     end 'sql65'

  • but you won't you will get nulls for the other columns and since you have multiple servers you cannot use max or other aggregate to group it. Your going to have to use a client tool or a temp table with a process to loop thru and put the values in the temp table like you want them.

  •  

    Did you run DBCC updateusage OR sp_spaceused with True. The table free space (in extents only) is reclaimed as they become free  . How ever, sp_spaceused may not reflect this, that is why you need to run those two commands to verify.  How ever, if the empty space is spread over several individual pages (as opposed to extents), the above two commands cannot help, and you may have to reindex to release that space.

    This is from BOL:

    There are some situations, for example, after an index is dropped, when the sysindexes information for the table may not be current. This process can take some time to run on large tables or databases. Use it only when you suspect incorrect values are being returned and when the process will not have an adverse effect on other users or processes in the database. If preferred, DBCC UPDATEUSAGE can be run separately.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply