Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello community

I'm trying to do the following:

1- I did a stored process via a parameter input, where some validations ago and finally generates a txt file.
2- text file is created on a path that was defined in the code


  The process generates the file successfully. My question is how can I run this file or open

SQL
SET @querytext = '"SELECT Descr FROM ##tbl WHERE lote = ' + @Lote + '"'
     SET @filelocation = '"C:\Microsoft Dynamics\SL\Applications\LogFacturacion\LOGERROR'+@Batch+'.txt"'
     SET @cmd = 'bcp ' + @querytext + ' queryout ' + @filelocation + ' -T -c -d '
     EXEC master..XP_CMDSHELL @cmd, NO_OUTPUT


But I need open that text file created windows explorer


Greetings
Posted

1 solution

Try
System.Diagnostics.Process.Start(filelocation);

where filelocation is set to the same string as @filelocation above.
 
Share this answer
 
Comments
Salomon Pineda Silva 30-Mar-15 13:58pm    
that code line is SQL?
Mark Farmiloe 30-Mar-15 15:01pm    
Oops, my mistake. But could you just use master..XP_CMDSHELL again, something like
SET @cmd = 'start C:\Windows\system32\Notepad.exe ' + @filelocation
EXEC master..XP_CMDSHELL @cmd, NO_OUTPUT

There may be permissions problems with this.
Salomon Pineda Silva 31-Mar-15 14:40pm    
none result the only that make the management say executing query nothing else

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900