Showing posts with label txt. Show all posts
Showing posts with label txt. Show all posts

Wednesday, March 7, 2012

MSSQL to Text File? how? thanks...

As we know, MySQL have function to output its data into Text File using "Select * into outfile 'C:/mytext.txt".

Does MSSQL has "Select into Outfile" function? If yes, what is the function??

Thanks in advance :)

Anderson

Do you have access to the SQL Manager GUI? You can output to a file from that.

You can also useSQLCMD -i Input.sql -o C:\mytext.txt -e from the command prompt.

|||P.S. - I'm not positive, but I don't think you can do it directly from the SQL statement like you can in MySQL.|||

You can use supplied BCP application or SQL Server Management Studio Express.

Example for BCP:

c:\Program Files\Microsoft SQL Server\90\Tools\Binn>bcp RZBWSPR.dbo.MenuItem out Result.txt -T -S DVESIC\SQLEXPRESS -c

|||You can call bcp utility with xp_cmdshell from T-SQL. Take a look at this post:
http://forums.asp.net/thread/1388531.aspx

Monday, February 20, 2012

MSSQL Select commands to FTP

Hello,

Im new to Sql Server Integration Services.

I need to get the data I get from my SQL Select statement into TXT, XML, CSV or Excel file format and then send it with FTP.

What is the easiest method that you recommend that I use?

Thank you very much!!

Data flow to select your records using an OLE DB source. Send those records to a text file (or csv) using the flat file destination.

Then in the control flow, use the FTP task to send that file.|||

Thank you very much for the reply.

I know this sounds simple, but do you know any tutorial out there that shows how to do this?

Thanks again in advance.

|||Try looking through the SSIS tutorials. What you need is pretty basic stuff.

http://msdn2.microsoft.com/en-us/library/ms167031.aspx|||

Thank you so much.

I have one complexity though.

My SSIS flow is gonna be run every day as a sceduled task.

The first time it runs, it has to send a History (Select Statement 1) but every day after that it just has to get the latest info (Select Statement 2).

How do I do this?

Thank you very much in advance!!

MSSQL Script execute in .bat

Hi Guys, anyone out there who could help me with my problem?

I have created a .bat file that would execute the mssql script and give an .txt file as an output. The script run successfully except for the output, the output save as .txt file was not in order unlike the output that was derrived from the query analyzer. As I try to solve my problem I observe that the lines separating the header and the data was the cause of un-order format, the lines doubles its length when I use the .bat file to execute my script. I have tried using the substring syntax to limit the length but same results achieved. Could anyone help me to remove those line automatically when I run my .bat file?

Please see the outputs below. Thank you very much.

output from query analyzer

object_name counter_name
-------- -----------
SQLServer:Buffer Manager Buffer cache hit ratio
SQLServer:Buffer Manager Buffer cache hit ratio base

(2 row(s) affected)

ouput from .bat

object_name
counter_name
----------------
----------------------
SQLServer:Buffer Manager
Buffer cache hit ratio
SQLServer:Buffer Manager
Buffer cache hit ratio baseFor anyone who will encounter same problem as I did, the solution for my problem was on the .bat file and not in MSSQL. I added the -W in the command in my .bat file.