SQL Server: How to get non-record output such as from PRINT statements

Hi,

I'm using VS6 C++/MFC/SQL Server 7

SELECT statements return records, which I can get using CRecordSet.

However, in Query Analyzer and other SQL Server Query Tools, executing
queries result in comments like
"12 records updated"

And also T-SQL statements like PRINT @myvar will yield this as a text result
in QueryAnalyzer.

How can I get these results (output info other than records) from my MFC
code?

Lisa


0
no6060 (315)
1/15/2004 1:41:11 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
716 Views

Similar Articles

[PageSpeed] 3

Lisa,

TSQL print statements are for diagnostics. Perhaps they served a use once
when people intended that users would sit down and run there own queries
interactively.

If you can output information using print, then you can collect it with
select and so return it to the user with standard recordset(s). If you need
to format your output as you may be doing with a print statement, you can
also do that in a select statement.

BTW: production SQL should not have print statements - comment them out. The
prints can apparently accumulate in an output buffer and interfere with the
connection.

- Tim


"Lisa Pearlson" <no@spam.plz> wrote in message
news:u7go7iw2DHA.2948@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I'm using VS6 C++/MFC/SQL Server 7
>
> SELECT statements return records, which I can get using CRecordSet.
>
> However, in Query Analyzer and other SQL Server Query Tools, executing
> queries result in comments like
> "12 records updated"
>
> And also T-SQL statements like PRINT @myvar will yield this as a text
result
> in QueryAnalyzer.
>
> How can I get these results (output info other than records) from my MFC
> code?
>
> Lisa
>
>


0
Tim
1/15/2004 3:42:36 AM
Thanks Tim,

I'm aware of the SELECT way, however, I am trying to write my own little
Query Tool, so I need to be able to output the PRINT satements and alike,
just like QueryAnalyzer and other Query tools do.

Lisa

"Tim" <Tim@NoSpam> wrote in message
news:%23Hi%232mx2DHA.1908@TK2MSFTNGP10.phx.gbl...
> Lisa,
>
> TSQL print statements are for diagnostics. Perhaps they served a use once
> when people intended that users would sit down and run there own queries
> interactively.
>
> If you can output information using print, then you can collect it with
> select and so return it to the user with standard recordset(s). If you
need
> to format your output as you may be doing with a print statement, you can
> also do that in a select statement.
>
> BTW: production SQL should not have print statements - comment them out.
The
> prints can apparently accumulate in an output buffer and interfere with
the
> connection.
>
> - Tim
>
>
> "Lisa Pearlson" <no@spam.plz> wrote in message
> news:u7go7iw2DHA.2948@TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I'm using VS6 C++/MFC/SQL Server 7
> >
> > SELECT statements return records, which I can get using CRecordSet.
> >
> > However, in Query Analyzer and other SQL Server Query Tools, executing
> > queries result in comments like
> > "12 records updated"
> >
> > And also T-SQL statements like PRINT @myvar will yield this as a text
> result
> > in QueryAnalyzer.
> >
> > How can I get these results (output info other than records) from my MFC
> > code?
> >
> > Lisa
> >
> >
>
>


0
no6060 (315)
1/15/2004 5:17:39 AM
Take a look at SQLDMO then.

You will find a method called

ExecuteWithResultsAndMessages
and
ExecuteWithResultsAndMessages2 (SQL Server 2000).

To use sqldmo in Vc you will need to #import the '.rll file.

Really useful & powerful. But check the restrictions on using dmo in an
application.

- Tim


"Lisa Pearlson" <no@spam.plz> wrote in message
news:e$VQ5by2DHA.2888@tk2msftngp13.phx.gbl...
> Thanks Tim,
>
> I'm aware of the SELECT way, however, I am trying to write my own little
> Query Tool, so I need to be able to output the PRINT satements and alike,
> just like QueryAnalyzer and other Query tools do.
>
> Lisa
>
> "Tim" <Tim@NoSpam> wrote in message
> news:%23Hi%232mx2DHA.1908@TK2MSFTNGP10.phx.gbl...
> > Lisa,
> >
> > TSQL print statements are for diagnostics. Perhaps they served a use
once
> > when people intended that users would sit down and run there own queries
> > interactively.
> >
> > If you can output information using print, then you can collect it with
> > select and so return it to the user with standard recordset(s). If you
> need
> > to format your output as you may be doing with a print statement, you
can
> > also do that in a select statement.
> >
> > BTW: production SQL should not have print statements - comment them out.
> The
> > prints can apparently accumulate in an output buffer and interfere with
> the
> > connection.
> >
> > - Tim
> >
> >
> > "Lisa Pearlson" <no@spam.plz> wrote in message
> > news:u7go7iw2DHA.2948@TK2MSFTNGP09.phx.gbl...
> > > Hi,
> > >
> > > I'm using VS6 C++/MFC/SQL Server 7
> > >
> > > SELECT statements return records, which I can get using CRecordSet.
> > >
> > > However, in Query Analyzer and other SQL Server Query Tools, executing
> > > queries result in comments like
> > > "12 records updated"
> > >
> > > And also T-SQL statements like PRINT @myvar will yield this as a text
> > result
> > > in QueryAnalyzer.
> > >
> > > How can I get these results (output info other than records) from my
MFC
> > > code?
> > >
> > > Lisa
> > >
> > >
> >
> >
>
>


0
Tim
1/15/2004 8:56:56 AM
Reply:

Similar Artilces:

Calling Dex Procedures from SQL
Is there any way to call dex procs from SQL or VB code? Jed There is an undocumented and unsupported method of calling Dex code from VBA. However, I know of no method of calling Dexterity from SQL. Please email me if you want an example, just remove the online. from the address below. David Musgrave [MSFT] Senior Development Consultant MBS Services - Asia Pacific Microsoft Business Solutions http://www.microsoft.com/BusinessSolutions mailto:dmusgrav@online.microsoft.com Any views contained within are my personal views and not necessarily Microsoft Business Solutions policy. This p...

How do I get microsoft publisher to recognize my scanner?
When I try to scan into MS Publisher, I get a message stating it does not support this application. How can I fix this? In Publisher 2003, you go to INSERT - PICTURE - FROM SCANNER OR CAMERA.. I do believe that this is true for Publisher 2002.. prior to that, I have no recollection of what earlier versions of Publisher can and can't do.. -- Mike Hall MVP - Windows Shell/User "If hard work were such a wonderful thing, surely the rich would have kept it all to themselves." - Lane Kirkland "microbet" <microbet@discussions.microsoft.com> wrote in message n...

is SQL 2000 architecture different SQL Server 2005 / 2008 architecture?
Hi I have a book "inside SQL Server 2000" by Kalen Delaney, which I have been told is a good book. I am going backwards... reading about the sql server architecture in chapter 3 of the book. As I'm reading... I was wondering is it different SQL Server 2000 vs SQL Server 2005/2008? Also where can I find a book/or link that can give me more details about the internals on architecture? Thank you norm (normanchan@gmail.com) writes: > Hi I have a book "inside SQL Server 2000" by Kalen Delaney, which I > have been told is a good book. I am g...

Print a Year Calendar
Is there a way to have Outlook print a year's worth of Calendar. How about a third party program. Please email me at Mike@Elliottmail.com See if any of the 3rd party add-ins listed on the following page might suit your needs: http://www.slipstick.com/addins/calendar.htm -- Jocelyn Fiorello MVP - Outlook *** Messages sent to my e-mail address will NOT be answered -- please reply only to the newsgroup to preserve the message thread. *** In news:9ab001c3eabf$26c58d80$a501280a@phx.gbl, Mike Elliott wrote: > Is there a way to have Outlook print a year's worth of > Calendar....

Moving customizations from SQL 2k to SQL 2k5 CRM
This may be a non-issue but I wanted to check to see if anyone has done this and ran into issues. I have the XML customization files from our previous install of CRM 3.0 with SQL 2k database. I now want to import and publish these same customizations to CRM 3.0 on SQL 2k5. Has anyone done this or can point me to documentation that tells about the success or issues for doing this? Thanks. On 7 Feb., 06:35, Chris Treanor <ChrisTrea...@discussions.microsoft.com> wrote: > This may be a non-issue but I wanted to check to see if anyone has done this > and ran into issues. > &...

Cannot install the 3rd Exchange 2003 Server
Hi All, Please help me. I cannot install the 3rd exchange Server 2003 on windows server 2003 Std with SP1 and without SP1. My AD is Server 2003 with SP1. The other 2 Exchange Server is 2003 std with SP2. During installing a new Exchange computer into the organization, I receive the following error message: Setup failed while installing sub-component Site Replication Service with error code 0xC007054B (please consult the installation logs for a detailed description). You may cancel the installation or try the failed step again. And the log is have the following error: [19:50:13] DS or RPC is b...

emails do not print correctly
I have never had trouble printing emails before, but for some reason they have started printing halfway down the page. I can't find any option that would affect this, and it seems to relate only to Outlook as my Word documents print out as they should. As far as I know, nothing has changed since I last printed from Outlook. Any suggestions? It's irritating and wasteful to have a one-page email print across two pages! Many thanks. (apologies if this appears twice, I had trouble posting the first time) ...

Need to add check transactions to Microsoft Money using OFX file (not bank statements)
Does anybody have an example of an OFX file that imports check transactions into Microsoft Money? I need to simulate the manual input of checks. Dut to problems in our accounting software, it's best to enter transactions in our accounting system and rekey them into MS-Money. I found some "statement" files but I am thinking this isn't what I need to do????? I appreciate the depth and functionality of ofx vs. qif but I am finding it difficult to find ofx examples since they all appear to be produced by large companies (i.e. banks and financial companies) Any help wo...

CRM 3.0 Install Error with SQL Reporting Services and SQL 2005
Hi, Doing a CRM 3.0 Server installation. During the last page of the install wizard (or what I assume is the last page) when I goes through and does verification I get a red X next to SQL Reporting Services. The message I receive when I look at the details is: ***** The specified path is not a metabase path. Parameter name: path ***** Now SRS is installed and working. I put in the URL: http://<servername>/reportserver and every other variation on that I can find. Thoughts? Alan try http://servername/reports also assuming you did not use ssl... =======================...

How do I print two pages on one non booklet
In MS Publisher can any one tell me how to print two consecutive A5 pages onto an A4 sheet in non booklet form. Chastom wrote: > In MS Publisher can any one tell me how to print two consecutive A5 pages > onto an A4 sheet in non booklet form. That depends which version of Publisher you are using. Which version of Publisher are you using? -- Ed Bennett - MVP Microsoft Publisher http://ed.mvps.org Side by Side? Set the page up as a booklet, do your work on pages two and three. When it is time to print, simply print pages 2,3. -- Mary Sauer http://msauer.mvps.org/ "Chastom&...

Comparing two sets of data, and outputting the matches to another location
Hello. I have a problem I've been working on for a few days now, and I can't seem to come up with a solution. I have two columns of data. The first is a list of company employees sorted by last name (about 10,000 names), followed by the department they work in. The second is a sample list of the employees (about 200 names), also sorted by last name, and the computer systems access level they have. What I want to do is compare the second list to the first list, and where the names appear on both lists, output the data from both columns (for that name) to a third location. The goal...

SQL 'for xml' and C# example??
I'm missing some piece of the puzzle. I'm using 'for xml' type queries from SQL2K - and now trying to change the front-end from ADO to C#, I can't quite figure it out.. It seems that I could use an XmlReader.. and somehow use that instead of a DataReader.. but that didn't work.. I tried using a DataReader and get the byte array - but that wasn't right. SQL returns formatted XML, I need to load that XML into an XmlDocument somehow without ANY molestation of that dom. Any ideas? Examples? Missing links???? thanks THANKS!! I've been looking for the answer to ...

sql summarizing help
Hi All, Given: table1 --------- id, cdate, weeksago, amount, typeid, timeclose 496, 2010-02-11, 0, 450, 3, 1 490, 2010-02-01, 1, 200, 4, 1 491, 2010-02-01, 1, 350, 2, 2 493, 2010-02-01, 1, 500, 5, 1 489, 2010-01-21, 3, 150, 2, 1 136, 2010-01-12, 4, 500, 3, 2 137, 2010-01-12, 4, 100, 3, 1 138, 2010-01-12, 4, 500, 2, 1 1. i'm trying to create a sql that will give me a summary resultset grouped by weeksago. 2. i want to sum the columns and get counts based on typeid. 3. avg of timeclose here's the sql i have: select weeksago, , (sum(timeClose)/(count(timeclo...

Update multivalue field in table from form with SQL
Access 2007 on Vista I am using a form to establish the variables for a report before it is created. One field on the underlying table is a multivalue field, and the form includes a multi-select combo box control. After selections are made and the OK button on the multi-select combo drop down is clicked, focus moves to the next control. I have discovered though, that the underlying table does not update immediately, but does so correctly when I close the form. This sequence does not deliver the proper report data, so I need a way to immediately update the underlying table (m...

can't get CListCtrl groups to work
Env.: VS2003, Common Controls v6 Hi All, I have this CListCtrl in report view displaying a bunch of items. I wanted to use item groups (a new feature in common controls v6). You know, such as in the Network Connections in Explorer under Win XP : Dial-up, Incoming, LAN or High-speed Internet... Docs are close to inexistant but I thought it shouldn't be to difficult : - call List.EnableGroupView() - call List.InsertGroup() to create each group. - call List.MoveItemToGroup() to place each item in a group. Even though not clearly documented in MS docs, these steps are the same as describ...

Project Server Cube Build Issue
I think I screwed up the install order on the SQL DMO components. According to MSDN: " At this time, do not use the feature packs for SQL Server 2008 to install and download these components, as those files will not allow you to build cubes in SQL Server 2008 Analysis Services with Project Server 2007." However, I didn't read that carefully enough and installed the Microsoft SQL Server 2008 Management Objects Collection instead of the 2005 version. Now I can't install the 2005 version even if I uninstall the 2008 version. The setup fails with the "highe...

How to get the file title name?
Hello to all, Given the following full file name: "C:\Temp\Directory\File.dat" Is there a way to get the title name "File" from the full file name? Thank you, Geo >Given the following full file name: "C:\Temp\Directory\File.dat" >Is there a way to get the title name "File" from the full file name? You can use the _splitpath() function. Dave -- MVP VC++ FAQ: http://www.mvps.org/vcfaq Here are some functions that may be useful for you. You have to include Shlwapi.h and .lib. Tom #define BACK_SLASH _T("\\") // // Returns the file...

Refer to SQL statements globally
I have two large SQL statements that I need to use across several forms, reports, etc. Rather than repeat them in each form, I'm trying to store and reference them globally. For example, I'd like to store strSQL1 and strSQL2 in a global module, so I can use either like this in a form: Random form: Me!lstResults.RowSource = strSQL1 Random report: Me.Report.RecordSource = strSQL2 Would I just store the SQL statements in a global module like: Public Function SQLSource() As String Dim strSQL1 As String Dim strSQL2 As String strSQL1 = "SELECT blah blah...

To SQL or not to SQL?
I have a very vertical product developed 100% in M/S Access. I developed it myself in 1993 in the initial release of Access and been with it ever since. It is currently very stable and running in Access 2003. My big question is how or even *if* we should move it to SQL. My customers are getting bigger all the time with more users. Typically our customers run one or two workstations generally never more than 5. Performance, however, is starting to slow with database sizes passing 500 meg. We also have a LOT of code behind forms so are bound tightly to the Access development environ...

How to get source frame rate in VMR?
when I didn't use VMR to render video from a frame grabber, I use hr=IBasicVideo->get_AvgTimePerFrame(&fRate) to get the source frame rate. Now, I'm using VMR and this interface function just keeps failed(hr). Any other way to get the frame rate information? Thanks. I found one: IQualProp->get_AvgFrameRate(&dFrameRate) This one returns real-time frame rendering rate not the original stream rate. "Frank E Rogers" <syang@pelco.com> wrote in message news:uALxRl16DHA.1672@TK2MSFTNGP12.phx.gbl... > when I didn't use VMR to render video from a fram...

writeback to SQL 2005
hello! I use excel 2007 iI open a connection agianst SQL server 2005 and choose a table. In my workbook i can now see this data from this table. if i change a value in some cell i wish to writeback to table in SQL server. Is this possible? It's possible through the use of VBA and ADO, but not simply using the data connection you've already established. Ross "CJ" <CJ@discussions.microsoft.com> wrote in message news:D54EC521-0DD5-4B3D-971B-4FF3394D6FA8@microsoft.com... > hello! I use excel 2007 > iI open a connection agianst SQL server 2005 and choose a table...

Server
Working in a large office we have recently replaced our exchange server. The new server has a different name fom the old one. For the vast majority of users this has not caused a problem. One user about once a week cannot open hois Outlook and the server name reverts back to the old server name. Please help ! ...

Can someone tell me some newsgroup server about AI or datamining?
Hi, all I am sorry to post my question here, but i really need help from everyone here. I have googled for newsgroup talking about AI or dataming for a long time, however, it ends no result. Can someone show me any newsgroup servers just like msnews.microsoft.com, then I would post my question there and gather helps from those experts. Best wishes Hi, there are endless resources in the internet, you just have to look for the right words and places: http://aima.cs.berkeley.edu/ http://dir.yahoo.com/Science/computer_science/artificial_intelligence/ http://en.wikipedia.org/wiki/Artif...

Project Server 2007 Hotfix dated 2/23/10
Need help in trying to determine what is actually being fixed in the newest hotfix they are the following first and second items in the kb article. Also, could someone let me know what the note applies to as well (that is the first item or the second item or both). Thanks!!!! 1. You accept updates for assignments in Microsoft Office Project 2007. In this case, the values for actual work and for actual overtime work differ from the values submitted by the resources. When you save and then publish the project, the resource timesheet on the My Tasks page shows the same incorrect...

Printing in MS Publisher 2003
I support a department that uses Publisher to create its monthly calendar. The secretary creates the base calendar, then e-mails it to the department members for them to add their own events. The secretary has a network printer as her default. The department members have local printers as their default (in fact, two users only have one printer configured in their respective "Printers and Faxes"). The two users in question print the calendar, after saving it to their local machine, and it prints to the secretary's network printer. Mousing over the print icon in the tool...