#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    Lastname, Firstname switch


    Hi,

    Please help, im not at all good with SQL but I have created the query below. It pulls information from a room booking system to display on a digital signage product.

    At present the 'Name' field outputs as lastname, firstname. I really need it to display as Firstname Lastname but still under the one column.

    Can someone take a look please? It would be greatly appreciated.

    SELECT HOST9006.DESCRIPTION, HOST0110.ROOMNAME, HOST0140.NAME, dateadd(mi, HOST0120.STARTMINS, HOST0120.MTGDATE) AS ASTART,

    dateadd(mi, HOST0120.ENDMINS, HOST0120.MTGDATE) AS AFINISH, CONVERT (VARCHAR(5), dateadd(mi, HOST0120.STARTMINS,

    HOST0120.MTGDATE) ,108) AS START, CONVERT (VARCHAR(5), dateadd(mi, HOST0120.ENDMINS, HOST0120.MTGDATE) ,108) AS FINISH,

    HOST0120.MTGKEY, HOST0120.HIPTYPE, HOST0120.ROOMKEY

    FROM HOST0140
    INNER JOIN HOST0120
    ON HOST0120.OWNERKEY=HOST0140.PERSONKEY
    INNER JOIN HOST9006
    ON HOST9006.KEYVALUE=HOST0120.MTGSTATE
    INNER JOIN HOST0110
    ON HOST0110.ROOMKEY=HOST0120.ROOMKEY

    WHERE CANCELSTATE='0'

    AND MTGDATE >= DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)
    AND MTGDATE < DATEADD(day, DATEDIFF(day, 0, GETDATE()), 1)
    AND MTGSTATE <> '11'
    ORDER BY START

    Thanks
  2. #2
  3. 0x800A0C93
    ASP Super Hero (2500 - 2999 posts)

    Join Date
    Jan 2009
    Location
    Ridin' through this world...
    Posts
    2,975
    Rep Power
    1310
    How is HOST0140.NAME stored?

    Does it look like:
    smith, john
    ?

    Is host0140 a table or a query?
    Brinkster- free development account. Not affiliated, but I sure like free. Brinkster.com
  4. #3
  5. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,581
    Rep Power
    278
    is any rule in name column? like first name "," last name or space and what about middle name?
    If it is a rules you can do just string manipulation...
    GK
    __________________________________________________ _____
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree
  6. #4
  7. No Profile Picture
    Registered User

    Join Date
    Mar 2010
    Location
    United States
    Posts
    11
    Rep Power
    0

    hey everyone


    just dropping by to say hi

Similar Threads

  1. Challenging To Write A Query For This Case
    By AASHAA in forum SQL Development
    Replies: 1
    Last Post: April 2nd, 2006, 10:13 AM
  2. Transcation Log
    By axisz in forum Microsoft SQL Server
    Replies: 1
    Last Post: January 25th, 2006, 03:15 AM
  3. Maxxan Rolls Out Intelligent Switch for the Midmarket (Ziff Davis)
    By RSS_News_User in forum Technology News
    Replies: 0
    Last Post: April 30th, 2005, 12:01 PM
  4. FirstName LastName Trim Problem
    By craigl in forum ASP Development
    Replies: 5
    Last Post: June 8th, 2004, 01:31 AM
  5. Insert into and update in ASP
    By bijou in forum ASP Development
    Replies: 1
    Last Post: February 6th, 2004, 08:41 PM

IMN logo majestic logo threadwatch logo seochat tools logo