Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Remove blank space from the beginning

Author  Topic 

pvong
Yak Posting Veteran

58 Posts

Posted - 2012-10-15 : 12:02:48
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

264 Posts

Posted - 2012-10-15 : 12:09:22
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

58 Posts

Posted - 2012-10-15 : 12:24:17
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

264 Posts

Posted - 2012-10-15 : 12:31:48
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

58 Posts

Posted - 2012-10-15 : 13:30:23
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
   

- Advertisement -