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
 RTRIM(LTRIM()) for import
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Robowski
Posting Yak Master

101 Posts

Posted - 02/25/2013 :  06:59:41  Show Profile  Reply with Quote
If importing directly from a csv file, is it possible to apply the rtrim(ltrim function for the direct import?


BULK
INSERT
#table
FROM
'\\filepath'
WITH
(
FIELDTERMINATOR = ','
,ROWTERMINATOR = '\n'
)

or is it simply a case of running the below after it?

UPDATE
#Table
SET
field1 = LTRIM(RTRIM(UPPER(field1)))
,field2 = LTRIM(RTRIM(UPPER(field2)))
,field3 = LTRIM(RTRIM(UPPER(field3)))
,field4 = LTRIM(RTRIM(UPPER(Gfield4)))

James K
Flowing Fount of Yak Knowledge

3741 Posts

Posted - 02/25/2013 :  07:28:50  Show Profile  Reply with Quote
Bulk insert does not have an option that will allow you to intercept the data on its way into the table and LTRIM/RTRIM it. What you suggested - updating the table after the insert - is perhaps the best course of action.
Go to Top of Page

Robowski
Posting Yak Master

101 Posts

Posted - 02/25/2013 :  10:23:05  Show Profile  Reply with Quote
quote:
Originally posted by James K

Bulk insert does not have an option that will allow you to intercept the data on its way into the table and LTRIM/RTRIM it. What you suggested - updating the table after the insert - is perhaps the best course of action.



Thanks
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.06 seconds. Powered By: Snitz Forums 2000