Extract data into specific csv columns?

Extract data into specific csv columns?

Hello,First off I am new to this forum and don't know much about sql. I guess that's why I am here :-) I hope I am in the right forum.

I'm hoping someone can lead me in the right direction here. I have a sql query that was written for me some time ago. I need to have the data placed in specific columns and rows within the csv file. Is it possible for me to do this? Here is what I have below... Lets say I need to place "ASSRREAL.Street" in column D row 3 of the csv file. Any help or ideas would be great. Even if there's a 3rd party tool that would allow me to do this? Thanks

Tony414 (4/23/2013)Hello,First off I am new to this forum and don't know much about sql. I guess that's why I am here :-) I hope I am in the right forum.

I'm hoping someone can lead me in the right direction here. I have a sql query that was written for me some time ago. I need to have the data placed in specific columns and rows within the csv file. Is it possible for me to do this? Here is what I have below... Lets say I need to place "ASSRREAL.Street" in column D row 3 of the csv file. Any help or ideas would be great. Even if there's a 3rd party tool that would allow me to do this? Thanks

Tools like bcp or SSIS will allow you to extract data from a database and write it to a text file, of which a csv is just one type. bcp can only extracts data into text files. SSIS can extract data into almost any file format as well as talk to other database platforms. If you're just starting out bcp is a simpler option, but if you invest time in learning SSIS it will pay you back 100-fold since it will allow you to bridge the gap between your SQL Server database and every other relevant data platform in use.

As for how to get your data into the third line of the file? Most data extraction tools will write the resultset to the file as it is returned from the database. If you need a specific ordering in your file, then you would control that via an ORDER BY clause onyour SELECT query, of which I see there is one. If you want your data in line 3 of the file, what would you expect to be in line 1 and 2?

PS In future posts if you surround your code with the IFCode for "sql code", [code="sql"][/code], then your post will show up with syntax highlighting.

__________________________________________________________________________________________________There are no special teachers of virtue, because virtue is taught by the whole community. --Plato