• David Burrows (2/18/2011)


    string strsql = "";

    strsql += " Select '' AS [CustomerId],' ---Select Customer --- ' AS [CompanyName] ";

    strsql += " Union Select CustomerId, CompanyName ";

    strsql += " From testCustomers ";

    strsql += " Order by CompanyName ";

    You can run into a problem with that, if there's a company name that comes earlier in the sort sequence than the "column header". I usually add a "Sequence" column, hard-coded to 0 for the header, and 1 for the query under the union, and then order by that first, to force the header to stay on top. (Had to do that in a few places in an Access front-end application.)

    Just something to think about on it.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon