473,881 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print data through Store Procedure

1,977 Top Contributor
any know how to Print data through Store Procedure to the printer Directly
Feb 3 '07 #1
1 1401
1,017 Recognized Expert Top Contributor
Try this:

[PHP]DECLARE @FileName varchar(8000), @bcpCommand varchar(8000), @PrintCommand varchar(8000)

Select @FileName = 'c:\query_resul t' + replace(convert (varchar(20), getdate()),' ','_') + '.txt'

SET @bcpCommand = 'bcp "select * from table_name" queryout "'
SET @bcpCommand = @bcpCommand + @FileName + '" -U uid_here -P pwd_here -c'

EXEC master..xp_cmds hell @bcpCommand

SET @PrintCommand = 'TYPE ' + @FileName + '>\\severname\p rintername'
xp_cmdshell @PrintCommand[/PHP]

Good Luck
Feb 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: zMatteo | last post by:
I've a problem. In my MSSql db I've some tables named username.mytable and only one store procedure named dbo.sp; CREATE TABLE . ( NOT NULL , NOT NULL ) ON
by: serge | last post by:
My project is to automate testing of Stored Procedures of type SELECT (at least for now). I want to create a table where each stored procedure's input parameter values are entered and in another table the expected result value(s) are entered when executed against a sample database containing manually entered and verified data. My current problem is that the stored procedures' input
by: Rod Snyder | last post by:
I'm trying to set up an asp.net (vb.net) that will allow a user to insert/update a bio/profile. I wanted to create a SQL Server 2000 table that includes their contact info and bio info. However, I'm not getting SQL Server to accept more than about two paragraphs of info. I've tried the datatypes of ntext and nvar char to no success. I'm presuming most people will be cutting and pasting from a Word document also. Does anyone have any...
by: Agnes | last post by:
I am confused about these two things 1st)As form load I new a data adapter programmicaly , and I can use stored procedure to 'select sth ' and then fill into the dataset.by using binding context, my form can display the correct data. 2nd) I want to new a record, so. dsinvocie.addnew(), I can type the new data. 3rd) I want to use the store procedure to insert this new record. my store procedure runs very well However, as i rund...
by: c676228 | last post by:
Hi everyone, I wrote a store procedure that fetch one row data in the database based on the parameter value I entered. After I created the store procedure, the store procedure code looks like this: ALTER proc getProductCommScale @product As varchar(30), @TISCommRate As Decimal(5,2) OUTPUT, @BrokerCommRate As Decimal(5,2) OUTPUT, @Fee As Decimal(5,2) OUTPUT As if RTRIM(@product)='Imed' Select @TISCommRate=TISComm,...
by: c676228 | last post by:
Hi everyone, I am just wodering in asp program, if there is anybody writing store procedure for inserting data into database since there are so many parameters need to be passed into store procedure(assume there are many columns in the table). I need to insert data into two separate tables, the relation between these two tables is 1 row of data in table1 could have multiple rows in table2 related to table1, but if the data insertion into...
by: Mukesh | last post by:
Hi all I m Using SQL SERVER 2005 I have a requirement to store some data in xmldatatype using stored procedure , Here is example
by: GUILLAUME LECOMTE | last post by:
Hi, I am a bit new to db2, and I am unable to find a proper command syntax where I can print values during execution in a stored procedure Pls help. regards, guillaume
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code is run again? This is causing certain error problems. 1 Why does the code run for a print preview when the report already exists? 2 What command do I use in code to find out if a report (or any other object for that matter) is already...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.