.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

SQLCMD timestamp output file

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net
 

Hi All,

   I am using SQLCMD to execute a script and then output the results to a csv file. Is it possible to name the output file with a timestamp each interval that it is executed (such as every 30 minutes that the command is executed to timestamp like "output 10/25/10 830.csv"?

 

Thank you in advance,




View Complete Post


More Related Resource Links

SQL Agent Jobstep output file contains automatically generated header

  
Hi,   I've created a stored procedure that creates a script to create a number of objects within the database (based on what existing objects are in the database).  From Management Studio, this works fine, and the output is exactly as I want it.   I'm now trying to create a job that will execute this stored procedure, and deposit the results into a file somewhere on the server.  When the job runs, the script is created in the correct place and is essentially ok.   However, there are a couple of questions I'd like to ask.   Why does SQL Server Agent put a header at the top of the output file?  I was hoping to be able to use that output file 'as is' and execute it automatically to recreate my objects when required.  (Obviously, I can manually remove the header, but this is an inconvenience in this situation).  How do I stop it?   Also, when executed from SSMS, the output is correctly line-spaced.  But, the output from the scheduled job adds an extra line between each line of text, which is, again, inconvenient.  Why does it do this, and how can I prevent this (again, without manually editting the output)?   Any thoughts and help greatly appreciated.   Cheers Simon

FileStreamResult how to rename the output file?????

  
i have an action to return a pdf file in my controller,if the return file is for downloading, the following code can be used to modify filename successfully.HttpContext.Response.AddHeader("content-disposition", "attachment; filename=form.pdf");HOWEVER, i found that when the pdf file was returned to browser( rather than a pop up window to download), the filename always remain same as the action name! (when u right click file and try to save it on ur hard disk), i was wondering if there is a automatic way to rename the file rather than "right click" and "save as" manually.so  can anyone tell me how to rename the outputfile when it is shown in the browser?

Sql Server 2005 ( remove header information from query output file "Job 'bustd_Daily_Query_Output_1

  
Dear All,I have scheduled job for querying output & asve it into particuler folder....but in the top of file i getting the message like "Job 'bustd_Daily_Query_Output_13July09' : Step 1, 'Query1' : Began Executing 2009-07-13 16:32:06"I want to remove this & want output in txt file format without above header....RegardsRavendra Cindia

Output Blank Text File

  
Hello all,I have come across an interesting edge case when using Response.Write. I couldn't find another forum to post this in, so I'm putting it here, even though its not really "getting started" in my mind.The scenario goes like this:I have a ASPX page that stores data in a string using a comma delimited text format, which is then written to the response stream using Response.Write. Whenever there is data, this works fine. But, when there is no data, the string generated is empty and a basic HTML page structure magically appears in the output even though it isn't even in the .ASPX file. What I'd like to do is simply return a blank text file (not even a space).I've tried using Response.Clear to ensure that there is no content in the response stream. I've tried setting the content type and even specifying a filename in the response header. I am, of course, also using Response.End after the call to Response.Write, but all to no avail. The response is always a basic HTML structure.To eliminate other possibilities, I've set up a test. Just a default .ASPX Web form with the following PageLoad method: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Response.ContentType = "text/plain" Response.Clear() Response.Write("") Response.End() End Sub

Execute a SSRS Report from CRM using URL to output to PDF with a specific file name

  

We have a CRM installation from which I am trying to do some reports which use the CRMAF filters so the reports are sensitive to entitiy selections.

eg execute a sales report for a number of selected accounts.

The specific RDLs have been created in VS2008 and uploaded to the reporting server via the Report import tools within CRM and all work as expected however the output of the report is in HTML via the web browser.

I have changed the configuration of the report in CRM so that it uses the URL method like below so that the report is rendered into PDF which is great.

http://servername/reportserver?/Sales/YearlySalesSummary&rs:Command=Render&rs:Format=PDF

 

This method prompts for the user to open/save the PDF file which is acceptable however I would like to replace the default file name (which is the report name) with one of my own.

For example rather

Non Delimited Header in a delimited output file

  

 

I have a requirement to make a delimited flat file from a data base table.  The table has some 20+ columns.   I totally understand how to accomplish this part.  What is a bit more  tricky is that I need to create a header row that is not delimited.  The final output would look something like this

 

$header –Opt1 –Opt2 20101005

DBCol1|dbCol2|DbCol3

Stale security timestamp error encountered in the middle of a large file transfer

  

I have two WCF services configured as Windows Services for both client and server that perform file transfers for DR replication. I'm using chunked streaming with a wsHttpBinding.

One of the files I am testing with is 58MByte, and after it has been going for 5 miinutes it throws a stale message exception

System.ServiceModel.Security.MessageSecurityException: The security timestamp is stale because its expiration time ('2010-10-07T20:36:25.322Z') is in the past. Current time is '2010-10-07T20:44:34.155Z' and allowed clock skew is '00:05:00'.

The problem is not clock skew because the two servers are within a minute of each other, and the transfer proceeds just fine until it reaches the 5 minute mark.  It's comparing the time at the beginning of the transfer to current time.  If got the receiveTimeOut set to 59 minutes.

I've seen posts about creating a custom binding to increase the clockSkew tolerance, but this seems to be more of a timeout issue.

Any ideas?

 

 

// get the stream from the remote server, copy it to a local file stream.

                                        stream1 = client.Get

Sql Server Agent failed to executed a scheduled bat file that contains sqlcmd command

  

Hi All:

I am currently using Windows 2003 R2, Standard Edition.
I have Microsoft Sql Server 2005 Installed with the latest service pack which is sp3.
I logged into the operating system as an administrator. The windows administrator id is "test2".
I logged into the Microsoft Sql Server 2005 database using "Microsoft Sql Server Management Studio" as an "sa" which is database admin.
I placed a bat file called "test1.bat" in the directory c:\test3, the file "test1.bat" contains the following content:

sqlcmd -b -e -Q "ALTER INDEX ALL ON [JOHNDATABASE].dbo.TABLE2 REBUILD"

In the dos-prompt, I can run the "test1.bat" batch file with no errors.
It gives me the following output:
c:\test3\sqlcmd -b -e -Q "ALTER INDEX ALL ON [JOHNDATABASE].dbo.TABLE2 REBUILD"
ALTER INDEX ALL ON [JOHNDATABASE].dbo.TABLE2 REBUILD

Using "Sql Server Agent", I created a new job called "Scripts1".
For the "General" link, I have the following values:
Name:test2
Owner:SA
Category:Database Maintenance

For the step link, I have the following values:
Step Name:test2
Type:Operating system(CmdExec)
Run As:SQL Agent Service Account
Command:
sqlcmd -b -e -Q "ALTER INDEX ALL ON [JOHNDATABASE]

Sql Server Agent failed to executed a scheduled bat file that contains sqlcmd command

  

Hi All:

I am currently using Windows 2003 R2, Standard Edition.
I have Microsoft Sql Server 2005 Installed with the latest service pack which is sp3.
I logged into the operating system as an administrator. The windows administrator id is "test2".
I logged into the Microsoft Sql Server 2005 database using "Microsoft Sql Server Management Studio" as an "sa" which is database admin.
I placed a bat file called "test1.bat" in the directory c:\test3, the file "test1.bat" contains the following content:

sqlcmd -b -e -Q "ALTER INDEX ALL ON [JOHNDATABASE].dbo.TABLE2 REBUILD"

In the dos-prompt, I can run the "test1.bat" batch file with no errors.
It gives me the following output:
c:\test3\sqlcmd -b -e -Q "ALTER INDEX ALL ON [JOHNDATABASE].dbo.TABLE2 REBUILD"
ALTER INDEX ALL ON [JOHNDATABASE].dbo.TABLE2 REBUILD

Using "Sql Server Agent", I created a new job called "Scripts1".
For the "General" link, I have the following values:
Name:test2
Owner:SA
Category:Database Maintenance

For the step link, I have the following values:
Step Name:test2
Type:Operating system(CmdExec)
Run As:SQL Agent Service Account
Command:
sqlcmd -b -e -Q "ALTER INDEX ALL ON [JOHNDATABASE]

File do exist in the output directory, But always FileNotFound Exception

  

Hi all,

I have a solution with several projects, some of them are C# whlie others are C++.net. the c++ projects are used as reference libraries for the c# projects.

the solustion can be complied and run well in 32-bit system, but when i built it in 64-win7, I  change all project to win32 platform.  when i managed to build the solution, and try to run  from one of the c# form appliction project which depend on on c++ project, there alway throw fileNotFoundException as follow:

System.IO.FileNotFoundException was unhandled
  Message=Could not load file or assembly 'CvAdapter.dll' or one of its dependencies. The specified module could not be found.
  Source=GraphicResarch
  FileName=CvAdapter.dll
  FusionLog=""
  StackTrace:
       at GraphicResarch.DisplayForm..ctor()
       at GraphicResarch.Program.Main() in D:\Develop\Code\AIStudio\AISeeStudio\GraphicResarch\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at

How to output data from master detail tables into text file but on different lines.

  

Hi,

I have a requirement to output data from two tables, a master table and a detail table, to a text file such that the output looks like the following:

master record 1

detail record  1 1

detail record   1 2

master record 2

detail record  2 1

master record 3

detail record 3 1

detail record 3 2

detail record 3 3

etc.

 

Is this possible in one query?  I am sufficiently familiar with the bcp utility to do the output from any of the tables separately but have some difficulty with doing it for the two tables and have the result structured as outlined above.


CS0016: Could not write to output file 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP

  

Hello,

I keep getting this error:

CS0016: Could not write to output file 'c:\WINDOWS.0\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\42d038b5\b838d243\App_Web_master.master.cdcab7d2.lwqjolwv.dll' -- 'Access is denied. '

So, what I did is to set Full control to NETWORK_SERVICES user to both 'Framework\v2.0.50727\Temporary ASP.NET Files' and %temp% folder.

But still the error exist ....

What do I do next?

could it be a specific code I am trying to excute on the master page?

 

 

THANKS

 


Problem redirect debug output to a file using trace listener

  

I have created a debug listener to redirect the output from the Debug/Console window to a file(with a call stack), using the following code:

void SomeMethod()
{
    // Create a file for output .txt.
    Stream debugFile = File.Create(fileName);

    // create TextWriterTraceListener named "file"
    TextWriterTraceListener debugWriter = new TextWriterTraceListener(debugFile, "file");

    // add to debug listeners
    Debug.Listeners.Add(debugWriter);
    // set callstack to be shown
    Debug.Listeners["file"].TraceOutputOptions |= TraceOptions.Callstack;
    // set auto-flush
    Debug.AutoFlush = true;
}

but the output won't redirect to the file I specified, it is always empty. I am calling this from the constructor in my main form. Is the place where I'm calling it from a problem?

What I am trying to achieve here is to have the exceptions from the Debug output window placed in a file with a call stack, so that I can find them and correct them.

Anyone have any ideas?


Bojan Skr

SSIS 2008 and output txt file of specifies structure

  

Hi All.
I have query to Oracle 11.

I need to iterate it and make txt file (UTF8).
In fact it consist of header + body + footer
body is made of records like:
"Afghanistan","Aland Islands","Albania"
values of in quotes. (in fact it is json file)

1?) Can I do it w/o script
 using Foreach Loop Container
 I don't see how to do
S_all = S_all + ',"' + field1 + '"'
where S_all is SSIS var

2?) If use script in data flow
Could anybody give code example (bettre in VB but C# also ok)
how to iterate recordset and make var like:
S_all = S_all + ',"' + field1 + '"'


File Splitter in .Net

  
I love to do utility programs in .Net. And this is one of them. As I was playing with JSplit (a free file splitter program), I wondered if I could do it in .Net. The framework supports file operations like reading files in bytes and creating them. It is indeed easy to do file operations in .Net Basics on File operations

Upload Multiple File using JQuery in asp.net

  
In this article I have explained how to upload multiple files using file upload control. I have used jQuery plugin for uploading multiple files.

I have also explained how to check for file type, file maximum size limit using jQuery & also using server side validation code.

Creating Excel file from C#

  
I used below coding for create a excel sheet.I got from on web site.
In below coding there is no problem.Its create the excel file.If i run second time,its ask to overwrite the current excel file.If I said "Yes" then it ok ,but If I select cancel button,its generate the Error message.The exception is
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend