trim spaces

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lillyehrhart
    New Member
    • Jun 2015
    • 48

    trim spaces

    i have this sql statement and i want to trim off any leading spaces, how i do that
    Code:
    SELECT tbl_Bills.[DATE ENT] AS DATE_ENT, tbl_Bills.[Date] AS SHIP_DATE, dbo.tbl_Bills.CARRIER, dbo.tbl_Bills.PRO, dbo.tbl_bills.spec_fedinv, dbo.tbl_Bills.SHIPPER, dbo.tbl_Bills.CONS, dbo.tbl_Bills.F_B, dbo.tbl_Bills.LOC, dbo.tbl_Bills.PCS, dbo.tbl_Bills.WT, dbo.tbl_Bills.NET_CHGS, tbl_Bills.[DATE PAID] AS DATE_PAID, tbl_Bills.[CK NO] AS CK_NO FROM dbo.tbl_Bills INNER JOIN dbo.[tbl_Bills LOCATIONS] ON dbo.tbl_Bills.[Customer Name] = dbo.[tbl_Bills LOCATIONS].[Customer Name] AND dbo.tbl_Bills.LOC = dbo.[tbl_Bills LOCATIONS].[WD LOCATION]
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Depending on what database you're using, you can use either the TRIM() or LTRIM() functions on the fields you want to trim.

    Comment

    • lillyehrhart
      New Member
      • Jun 2015
      • 48

      #3
      so i would just do this?

      Code:
       trim(dbo.tbl_Bills.CARRIER)
      when i did that before it didnt like that.

      Comment

      • madankarmukta
        Contributor
        • Apr 2008
        • 308

        #4
        bills.CARRIER - what is the datatype of this. Seems to be of the type string. If so, as Rabbit suggested depending on the Database you can use TRIM or LTRIM functions.

        Hope this resolves your problem.

        Comment

        • lillyehrhart
          New Member
          • Jun 2015
          • 48

          #5
          i am pulling this field from my ms access database, tbl_bills is the table in my dbo and carrier is the field in that table. when i put the whole thing in

          Code:
           trim(dbo.tbl_bills.carrier)
          it does not like that
          Last edited by lillyehrhart; Oct 2 '15, 02:55 PM. Reason: didnt put coding correctly

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            What do you mean it doesn't like it? You need to be more specific. And please post the full updated code.

            Comment

            Working...