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
 Design question.

Author  Topic 

crugerenator
Posting Yak Master

126 Posts

Posted - 2009-03-06 : 17:07:37
I "inherited" a program that reads from a .csv. Recently I've been having to add new records to this file and it's the most mind numbing boring thing in the world, so I decided to make it easier. Currentlly, I have to copy/paste an existing line and then copy/paste a few new fields over the existing fields. The majority of the data remains constant, and only a few fields are changed. What I'm going to do is create a web form that inserts the necessary new data into a SqlServer2005 db, and the database will export the table as a .csv for the program to read from (The program needs to read from a .csv, otherwise I would skip this step and have it read directly from the db).

Here's an example of the .csv file:

first_num, sec_num, const_1, const_2, email, const3
076543,076543,1stConstant,2ndConstant,myemail@gmail.com,3rdConstant
083617,083617,1stConstant,2ndConstant,newemail@gmail.com,3rdConstant
578542,578542,1stConstant,2ndConstant,xtraemail@gmail.com,3rdConstant

^sorry, don't know why the above is underlined.
It's basically acting as a flat file database.

My question is, do I add the rows that are constant into my insert statement? ex:

INSERT INTO Table (first_num, sec_num, const_1, const_2, email, const3)
VALUES (@firstnum,@sec_num,'1stConstant','2ndConstant',@email,'3rdConstant')


or do I somehow have the constants populate automatically when a new record is generated?

or, can I possibly add the constants when I'm exporting the table to a .csv?

My problem is obviously a little more complex than the example, and there are multiple .csv files that are filled with slightly different sets of data. I'll design the db to store the data correctly, and write views that include only the necessary fields in the necessary order, and export those views.

Thanks in advance. Let me know if you have any Q's.

guptam
Posting Yak Master

161 Posts

Posted - 2009-03-06 : 21:23:41
Hi,

The constants are they a code table format? That is a lookup where it is limited to that list only? Other CSV are they of similar format?


--
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCITP: Database Administrator
MCTS: SQL Server 2005
http://sqllearnings.blogspot.com/
Go to Top of Page
   

- Advertisement -