SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Remove blank space from the beginning
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pvong
Yak Posting Veteran

52 Posts

Posted - 10/15/2012 :  12:02:48  Show Profile  Reply with Quote
I have an SSIS package that imports a csv file. For some reason, when it goes into the SQL table, there are SOME values that start with " and I want to get rid of them but don't konw the TSQL to say delete " at the beginning of the value.

I double checked the CSV file and there are not spaces or special characters before the import.

Thanks in advance.
Phil

------------------------------
Using VS2010 / Learning in VB.Net / Win2008 R2 / SQL 2008 R2
Be kind to the newbies because you were once there.

malpashaa
Constraint Violating Yak Guru

Saudi Arabia
260 Posts

Posted - 10/15/2012 :  12:09:22  Show Profile  Reply with Quote
Use function LTRIM like this:
SELECT LTRIM('  ab');




For us, there is only the trying. The rest is not our business. ~T.S. Eliot

Muhammad Al Pasha
Go to Top of Page

pvong
Yak Posting Veteran

52 Posts

Posted - 10/15/2012 :  12:24:17  Show Profile  Reply with Quote
Thanks but that didn't work because I'm not trying to get rid of blank spaces. Some values are starting with the quote " and I want to actually get rid of them like an update or something and not just say a Select statement to ignore the ". I know I can get rid of the " in the Select statement by just using REPLACE like this.

Select REPLACE (value, '"', '')

Does anyone know how to actually delete just " found in values or update so it will replace " with ''?

Thanks!

------------------------------
Using VS2010 / Learning in VB.Net / Win2008 R2 / SQL 2008 R2
Be kind to the newbies because you were once there.
Go to Top of Page

malpashaa
Constraint Violating Yak Guru

Saudi Arabia
260 Posts

Posted - 10/15/2012 :  12:31:48  Show Profile  Reply with Quote
If REPLACE works in SELECT then it will work in UPDATE like this:

UPDATE TableName
   SET value = REPLACE(value, '"', '')




For us, there is only the trying. The rest is not our business. ~T.S. Eliot

Muhammad Al Pasha
Go to Top of Page

pvong
Yak Posting Veteran

52 Posts

Posted - 10/15/2012 :  13:30:23  Show Profile  Reply with Quote
This worked Perfectly!!!! Thanks!

------------------------------
Using VS2010 / Learning in VB.Net / Win2008 R2 / SQL 2008 R2
Be kind to the newbies because you were once there.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.17 seconds. Powered By: Snitz Forums 2000