May 13, 2013 at 9:51 am
dear Gurus,
I want to export data in table to txt
SELECT [StatBeginTime]
,[MDASum]
,[BureauName]
,[MDA]
FROM [kpidb].[dbo].[t_MDA_1]
the result :
2013-05-13 00:14:00.000290bjm261651
2013-05-13 00:29:00.000226bjm203767
2013-05-13 00:44:00.000174bjm15730
how to process so can create file txt in c:\\ directory ??? many thanks
May 13, 2013 at 12:33 pm
trisno (5/13/2013)
dear Gurus,I want to export data in table to txt
SELECT [StatBeginTime]
,[MDASum]
,[BureauName]
,[MDA]
FROM [kpidb].[dbo].[t_MDA_1]
the result :
2013-05-13 00:14:00.000290bjm261651
2013-05-13 00:29:00.000226bjm203767
2013-05-13 00:44:00.000174bjm15730
how to process so can create file txt in c:\\ directory ??? many thanks
Is this a one time export or something you need to do routinely?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 13, 2013 at 5:13 pm
Thank you Sean Lange,
This is routine work and will be running every hours, thanks
May 14, 2013 at 4:41 am
You can run a Sql Command in the scheduled job to do the desired task for you. Following is the syntax for the same.
SQLCMD -S YourSQLServer -d YourDatabase -U YourUserName -P YourPassword -Q “Your Query” -s “,” -o “C:\Yourfilename.csv"
Feel free to get back in case of any issues.
May 14, 2013 at 11:35 pm
HI Bhavpreet Singh Narang,
I have try your command but there were error :
For My Server Name : 10.67.172.202
Database Name : morscdb
Table name for query : dbo.AO_MT
the error like below :
:\Documents and Settings\Administrator>SQLCMD -S 10.67.172.202 -d morscdb -U sa
-P sa -Q "Select* FROM dbo.AO_MT" -s "," -o "C:\Yourfilename.csv"
sqlcmd: 'FROM dbo.AO_MT"': Unexpected argument. Enter '-?' for help.
which one is wrong ? thank you
May 15, 2013 at 1:17 am
Hi,
I could replicate the issue you are facing the copying the template query and pasting it in command prompt after making the required changes.
Workaround: Just type the whole command in the command prompt and it will surely work
I guess, there is some special character\Unicode conversion of space or something is causing an issue.. Not sure.. Let me know if you could find the exact culprit..
Regards
Bhav
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy