By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,054 Members | 1,301 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,054 IT Pros & Developers. It's quick & easy.

trim spaces

P: 48
i have this sql statement and i want to trim off any leading spaces, how i do that
Expand|Select|Wrap|Line Numbers
  1. 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]
Oct 1 '15 #1
Share this Question
Share on Google+
5 Replies

Expert Mod 10K+
P: 12,408
Depending on what database you're using, you can use either the TRIM() or LTRIM() functions on the fields you want to trim.
Oct 1 '15 #2

P: 48
so i would just do this?

Expand|Select|Wrap|Line Numbers
  1.  trim(dbo.tbl_Bills.CARRIER)
when i did that before it didnt like that.
Oct 2 '15 #3

P: 293
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.
Oct 2 '15 #4

P: 48
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

Expand|Select|Wrap|Line Numbers
  1.  trim(dbo.tbl_bills.carrier) 
it does not like that
Oct 2 '15 #5

Expert Mod 10K+
P: 12,408
What do you mean it doesn't like it? You need to be more specific. And please post the full updated code.
Oct 2 '15 #6

Post your reply

Sign in to post your reply or Sign up for a free account.