January 23, 2008 at 2:13 am
hehehehehehe, I like your thinking mate 🙂
Yes I am actually,I used it recently on a different program.
January 23, 2008 at 5:21 am
Ok, thanks for the info. I'll see what I can do tonight after work.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 23, 2008 at 5:51 am
January 23, 2008 at 6:23 am
Certainly not... but I don't use DTS or SSIS for several reasons... wanna give it a try for us? Because I don't use it, I wouldn't know where to start with either of those two especially converting the word "NULL " to an actual null.
I'll take a slightly different approach tonight...
--Jeff Moden
Change is inevitable... Change for the better is not.
January 23, 2008 at 6:55 am
Ok, cool.... A simple data transformation task between the source file and the destination table would remove the trailing spaces in the fields.
In English, the DTS package (attached as .zip file as .dts files are not acceptable uploads :crazy: ) transfers the data from the source file to the target table, substitutes NULL for 'NULL' and empty cell values.
To set up the DTS package on your server:
1. Save the File
1.0 Save the .dts file to a directory accessible by the SQL Server.
2. Open the package
2.1 In Enterprise Mangler, right-click on Data Transformation Services.
2.2 Click on Open Package.
2.3 Navigate to saved .dts file.
2.4 Click Open
2.5 Click on ssc_example_002
2.6 Click OK.
This will open the package in DTS designer. I have annotated the package with the step by step instructions required. You can then save the package to your server by:
3. Save the package to the server
3.1 Click on Package on the Menu bar.
3.2 Click on Save as...
3.3 Give the package a useful package name.
3.4 Change the location to SQL Server.
3.5 Choose the server to save it to (don't forget security info if required)
You should then be able to run the package; you can use the green play button in the package designer to run it.
If you get any trouble with it just give us a shout.
January 23, 2008 at 7:11 am
Very cool... with your great instructions, I'll just bet I learn something new! Thanks, Adrian...
I'll bet the OP will like it, as well!
I'll still take a brute force whack at it tonight... Gotta do that for myself, anyway... maybe I've been wrong about DTS.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 23, 2008 at 8:11 am
I suppose it depends on the individual; for some reason I have a penchant for DTS and SSIS. Although I also enjoy seeing if I can get a T-SQL based solution for scripts that I write in my DTS ActiveX tasks....
Maybe I need to get out more?! 😛
January 24, 2008 at 1:17 am
Hey guys,
I don't know what to say? Thanks a lot for all the support!!! I'm overwhelmed!!!
Just to let you know, I won't be using DTS/SSIS packages for this scenario.
One of the reasons is that I have already started a procedure which can currently import comma delimited, fixed length, and tab delimited files using Bulk insert and Format files!
Great instructions though...! Bravo!!! 😉
January 24, 2008 at 3:12 am
Hi,
I noticed that on your example of your Format file you have 59 columns defined whereas the file you are importing only has 56 columns. The last line in your format file should therefore be:
56 SQLCHAR 0 10 "\r" 56 P2_EndDateAtAddress ...
I have attached a zip file that contains 3 files - a sample input from the data supplied, a format file containing the information for the 56 columns(watch out for my collation, you may need to change this) and a T-SQL script file. The T-SQL recreates the JobTable table and utilises BULK INSERT with the format file to insert the data in to the table. There are then UPDATE statements (that I took from the previous DTS package) to update 'NULL' and empty string values to actual NULL values.
Hope this helps,
January 24, 2008 at 6:06 am
I obviously need more coffee... Adrian, who was that last post of yours directed to?
--Jeff Moden
Change is inevitable... Change for the better is not.
January 24, 2008 at 6:09 am
Emmanouil Karaiskakis (1/24/2008)
Hey guys,I don't know what to say? Thanks a lot for all the support!!! I'm overwhelmed!!!
Just to let you know, I won't be using DTS/SSIS packages for this scenario.
One of the reasons is that I have already started a procedure which can currently import comma delimited, fixed length, and tab delimited files using Bulk insert and Format files!
Great instructions though...! Bravo!!! 😉
So, does that mean you're all set or do you still need help on this?
--Jeff Moden
Change is inevitable... Change for the better is not.
January 24, 2008 at 6:10 am
January 24, 2008 at 7:37 am
Hi,
That was way more stuff than I need hehe! You really work hard in here! Very impressed.
I only needed a format file sample. The format file is very similar to my comma delimited format file...!
Does that mean that the bulk insert ignores all spaces between the right of the last letter and the comma?
The reason I am asking is that, as said earlier, the structure of this crappy data is like this:
imagine that zero is space (the forum get rid of spaces lol)
field1000000000000,field2000000000000,NULL,field3000000000000,field4000000000000
field1000000000000,field2000000000000,NULL,field3000000000000,field4000000000000
field1000000000000,field2000000000000,NULL,field3000000000000,field4000000000000
field1000000000000,field2000000000000,NULL,field3000000000000,field4000000000000
Will the format file you gave me deal with all those spaces?
January 24, 2008 at 8:26 am
The format file should ignore any spaces that are over the specified length; sadly I don't think that it'll strip out spaces such as (using the 0s for spaces again and a string length of six) :
Samuel000 = Samuel but Jane00000 would be Jane00
You're table definition has the columns as CHAR which would pad the result with spaces anyway. If you change the CHAR columns to VARCHAR this would automatically rid all of the extra spaces on import.
January 24, 2008 at 10:09 am
there must be something wrong with the data then because it doesnt work...hehe
nevertheless I'll work it out. thank you for all this information. I really appreciate it 🙂
Viewing 15 posts - 16 through 30 (of 58 total)
You must be logged in to reply to this topic. Login to reply