Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Warning: Null value is eliminated by an aggregate or other SET operation.

Posted on 2010-08-31
6
Medium Priority
?
460 Views
Last Modified: 2012-05-10
Ok, I have been trying to figure this out, it keeps breaking but this is all it gives me, If i run each individual filter by itself they work just fine, and this process works fine for a couple days and then breaks itself.  How can I trouble shoot to find out where the exact error is coming from while runnning this thing SP.
 Can I put a print somewhere in here that might lead me to the problem for this darn thing.

First what it does is slect all the filters (SQL code) that are assigned to people, then it goes through and runs the code on every persone to see if they have problems, per the sql code, if they do then it saves it to a table.

Here is an example of the sql code.
Select p.intPositionId  , p.strPara  , p.strline  , 'SRP Dental'  , mt.dtMODRE_Date  , pp.strName  , pp.strSSN   from tblUnitPosition as p     Inner join tblUnitPersonnel as pp          on p.intPositionId = pp.intPositionId     INNER JOIN ModreTracker.dbo.tblResults as mt          on mt.strSSN = pp.strssn   where mt.bitDental = 1   And intUnitMobId =
declare @counter int, 
		@countfilter int, 
		@FilterID int, 
		@AssignedID int, 
		@UnitID int, 
		@DeployDate datetime,
		@TaskName varchar(60), 
		@Proponent varchar(60),
		@ApproveLev varchar(15),
		@Days int, 
		@Sql nvarchar(4000), 
		@PositionId int, 
		@Para varchar(4), 
		@Line varchar(3), 
		@Posn varchar(60), 
		@Sid varchar(60), 
		@Name varchar(60), 
		@SSN varchar(10), 
		@cur cursor, 
		@taskID int 
 
Declare Vend_Cursor CURSOR FOR Select uf.intFilterId, uf.intAssignedID, uf.intUnitMobId, ud.dtdeployDate,
										f.strTaskname, f.strProponent, f.strApprovalLevel, f.strSusDays, f.strSql 
										from tblSoldierFilters as uf Inner join tblUnitDeployData as ud on 
										ud.intUnitMobId = uf.intUnitMobId Inner Join tblFilter as f on 
										f.intFilterID = uf.intFilterId where uf.dtRemoved is NULL 
										order by uf.intfilterID

OPEN Vend_Cursor

FETCH NEXT FROM Vend_Cursor INTO @FilterID,@AssignedId,@UnitId,@DeployDate,@Taskname,@Proponent,@ApproveLev,@Days,@Sql
 
while @@FETCH_STATUS =0 
begin
	--- Call the SQL Filter and assign the unit # as the variable to get at table	
	
	set @Sql = N'set @cur = cursor for ' + @Sql + Cast(@UnitID as varchar) + ';open @cur'

	exec sp_executesql @Sql, N'@cur cursor OUTPUT', @cur output

	fetch next from @cur into @PositionId, @Para, @Line, @Posn, @Sid, @Name, @SSN
	
	while @@FETCH_STATUS =0 
	begin
		set @taskID = (select intTaskId from tblTask where intFilterId = @FilterID and intPositionId = @PositionId)
		
		if (select isnull(@taskID, 0)) = 0
		begin
			Insert Into tblTask (intAssignedId, intFilterId, intPositionID, strTaskName, dtFound, strStatus, 
						dtStatus, strSSN, strName, strPositionData, strSoldierData, strProponent, dtNotification,
						dtCompleteTask) 
			VALUES (@AssignedId, @FilterID, @PositionId, @Taskname, Getdate(), @ApproveLev, Getdate(),@SSN, 
					@Name, @Posn, @Sid, @Proponent, Getdate(), dateadd(DAY, -@Days, @DeployDate)) 
		end
		
		fetch next from @cur into @PositionId, @Para, @Line, @Posn, @Sid, @Name, @SSN
	end
	
	close @cur
	deallocate @cur	
	  
	FETCH NEXT FROM Vend_Cursor INTO @FilterID,@AssignedId,@UnitId,@DeployDate,@Taskname,@Proponent,@ApproveLev,@Days,@Sql
end

Close vend_Cursor
deallocate vend_Cursor

Open in new window

0
Comment
Question by:kdeutsch
  • 4
  • 2
6 Comments
 
LVL 70

Expert Comment

by:Scott Pletcher
ID: 33570677
If that's the *only* error you're getting, issue this statement inside the stored proc / start of T-SQL code:

SET ANSI_WARNINGS OFF

But that's just a warning, it shouldn't keep the code from finishing.
0
 

Author Comment

by:kdeutsch
ID: 33570715
ScottPletcher:
Ok trying now it takes this things about 20 min to run.  Is there a way to put some print statments in this thing to see where its failing or at what part its failing.
0
 

Author Comment

by:kdeutsch
ID: 33570729
ScottPletcher:
I ran into this error, I have some sql queries that go over a linked server to get results, don't know if that would cause this.

Msg 7405, Level 16, State 1, Line 1
Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 70

Accepted Solution

by:
Scott Pletcher earned 2000 total points
ID: 33589807
You can't -- and don't want -- to try to get around that.

Instead, you'll have to modify the SQL code that contains the grouping function.  That'll be a pain because I don't see it in your code, so it must be in the @sql / cursor def code.
0
 

Author Comment

by:kdeutsch
ID: 33590211
ScottPletcher:

Found the problem was a bit of sql code that runs insdie the whole process was picking to much information instead of the standard 7 items that the stored procedure allow.
0
 

Author Closing Comment

by:kdeutsch
ID: 33620474
This is really not solution but because picking mine and divding out points seems to be a pain and I want to colse out the question.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question