query problem

  • Hello everyone,

    i have a

    table in sqlserver 2000, in this i have a column "Name" with the following data::

    Name

    Ali Sheikh

    Umer Aftab

    Waseem

    Vidya Balan

    now i want

    to write a query to get the first part of the name ,e.g my query return the follwing result:

    Ali

    Umer

    waseem

    Vidya

    and then

    i stored this in my new column "MiddleName",

    tell me the query plz

    its very urgent

    plz reply me asap.

  • very simple....

    select (case when charindex(' ',name) > 0 then substring(name,1,charindex(' ',name)) else name end) from your_table

     

     

    --Ramesh


Viewing 2 posts - 1 through 1 (of 1 total)

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