.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

Looping vs Union/ Exists - How would I do this task?

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :Sql Server


I have an engineering system writing alarms to a SQL server 2000 table. I would like to process the table at night and store the results in a new table.

It will look at all alarms in a 24 hour period and for each distinct record occurrence count the frequency for the alarm for that 24 hour period and for the preceding period of 8-90 days. Store the results in a table. (I’m looking for chronic alarms)

Resulting in something like this for rows of the stored table:

Alarm      Date         Count 24hr_period                     Count 8-90day_period


View Complete Post

More Related Resource Links

SSIS Database Transfer Error - "Role Exists" even though DB is being overwritten in task.



Can't get over this error, and net searches reveal other postings similiar, but no answers.

SSIS database transfer task (with overwrite) from SQL 2k source to SQL 2k5 destination fails with:


Error: The Execute method on the task returned error code 0x80131500 (ERROR : errorCode=-1073548784 description=Executing the query "CREATE ROLE [RFRSH_USER] " failed with the following error: "User, group, or role 'RFRSH_USER' already exists in the current database.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.  helpFile= helpContext=0 idofInterfaceWithError={8BDFE893-E9D8-4D23-9739-DA807BCDC2AC}). The Execute method must succeed, and indicate the result using an "out" parameter.

The error seems the same regardless if the destination DB exists or not!

Anyone have a solution?




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

Parallel Debugging: Debugging Task-Based Parallel Applications in Visual Studio 2010


In Visual C++ 10 and the Microsoft .NET Framework 4, Microsoft is introducing new libraries and runtimes to significantly ease the process of expressing parallelism in your code base, together with new tool support for performance analysis and debugging of parallel applications. In this article, you will learn about debugging support in Visual Studio 2010, much of which is focused on task-based programming models.

Stephen Toub, Daniel Moth

MSDN Magazine September 2009

Windows with C++: Task Scheduler 2.0


The new Task Scheduler in Windows Vista can do so much more than previous versions. We introduce some basic concepts and building blocks you can put to use in your own scheduled task projects.

Kenny Kerr

MSDN Magazine October 2007

Cutting Edge: Simplify Task Progress with ASP.NET "Atlas"


Dino Esposito rewrites his task progress bar with the help of ASP.NET "Atlas."

Dino Esposito

MSDN Magazine October 2006

Cutting Edge: Reporting Task Progress With ASP.NET 2.0


The progress bar is great for keeping users informed about the progress of a task. Unfortunately, there's no progress bar element built into ASP.NET, so Dino Esposito solves that problem with his ProgressPanel control.

Dino Esposito

MSDN Magazine September 2006

SQL Server and DMO: Distributed Management Objects Enable Easy Task Automation


SQL Server can be administered programmatically using system stored procedures, but Distributed Management Objects (DMO) offer a more modern, object-oriented alternative. This article introduces SQL-DMO in SQL Server 7.0 and SQL Server 2000 and describes the SQL-DMO object model, then focuses primarily on the Databases tree and the JobServer tree of the object model. The sample code and the article show how to use various objects such as the Registry object, the Configuration object, and the Database object to automate common administration tasks such as programmatically retrieving configuration settings, creating new databases, applying T-SQL scripts, and creating and scheduling backups.

Francesco Balena

MSDN Magazine May 2001

Looping through DataSet in C#


I have the following line of C# code that successfully returns the results of a stored procudure via a DAL:

spParamGetGamesTableAdapter spGG10 = new spParamGetGamesTableAdapter();

I can bind spGG10 to a DataGrid and see the stored procedure query results, so I know everything is good so far.

I want to loop through the spGG10 (DataSet table?) and output each row on a row-by-row basis using a Literal Control. I think I know how do the output part, so...

My question is: How do I access the data in spGG10 and loop through its records? (Also, I am not exactly sure what kind of object spGG10 really is. Is it a table?)

Thanks in advance.

order by in combination with union


 Hi All,

How can I order this by count? so if it appears above and below the union statement, I want it on top

	SELECT distinct BIER.Naam, BIER_L2.L2_Naam, BIER_L3.L3_Naam from BIER_MATCH, BIER, BIER_L2, BIER_L3

	SELECT distinct BIER.Naam, BIER_L2.L2_Naam, BIER_L3.L3_Naam from BIER_MATCH, BIER, BIER_L2, BIER_L3
	where BIER_L2.L2_ID = BIER.L2_ID and BIER_L2.L3_ID = BIER_L3.L3_ID and RECEPT_ID = @RECEPT_ID 
	and BIER_MATCH.BIER_ID is null


create Scheduled Task that auto send mails


hello every one

i bought a hosting plan that allows me to send about 500email/per hour

but my client wish to send about 2000 or 3000 email at a time

is there a way to split them and 500 email per a time automaticly without the need of reloging again every hour

my hosting plan doesn't allow me to create a sql jop or send mails via Sql Server.

any bright ideas ?

Checking if a URL Exists


I've got a HttpHandler which outputs XML to the client to play video, it outputs the url to the video, video name etc... Validates the request etc.

However sometimes when i upload new video the main URL doesn't pickup the file from the CDN so i have to use a different URL to go directly to one of the main servers.

For example the CDN url is:
One of the server urls is:

What i want to do is check to see if the file can be reached off the .net url before posting it back to the user.


if http://videos.****.net/ar/ar_1003_scene_1.ext response then
> post http://videos.****.net/ar/ar_1003_scene_1.ext to client
> post http://videos1.****.com/ar/ar_1003_scene_1.ext to client

I hope that makes sense.

I thought of doing a WebRequest/WebResponse but i don't want the file to come back, i just wanna know if its there or not. My site is on a single server while all the video is on a CDN.

(i can't post the url because it's NSFW)

Edit: Why do posts not auto format?!?

Looping through controls to find reorderlist to set allowreorder


How would I loop through controls on a content page to set allowreorder of all reorderlists to false. Thank you. 

Linq to sql does not return appropriate multiple result sets with "If exists" conditions in the stor


Hello All,

I have a stored proc that returns 4 resultsets, they are in the format.

ALTER PROCEDURE [dbo].[pGetManagerEmployeeSummaryDummy]

    @ManagerStaffID int,
    @PeriodID int



IF EXISTS (select 1 from dbo.temployee e
    inner join dbo.temployeedetail ed
        on e.staffindividualid = ed.staffindividualid
        and ed.periodid = @PeriodID  
    inner join Incentive.tRole r
        on rm.IncentiveRoleID = r.RoleID
    where ed.ManagerIndividualStaffID = @ManagerStaffID
    AND r.RoleID = 1) --Closer
        SELECT e.StaffIndividualID, e.LastName, e.FirstName, r.RoleName, e.xname, e.yname

from dbo.temployee e

inner join dbo.temployeedetail ed
            on e.staffindividualid = ed.staffindividualid
            and ed.periodid = @PeriodID

where ed.ManagerIndividualStaffID = @ManagerStaffID

Convert .docx to web page - "the converter cannot complete the task because an internal error occurr


I'm trying to convert docx files to webpages to be published in to a library elsewhere on our sharepoint site. At first I was having no problem, the files were converting, however more recent files have returned the error: the converter cannot complete the task because an internal error occurred

I've tried writing, uploading and converting a simple docx file, and this works which has led me to believe that the problem is something in the docx files that i'm trying to convert. So i tried using word07 to clean the documents up by clicking Office button>prepare>inspect document then removing all the metadata, custom xml etc from the files resave, upload and convert, but still no joy.

I'd simply rewrite the document but the problem is that there are a lot of them.

Any ideas what's going wrong?


Attach Workflow to Task List, don't get option to manually start workflow via dropdown on task item



I am running WSS 3.0 with other workflows which are functioning correctly.  I created a new workflow in Visual Studio 2008 and was able to successfully run it in my dev environment.  I attached the workflow to a task list in my dev environment and was able to manually start the workflow by using the drop down workflow option and using the menus to manually start it.  I installed this workflow in our production environment and attached it to the task list (which had a SPD workflow attached to it which stopped working about a month ago).  I made sure that the option to manually start the workflow was checked.  When I tried to manually start the workflow, (hover mouse over title, drop down) there isn’t a workflow option.  The workflow also will not start automatically when a task is changed.


I attached this same workflow to a different task list in production and get the option to start it.


I have tried creating a small workflow in SPD 2007 and attaching it to the task list.  It shows that it is attached, when I look at the workflows that are attached to the task list, but I still don’t get the option to manually start it.


I have checked my security and I have fu

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