I wasn't sure which section to post this under but I am working on an assignment in SQL and have created a batch file to make the tables, load the data into the tables, and then sends several queries to sql to get results. Is there a way I can write the output from this batch file to a .txt file somewhere on my system? I have tried to look this up in several different places but have not had too much luck understanding them. I am fairly new to SQL.

To write your output in a text file follow these steps
1-Open query analyzer.
2-Go to Query
3-select Result to file
After doing this when you will execute your queries sql qill will prompt to ask the file name.

Use standard input/output direction from the console window. If your script resides in myscript.sql and your output should go in output.txt, enter mysql -u[I]username[/I] -p[I]password[/I] [I]database[/I] < myscript.sql > output.txt on the command line.

smantscheff - I understood your suggestion and tried it out but the output.txt file had what appears to be the help topics for MySQL rather than the output from the batch-file I entered

Then you have at least one parameter wrong in your mysql call. Try mysql -uusername -ppassword database from the command line first. When that works, add the redirections.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.