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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Can I Combine resultset return by union

Posted By:      Posted Date: September 30, 2010    Points: 0   Category :ASP.Net



Is there a way to row two and three of the result set be returned so that the


following query:


Select Distinct A as TotalUniqueTranTypeT, B as TotalUniqueTranTypeO, C as Week from


SELECT     COUNT(DISTINCT EmailTracking.EmailAddress) AS B, 0 as A, DATEPART(Week, EmailTrackingDetail.TranDate) AS C

FROM         EmailTrackingDetail INNER JOIN

                      EmailTracking ON EmailTrackingDetail.EmailTrackingRecordID = EmailTracking.RecordID

WHERE     (EmailTrackingDetail.TranType = 'O')

GROUP BY DATEPART(Week, EmailTrackingDetail.TranDate)


SELECT     0 AS B, COUNT(DISTINCT EmailTracking.EmailAddress) AS A, DATEPART(Week, EmailTrackingDetail.TranDate) AS C

FROM   EmailTrackingDetail INNER JOIN

                      EmailTracking ON EmailTrackingDetail.EmailTrackingRecordID = EmailTracking.RecordID

WHERE   &n

View Complete Post

More Related Resource Links

Need Syntax To Make Results of LINQ Union Return Non-Generic Type



I have the below SQL which works just fine:

SELECT     Message, CreateDate, AccountId, AlertTypeId
FROM       dbo.Alerts
SELECT     TOP (100) PERCENT Status, CreateDate, AccountId,
                          (SELECT     10 AS Expr1) AS AlertTypeId
FROM         dbo.StatusUpdates
WHERE AccountId = PassedInParameter

I have been going about trying to convert the above into a LINQ method and am having problems with return types.
As the above SQL illustrates, I am querying two distinct LINQ tables - Alerts and StatusUpdates -
and then attempting to perform a Union on them. In order to do the union in LINQ, I have to have agreeing types. So, I
am using "var" to make the results of "alerts" and "updates" generic before the union.  

public IList GetStatusUpdatesAsAlertsByAccountId<T>(Int32 accountId)
            using (WorkbookDataContext dc = _conn.GetCont

Combine two queries in one resultset

Hi,I want to combine two queries like :select name as name1 from table1 where id = 6 and select name as name2 from table1 where id = 2.I need a single resultset. How can I do that?Regards,ap.

Execute SQL Task with XML resultset not return properly

Hello, I have a table with one column as XML data type, and it stored XML content from a XML file. In SSIS, I used execute SQL Task, and select the XML column from the table, and set resultset as XML. I then defined a variable XMLList as string, and I used this XMLList variable as resultset. When I run the package, I saw from watch window that this XMLLIst variable not returned the proper value from the table column, but with something like <ROOT><?MSSQLError HResult=\"0x80004005\" etc. Could anyone give me advice on what is wrong with my settings for resultset? Any suggestion will be appreciate!  

How to use multiple resultset return by SP in a Report



Can we use different resultset in our Report. Like if we have written two select statement in our SP, how can we use the different result set to bind them in our Report.


Thanks in advance. 

How to combine 3 Fact Tables into 1: UNION in TSQL vs. MDX Scripts


Hi All,

I have 3 Fact Tables I would like to combine them into 1, I am not sure what's the best way to do it.

In Adventure Works, it uses UNION in TSQL to create a sales_summary Fact from Internet Sales and Reseller Sales.

Can I just write a simple Calculated measure?  What's the best way to handle this kind of situation?







[Distribution Partner].[Distribution Partner].[DP]

Combine, minify and compress JavaScript files to load ASP.NET pages faster

Websites are getting more interactive these days and most of this interactivity comes from JavaScript. People are using different JavaScript libraries and frameworks to make their websites more interactive and user friendly.

ListView DataPager with SQL-Statements that already return only paged data.



As far as I understand the ListView-Control and the DataPager-Control, they work like this: The ListView gets its datarows from its data source, then the DataPager causes the ListView to display only a subset of those rows.

So what, when I want to use custom databinding for the ListView, that *already* gets the certain subset from SQL-Server (for better performance). Can I and how can I use the DataPager then?

Thanx, S.

XMLHTTP.ResponseText return unexecuted code?


I have a simple asp with the following code.  When I access this page directly (via browser) everything works fine:  the xml object shows up fine.  When I call this page via VBA (excel), the ResponseText method of the 

XMLHTTP object returns the below code unexecuted.  Anybody knows what's going on?  thanks.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <% Response.Buffer = True Response.ContentType = "text/xml" Dim oDataXML As Object 'Custom Data XML passed in by caller. On Error Resume Next 'Load the XML passed into the request. oDataXML = Server.CreateObject("Microsoft.XMLDOM") oDataXML.Load(Request) Dim sResult As String sResult = "<?xml version=""1.0""?>" sResult = sResult & "<OrderProcessed>" sResult = sResult & "<Status>test</Status>" sResult = sResult & "<OrderID>111</OrderID>" sResult = sResult & "</OrderProcessed>" Response.Write(sResult) Response.End() %>

Posting data to ASMX and return Object for jQuery


I am using fluent NHibernate with WebForms and I am trying to build a page where I allow a user to post a status update on their profile page and I a using a .asmx WebService to post the data to the database and then returnig a StatusUpdate instance to the page to be used by jQuery. I have a couple problems.

1) First off when I return a string from the WebService(i was testing) the textbox where the user enters their status doesnt empty the contents. And since the page doesnt refresh even if I manally clear out the textbox and put in something else, it still posts the previous status to the database again. How do I fix this?

2) Secondly, when I return the StatusUpdate Object from the Webservice I cant the results to display anything. Like I sad, Im using jQuery to make an AJX call to the WebService.

Here is my code:

User Profile Page:

Status: <asp:Label ID="status" runat="server"></asp:Label><span style="font-size:.7em;"><asp:Label ID="statustime" runat="server"></asp:Label></span><br />
<textarea id="statusBox" rows="3" cols="40"></textarea><br />
<input type="button" value="Update Status" onclick="SetStatus(); return false;

What Gives You the Right?: Combine the Powers of AzMan and WSE 3.0 to Protect Your Web Services


In this article, Niels Flensted-Jensen demonstrates how you can combine new and existing Microsoft technologies with minimal new code to provide flexible authorization for individual Web service methods. Windows 2003 Authorization Manager, Web Service Enhancements 3.0, and Enterprise Library all play a part.

Niels Flensted-Jensen

MSDN Magazine November 2005

Web Services: Increase Your App's Reach Using WSDL to Combine Multiple Web Services


The very tools that have helped drive the growing adoption of Web services, and the enabling abstractions that they provide, can often prevent developers from peeking behind the curtains at the XML standards that make up the Web services stack. This article will offer a solution that enables type sharing between proxies created for complementary Web services, while at the same time providing an opportunity to examine the Web Services Description Language (WSDL) and its interaction with the Web services tools you know and love.

Gerrard Lindsay

MSDN Magazine March 2005

ASP.NET: Combine Web and Windows Services to Run Your ASP.NET Code at Scheduled Intervals


If you want to schedule ASP.NET tasks, one solution is to use a Web service to provide an interface to your ASP.NET application and build a Windows service that calls to it at scheduled intervals. Thus the ASP.NET application doesn't have to own the scheduling logic. Here the author shows how to schedule your ASP.NET tasks using a Windows service to initiate the Web service call because Windows services can start themselves when Windows boots up.

Andrew Needleman

MSDN Magazine March 2005

Return of the Rich Client: Code Access Security and Distribution Features in .NET Enhance Client-Sid


Rich clients employ many of the features and conveniences of the operating system they run on, and the list of these features has been growing since the dawn of the PC. But as apps have migrated to the Web, the trend towards increasing client-side functionality has ground to a virtual halt. There are several reasons for this; chief among them are security and deployment problems. But that's all about to change. With the .NET Framework, you can participate in building the distributable rich client of the future. In this article, the author enumerates the pertinent features of .NET that will allow you to build safe, easily deployable controls. The features discussed include managed code, code access security, versioning control, Windows Forms classes, and isolation.

Jason Clark

MSDN Magazine June 2002

SQL and XML: Use XML to Invoke and Return Stored Procedures Over the Web


Front-end developers frequently want to add functionality to the presentation tier of an n-tier architecture, but such requests can require changes on all tiers just to get the data and present it. This process can be made easier and more flexible by using SQL Server stored procedures to automate the delivery of data in XML format from the database to the front-end components. In the component presented here, stored procedures are invoked by XML strings, XML is returned, converted using XSL, and presented to the client in HTML. The technique supports rapid changes yet doesn't sacrifice the n-tier approach. This approach can be used with either SQL Server 7.0 or SQL Server 2000.

Dave Grundgeiger, Anson Goldade, and Varon Fugman

MSDN Magazine August 2001

linq and max, if return null return error


hi there
i have this query :

var result2 = (from TH in DB.Threshold
                          where TH.ProductSKUID == int.Parse(HID_ProductSKUID.Value)
                          select TH.ThresholdID).Max();

the problem is that if this query does not find any items, return null, so thow exception
how can i do to return 0??

filter n compare between two table in resultset


Hi .. I have two table 

Say Table1 n Table2


Item              ItemName

001                 Laptop

001                  PC

002                  PC

002                  Printer

003                  Pendrive

004                  Keyboard

004                  CPU


Item                  ItemName

001                   laptop

001                   PC

002                   Printer

004                   CPU

Here am comparing table1 with table2

The Itemname which is available in both table1 n table2 should be dropout ... Other Item should be displayed ...

I need the sql result set like this :

Item                 &n

Return a file with bad headers?


I've build a MP4Handler. The Mp4 hander selects a correct file from a url.
The system works if you work with 'normal' mp4 files.

But the problem is the MP4 files are genrated by another program, so i think there's the problem.
Right now i returned a test file, then it woks great!

Do i return the other file, i get a 412 error if i use it in IE (he shows a  400 error because i deleted the 412 error in the IIS i thought maybe that solves the problem) . In IE it doesn't work, but in firefox it works great!

In my Fiddler result, the first movie (guid url) is from firefox, and works great. The second with the text/html result (selected row) is from IIS.
How can i solve this problem?

Or is this the problem?:
This entity tag is not recognized by IIS. It only affects version 7.0 of the IIS software.
From: http://www.pc-library.com/errors/error-code/412-0x19C/ 


As coding i use this as base: http://dotnetslackers.com/articles/aspnet/Range-Specific-Requests-in-ASP-NET.aspx 
I changed The GetRequestedFileInfo with:
public override FileInfo GetRequeste

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