Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 tinyint not increasing

Author  Topic 

krnlpanic
Starting Member

2 Posts

Posted - 2010-04-08 : 12:00:00
I am running this in a USP:

Declare @RouteCount tinyint

SELECT @RouteCount=COUNT(DISTINCT ROUTE)
FROM tblCAL
WHERE (tblCAL.DATESTAMP = @DateStamp or tblCAL.DATESTAMP='MASTER')
AND tblCAL.LANEGROUP = @LaneGroup

INSERT INTO tblCAL(STATUS, ASOF, BYUSER, DATESTAMP, LANEGROUP, ROUTE, STOP, LANE)
VALUES(@RecordType, GetDate(), @User, @DateStamp, @LaneGroup, @RouteCount + 1, 1, '-')

The problem that is happening is @RouteCount is NOT increasing by 1
DISTINCT COUNT = 9
@RouteCount + 1 = 9

Any help would be greatly appreciated!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-08 : 12:09:47
trying printing out value of @RouteCnt before insert and see what value it has

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

krnlpanic
Starting Member

2 Posts

Posted - 2010-04-08 : 12:21:05
Results of @RoutCount = 8
So.. the USP was working correctly..
Unfortunatly, I had bad data in the
ROUTE field which was throwing off
my SP..

Thank you!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-08 : 12:24:20
hmm..ok...Glad that you sorted it out

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -