473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How can I produce multiple output flat files from a single SQL filewith multiple SQL statements?

Tim
Hi Folks,

I'm used to a UNLOAD command that allows me to dump to a named flat
file the results of any SELECT statement. Hence one can build a single
SQL file which contains multiple SQL statements each of which
'unloads' to its own unique file.

unload to 'file1.txt' select * from ......
unload to 'file2.txt' select * from ......
and so on....

I have a requirement to write a stop gap set of SQL to dump 10 flat
files from SQL server 2005.
I'd like to gather all these SQL statements into 1 or 2 SQL files so
Ops have an easy life running them and to remove as much possibility
for human error as possible.

However I can't do this if I cannot dump to individual flat files the
output of each SQL statement.

RTFM got me to the 'OUTPUT' command but that only seems to place the
data into a table not a flat file so I'm back at square one.

I assume there is a way round this of which I'm unaware, can someone
please point me in the right direction.

TIA, Tim
Aug 22 '08 #1
3 8589
On Aug 22, 6:14*am, Tim <tim_roger...@hotmail.comwrote:
Hi Folks,

I'm used to a UNLOAD command that allows me to dump to a named flat
file the results of any SELECT statement. Hence one can build a single
SQL file which contains multiple SQL statements each of which
'unloads' to its own unique file.

unload to 'file1.txt' select * from ......
unload to 'file2.txt' select * from ......
and so on....

I have a requirement to write a stop gap set of SQL to dump 10 flat
files from SQL server 2005.
I'd like to gather all these SQL statements into 1 or 2 *SQL files so
Ops have an easy life running them and to remove as much possibility
for human error as possible.

However I can't do this if I cannot dump to individual flat files the
output of each SQL statement.

RTFM got me to the 'OUTPUT' command but that only seems to place the
data into a table not a flat file so I'm back at square one.

I assume there is a way round this of which I'm unaware, can someone
please point me in the right direction.

TIA, Tim
Here is a fresh article about doing it using SSIS:
"How to Dynamically and Iteratively Populate An Excel Workbook from
SQL Server"
http://www.sqlservercentral.com/links/788627/60118

Also utilizing bcp (bulk copy program) in a batch can help (See bcp in
SQL Server Books Online).

If the names and locations of the Excel files are persistent, then
creating linked server against those files and using TSQL statements
to SELECT, INSERT, UPDATE, DELETE data can be more convenient.
Aug 22 '08 #3
On Aug 22, 6:14*am, Tim <tim_roger...@hotmail.comwrote:
Hi Folks,

I'm used to a UNLOAD command that allows me to dump to a named flat
file the results of any SELECT statement. Hence one can build a single
SQL file which contains multiple SQL statements each of which
'unloads' to its own unique file.

unload to 'file1.txt' select * from ......
unload to 'file2.txt' select * from ......
and so on....

I have a requirement to write a stop gap set of SQL to dump 10 flat
files from SQL server 2005.
I'd like to gather all these SQL statements into 1 or 2 *SQL files so
Ops have an easy life running them and to remove as much possibility
for human error as possible.

However I can't do this if I cannot dump to individual flat files the
output of each SQL statement.

RTFM got me to the 'OUTPUT' command but that only seems to place the
data into a table not a flat file so I'm back at square one.

I assume there is a way round this of which I'm unaware, can someone
please point me in the right direction.

TIA, Tim
As an alternative to bcp, here is a fresh article about doing it using
SSIS:
"How to Dynamically and Iteratively Populate An Excel Workbook from
SQL Server"
http://www.sqlservercentral.com/links/788627/60118

If the names and locations of the Excel files are persistent, then
creating linked server against those files and using TSQL statements
to SELECT, INSERT, UPDATE, DELETE data can be more convenient.

Aug 22 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: googlinggoogler | last post by:
Hiya, The title says it all really, but im a newbie to python sort of. I can read in files and write files no probs. But what I want to do is read in a couple of files and output them to one...
4
by: Raj Kotaru | last post by:
Hi, In sqlplus, I can insert a single row using: insert into employee (name, salary, hiredate) values ('xyz', '86378', sysdate); Is there a modification of the insert command that will...
3
by: Mark Miller | last post by:
I have an sp that outputs multiple xml fragments w/ no root. The sp calls individual sp's to output the correct set of data and each "type" has different fields. ex.: <LEADERBOARD...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
5
by: Jeff | last post by:
We are using .Net and the wsdl Utility to generate proxies to consume web services built using the BEA toolset. The data architects on the BEA side create XML schemas with various entities in...
3
by: anuanusha29 | last post by:
Hi, I am kinda new to programming and am in the process of implementing an application which is expected to parse/read data from flat files and display errors to the user about missing/invalid...
7
by: =?Utf-8?B?QVRT?= | last post by:
HOWTO Run multiple SQL statements from ASP/ADO to an Oracle 10g. Please help, I'm trying to write an ASP page to use ADO to run a long query against an Oracle 10g database, to create tables,...
0
by: Sells, Fred | last post by:
the short answer is a file is a module; therefore to 'include' access to 'myclass' in file xyz.py from another file called 'abc.py' you would put this in abc.py import xyz #note no '.py' x =...
15
by: naveenkongati | last post by:
Hi, How do we connect a Oracle Remote server using php. Can we pass hostname,port,db,username,password into the oci_connect() function? As per oci_connect() syntax is seems to be not possible , is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.