Need help in using query

  • somebody please tell me how to query data like below

    table : test.dbo

    ID Desc qty

    -----------------------

    1 Oil, chem 1

    2 Oil, chem 1

    3 gas, oil 1

    4 bez, oil, gaz 1

    -----------------------

    how to show all desc = "oil" using select

    if in visual foxpro should be like ...

    "brow for alltrim("oil") $ alltrim(desc)"

    i don't know what is similar with "alltrim" in SQL server.

    Thank you all.

  • alltrim in Foxpro means strip all leading and trailling spaces. Its like doing a Rtrim(Ltrim(desc)).

    TSQL Rtrim - trims off trailling spaces

    TSQL Ltrim - trims off leading spaces

    However I don't beleive your query really needs to strip the leading or tailling spaces. I would just do a :

    SELECT * where desc like '%oil%'

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

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