I am using Visual Studio 2010. My database is SQL Server. I have a static link which has daily updated data in .txt format (it is a tab (space) separated file). I want to import the data from the .txt file to the SQL Server database. This is to be done daily. Hence I can schedule it on the SQL Server to run everyday. The scheduling is done.
Can someone please help me to write the script for the import? And I can’t use BULK command. Is there anyway to do this? Please help.
Thanks.
If you cannot use the
BULK INSERTstatements (again: why??), then my best bet would be to create a small console app that woulddownload that file from the static URL
use the FileHelpers library to load the
.txtfile into memory (it does this very well and very easily – you define the structure as a C# class, and don’t have to worry about anything else anymore…)use a SQL Server stored procedure or a parametrized SQL inline query to store the entries – one by one – into your SQL Server table
Once you have that console app, use the Windows scheduled tasks facility to run this app once e.g. every morning or whatever your schedule is.