December 18, 2008 at 5:13 am
I am using foolowing command to create text file:
Declare @filecontents varchar(150)
Declare @strcmdshell varchar(150)
set @filecontents = ' '
set @strcmdshell = 'echo '+@filecontents+' > c:\testting.txt '
exec master..xp_cmdshell @strcmdshell
when i run above command in query anlyzer
i got error: "> was unexpected at this time."
I want in text file.
can u solve this issue, how can i create file? any way?
December 18, 2008 at 7:45 am
You have to use a doube >> to pipe the results to a file at the command prompt.
Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
My Blog | Twitter | MVP Profile
Training | Consulting | Become a SQLskills Insider
Troubleshooting SQL Server: A Guide for Accidental DBAs[/url]
December 18, 2008 at 7:46 am
What version of SQL Server are you on currently? If you are on SQL 2005, a CLR procedure with EXTERNAL ACCESS would be a much more secure method of doing this process.
Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
My Blog | Twitter | MVP Profile
Training | Consulting | Become a SQLskills Insider
Troubleshooting SQL Server: A Guide for Accidental DBAs[/url]
December 18, 2008 at 11:58 pm
Sorry @filecontent is not displayed, bec it contains open tag ' '
so, can u tell me, how can i write ' ' in file ?
December 19, 2008 at 5:46 am
What do you want it to contain specifically?
Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
My Blog | Twitter | MVP Profile
Training | Consulting | Become a SQLskills Insider
Troubleshooting SQL Server: A Guide for Accidental DBAs[/url]
December 19, 2008 at 7:42 am
I use something like
[font="Courier New"]'type filename.txt > a.txt'[/font]
** NOT ** [font="Courier New"]'type filename.txt' > a.txt [/font] as in "greater than"
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply