Amitabh
asked on
Importing a text/excel file in sql server table (no bcp)
i need to import data from text/excel file in a table in sql server but the field structure of tables differ from the one in the file. so i think i can't use bcp or DTS. is it possible to read files through procedures? or if u can provide any alternate solution.
Even if field structures differ in file and DB, you can still use DTS.
After choosing Source and Destination, you can Transform your data. You can ignore some columns in source or destination, or you can use VBScript or JScript to do some additional transformations.
After choosing Source and Destination, you can Transform your data. You can ignore some columns in source or destination, or you can use VBScript or JScript to do some additional transformations.
ASKER
"or you can use VBScript or JScript to do some additional transformations." would be obliged if you Could plz pour some more light on this. Also (right now i don't have sql server) can i use DTS for importing files without bothering about any VBscript or Javascript coding ?
thanks...
amitabh
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for this info Rimvis infact you have already answered the main part but a small question like in oracle where we have packages to read or write in file and even create files isn't there a way in sql server to do any file manipulations.
I'm not sure I understand what do you want to do :o/
Do you want do imort text files in Oracle instead of MS SQL? No problem, just specify your Oracle server as Destination.
If you want to EXPORT data into text files, just switch Source and Destination, and re-map columns.
I hope this will help.
Do you want do imort text files in Oracle instead of MS SQL? No problem, just specify your Oracle server as Destination.
If you want to EXPORT data into text files, just switch Source and Destination, and re-map columns.
I hope this will help.
ASKER
no no....i am talking about sql server....i just gave example of oracle....
ok let me ask it this way....can i create a text file thru a stored procedure in sql server. or read a text file. i mean file manipulation which we do in VB.
since in oracle one can do it, i want to know if it is possible in MSSQL also.
ok let me ask it this way....can i create a text file thru a stored procedure in sql server. or read a text file. i mean file manipulation which we do in VB.
since in oracle one can do it, i want to know if it is possible in MSSQL also.
I've just found an article in SQL Books Online regarding your issue. If you have SQL BO installed, search for "Using a Data File with Fewer Fields" article. It's about using bcp utility to copy data from file to DB by using format file. Haven't done it myself, so I can't provide more help than this article.
As for exporting data to text file, use same bcp utility, just format SQL query in suitable way.
As for exporting data to text file, use same bcp utility, just format SQL query in suitable way.
It's been a while since I used SQL Server DTS, but if I remember correctly, it allows you to import/export to/from SQL Server using many file formats - e.g. other SQL Server DBs, Oracle DBs, text files, MS Access Databases, MS Excel spreadsheets etc etc etc.
...and the DTS interface is wizard-based so is intuitive to use. You can do more complex data transformations by adding a small-ish (depends on what you want to do) amount of vb code during the wizard process.
Rimvis has already answered this question
ASKER