How To Print To A File Using T-SQL Or Stored Procedure
Sep 7, 2000Does anyone know how to print to a file or printer using T-SQL or stored procedure?
Thanks
Does anyone know how to print to a file or printer using T-SQL or stored procedure?
Thanks
Is this possible? I would think it would be, but not sure of the commands and I can't find them in my books.
I'm looking for something like.
EXEC usp_studentassign SPOOL C:
esults.txt
Is there such a beast?
Thanks : )
I've upgraded MS-Access 2002 to a MS-Access Project (adp), so now I have todeal with more sophisticated queries (may I call them so?) like storedprocedures. I have a form with a combobox for selections and a textbox toenter a certain value. Let us say I call the combobox @select and thetextbox @find. The combobox always shows the first of the items to select.Now I want to return a message if nothing is found, or if nothing has beenentered at all. The stored procedure reads for instance:ALTER PROCEDURE OPC@select nvarchar(20), @find nvarchar (100)ASSET NOCOUNT ONIF@find IS NULLBEGINPRINT 'You didn't enter any value'RETURNENDIF@select = 'Author'BEGINSELECT *FROM BooksWHERE Author LIKE '%' + @find + '%'ORDER BY Author, Title, Publisher, YearEND[And so on]RETURNThis works correct when I enter something, but when I don't enter any value,a message box pops up saying that the stored procedure has been executed,but no records were found. I want to see an error message like above. It'sas simple asALTER PROCEDURE HelloASBEGINPRINT 'Hello'ENDand nothing is seen. Does anybody know? Thank you.Wim
View 6 Replies View RelatedHi,
How do I print the SELECT statement in my Stored Procedure??
I have a set of variables and I want to see how they output in the select statement.
Thanks.
I am trying to print a stored procedure in color to read it on paper.
But it prints in BW even on a color printer with color options.
I have printed the code in color using Rapid SQL. All I have now I query analyzer (SQL SERVER 2000)
any way to do this in SQL SERVER 2000
Ashley Rhodes
What is the easiest way to accomplish this task with SSIS?
Basically I have a stored procedure that unions multiple queries between databases. I need to be able to export this to a text file on a daily basis and add a total records: row to the end of the text file.
Thanks in advance for any help.
I have defined an email as a .html file on my server: /Emails/email.htmlThis file defines what the email will look like and in the text I have placed tags that need to be replaced with values.A tag that requires replacement looks like: <#SENDERNAME> or <#RECEIVERNAME>I want to replace these tags with the names of the sender and the receiver respectively.AFTER this is done the email needs to be sent to the receiver's address, let's say: receiver@yes.comI want to create a stored procedure that takes as input the sender and receivername AND receiveraddress.It then uses the file I have defined on my server, replaces the tags and sends the email.How can I do this?!
View 1 Replies View RelatedIs there a way I can use one SQL server 2005 (full edition not express) Stored procedure that can execute a .SQL file as if it were in the SQL management studio Query window?
I have the situation where I have some .SQL file which were created with the 'Create to File' option in SQL Management studio. I then want to send them to a user who can execute them to create a SP on his SQL server without having to run the SQL management tools.
Regards
Clive
Hi..
I have a website in which the user uploads a text file to the webserver. and then i am calling a stored procedure which loads the data into the staging database using bulk copy. since my sql database and the web server are in different machines but on the same domain.. i am accessing the .txt file from the stored procedure by giving http://Ipaddress/ApplicationName/Directory/plan.txt
and the format file using the same address i.e http://Ipaddress/ApplicationName/Directory/plan.fmt
But when i press ctrl + click on the text file it take me to that location but when i do the same for the format file it says the page cannot be found.. Since it cannot access the .fmt file my import doesnt work.
Any help will be appreicated..
Thank you,
Karen
hi to all,
i have a stored procedure and i want to run a program from it..
i think that i need use api functions but how can i do that..
if there is a nother ways please tell me..
thanx..
hi,i am passing a xml file name to the stored procedure. the SP parses the file. but it is giving the error' INVALID AT THE TOP LEVEL OF THE DOCUMENT 'I expect this because of + and - in the xml file bafore the parent tags.how can i do the parser to eliminate these.
View 1 Replies View RelatedAnyone have the code used in DTS to make a connection to Excel? Or perhaps a better idea? I need to pass different file names to a stored procedure which would upload the spreadsheet data into SQL7 on demand.
View 1 Replies View RelatedI've been administering SQL Server for quite a while, but have managed until now to stay out of the development side. I find myself finally writing some complex SProcs. What I want to do is to create a "switch", i.e., a parameter that will output a few lines of text characterizing the SProc, with such information as required & optional parameters, potential "gotchas", and a handful of examples of usage. I want this to be able to work like this:
EXEC spMySProc '?'
or
EXEC spMySproc 'help'
This has to work even if there are multiple required parameters.
Thanks for your help!
Reading through the forums, I found some great imformation for importing/exporting an excel spreadsheet via a stored procedure, however, the amount of data I have won't fit in excel. Can someone help me export a CSV file via a stored procedure? I don't know if XML is the answer or if there is another way. I am able to use Bulk for an insert of a csv via stored procudure, although it doesn't allow me to use a variable for the file name and pass it in. We are currently using SQL Server 2000.
Thank you,
Stacy
I have a bulk insert script. I have a stored procedure. I saved the stored procedure as a .sql file in another folder too. I have another program that can "run external program" and the only files it will run is a .bat or .exe. I want my other program to be able to trigger the stored procedure to run. I think this means I need a .bat file.
Here is my stored procedure:
USE [EricaTraining]
GO
/****** Object: StoredProcedure [dbo].[LoadDailyAdjReport] Script Date: 03/29/2013 10:56:42 ******/
SET ANSI_NULLS ON
GO
[code]....
Hi there,
Does anyone know any possible way of creating a dbf file from within a stored procedure?
Any guidence, articles, examples, topics to revice would be a great help.
Thanks guys
Butterfly82
Hello everybody,I have a file with several asp functions where some depend on others.Some of the functions I will need to transform a string value.How can I include these functions in a stored procedure? (in SqlServer 2000)Do I have to add all the functions as userdefined functions?Or is possible to reference the external file like include files inasp?Thank you for your help!Regards,Michael
View 3 Replies View RelatedI need to develop some crystal reports on some .NET ado datasets.This is easy to do if I actually had data to work with. It is mucheaser creating reports with you have data.Therefore, I would like to run the stored procedure that the .NET adodataset is built on and generate an XML file. I could run the projectand try to figure out where the developers are making the call to thestored procedure and insert a line to writetoxmlfile. I would rathernot have to mess with their code.Is there a way working with SQL Server (either query analyzer orenterprise manager, dts, or whatever) that I can generate an xml file.I see that I can run a stored procedure and get an xml style return inquery analyzer, but I don't know how to save that as an actual file.Thanks for the help.Tony
View 3 Replies View RelatedAll I want to do is copy a text file and add a 1 after the name in a stored procedure that already cretes this file.
CREATE PROCEDURE [dbo].[sp_export_req] AS
DECLARE @trenutniRed varchar(30),
@tableRow1 varchar(3000),
@sql varchar(4000),
@sql1 varchar(4000),
@firstColumnName varchar(30),
@HTMLfile varchar(1000),
@columnNumber varchar(30),
@fs int,
@ole int,
@file int
declare @body as nvarchar(225)
CREATE TABLE #temptableHTML (code nvarchar(225))
select @HTMLfile = 'c: est_new.txt'
This is the start of the procedure that creates the test_new.txt file. I want to copy the test_new.txt file and name it test_new1.txt. Any help is appreciated. thank you
Hi..
I have a website in which the user uploads a text file to the webserver. and then i am calling a stored procedure which loads the data into the staging database using bulk copy. since my sql database and the web server are in different machines but on the same domain.. i am accessing the .txt file from the stored procedure by giving http://Ipaddress/ApplicationName/Directory/plan.txt
and the format file using the same address i.e http://Ipaddress/ApplicationName/Directory/plan.fmt
But when i press ctrl + click on the text file it take me to that location but when i do the same for the format file it says the page cannot be found.. Since it cannot access the .fmt file my import doesnt work.
Any help will be appreicated..
Thank you,
Karen
Hello all,
I have a big stored procedure which is going to alter many tables,insert data, basically lot of changes.
So, i want to have a text file (or) any log file which will display, what all the changes does the stored procedure has done ( They dont want profiler output )
Can anybody know how to log the results of execution of stored procedure to a text file.
Thanks.
In XSD file keep specification of each tables
So I think It would have some class or method to generate common stored procedure from xsd file.
Please help me.
ok...i give up.....
can this be done? (sql server 2000)
all i want to do is have my stored procedure output some data to a file and i want the filename to include a time stamp.
here's my current working file output code:
EXEC master..xp_cmdshell 'bcp "select * from CEData..employee" queryout "c:employees.txt" -c -Usa -P'
i'd like it to be something like this:
EXEC master..xp_cmdshell 'bcp "select * from CEData..employee" queryout "c:employees" + datetime + ".txt" -c -Usa -P'
but nothing seems to work.
i am trying to pass a large XML file from VS2005 (web service layer) to stored procedure (SQL Server 2000)In my stored procedure, the input parameter takes as "nText" (which will be XML file)Question:While performing ExecuteNonQuery, i am getting request timeout i think this is coz of large XML file i am passing.can anyone plz tell me how to pass XML file to SP...it would be better if you can provide me with some codei am completely new to this XML file passing between web service and SP...... thanks a lot in advance.....
View 7 Replies View Relatedhi all
I have to execute the stored procedure from code file
string constr = ConfigurationSettings.AppSettings["ConnectionString"];SqlConnection con = new SqlConnection(constr);con.Open();SqlCommand cmd = new SqlCommand("GetTax",con);cmd.CommandType = CommandType.StoredProcedure;SqlParameter paramFrom = new SqlParameter("@from", SqlDbType.VarChar, 50);paramFrom.Value = "JFK";SqlParameter paramTo = new SqlParameter("@To", SqlDbType.VarChar,50);paramTo.Value = "HOU";SqlParameter paramAirline = new SqlParameter("@Airline", SqlDbType.VarChar,50);paramAirline.Value = "US";SqlParameter rpTax = new SqlParameter("@Tax",SqlDbType.Int);rpTax.Direction = ParameterDirection.Output;cmd.Parameters.Add(rpTax);
insted of this way can i execute stored procedure any other way
like
exec MystoredProc "param1"."param2","param3"
i appreciate u r help
Hi guys,
I need to be able to send a text file with data seperated by tabs to a stored procedure that populates my table.
I am new to SQL and SPROCs that I am not sure how to even start. If you guys have any ideas I would really like to hear them or maybe any on-line docs and examples.
Thanks in advance!
hi,i have created a stored procedure to read xml dataCREATE PROCEDURE InsertXML(@xml varchar(1000)) AS DECLARE @XmlHandle intEXEC sp_xml_preparedocument @XmlHandle output,@xmlinsert into Employee(Name,ID,Sal,Address) (SELECT Name,ID,Sal,AddressFROM OPENXML (@XmlHandle, 'emp:EmployeeDetails/emp:Employee',2) WITH (Name varchar(30) 'Name', ID int 'ID', Sal int 'sal', Address varchar(30) 'Address'))EXECUTE sp_xml_removedocument @XmlHandlebut it is taking only xml text as input.but i want to send the file name as input.how to do it.
View 2 Replies View RelatedHi List
I have stored procedure which need 4 input variables. I want to send the stored procedure output to Table or text file. Is there any way I can do it let me know. Here is the stored procedure.
Exec TestProcedure 'USD',@test1 output, @test2 output, @test3 output
Thanks in advance
Wang...
Is there a way to use BCP or something else within a stored procedure to extract data from a select statement out to a text file?
View 4 Replies View RelatedHi!!!
Is it possible to create a stored procedure which will create a text file (containing information from some tables) and send it via e-mail to a list of user.
I know that I will have to configure the SQL Mail.
If it is possible, can someone give me sample code.
Thanks you.
Hi,
How to read from a flat file in a stored procedure. Is there any built in utility available ? Please let me know.
Mahesh.
Is there a way to run/call a batch file from a stored procedure?
Or, is there a way to run/call a batch file from a trigger?
Hi all,
Please ignore my ignorance, but I was wondering if someone could help me out a bit?
I'm trying to export the results from a stored proc, to an csv file.
So for example, I want to run this query:
SELECT TOP 10 pkID FROM myTable ORDER BY pkID DESC
and I wanted it to be saved to:
C:spExport.csv
How would I go about doing that?
Hope you can help :-)
bwuk