x

How to create these type of files?

i have file/table in my database with the following format

account_name (blank) Trade_date Price
sam            by    09012010   102.3
jaz            by    09012010   101.8
mike           by    09122010   104.3
sam            by    09132010   105.5 

i want to achieve the output like this first of all a file should be created as (account_number).dex

so foe example :- file created sam.dex with entries like

sam            by    09012010   102.3
sam            by    09132010   105.5

2 nd file created:- jaz.dex with entries

jaz            by    09012010   101.8

3rd file created:- mike.dex with entries

mike           by    09122010   104.3

How to achieve this output? thanks in advance!!!

more ▼

asked Apr 20, 2011 at 07:05 AM in Default

AbhiD gravatar image

AbhiD
171 15 15 17

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first
Are you looking for this to be dynamic to be able to include any new account numbers that come in or is your data set going to remain static? If static a simple DTS, SSIS, or even TSQL statements using SQLCMD could pipe the results out to file. What version of SQL are you running and what are your full requirements?
more ▼

answered Apr 20, 2011 at 10:04 AM

Tim gravatar image

Tim
36.4k 38 41 139

The number of entries in my source file will be dynamic ..sometimes it may be 10 records and sometime it can reach 100 also. i m using sql server 2005. Can u tell me what should be the approach if i plan to use ssis?
Apr 20, 2011 at 01:17 PM AbhiD
You could use a foreach loop and get the distinct account number, then pass each account number to a stored procedure or query to get the individual result set per account number. Those results could be written to individual files and use the account number in the output file name.
Apr 20, 2011 at 01:21 PM Tim
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x943
x292

asked: Apr 20, 2011 at 07:05 AM

Seen: 675 times

Last Updated: Apr 20, 2011 at 07:05 AM