Mssql Stored Proc Executing Multiple Times On Tag Creations Follow
I am using a stored proc to generate RFID tag info on the fly using a stored proc. The problem with this appears that the custom SQL gets executed 4 times per label. 1 time when Print Station selects the label containing the stored proc. then 3 more times as the label prints. It appears based on the tag that prints that the label is the 2nd one printed. But I've had it query 3 or 5 times a few times as well.
Is there any way to stop Bartender from running the stored proc multiple times? Since my stored proc does an insert, I am ending up with multiple records in the table when it really should only run once. I suspect it is running the query to see the field names or to do some validation.
Below is my stored proc.
SET NOCOUNT ON;
create table #Temp (Tag varchar(24), Taglabel varchar(8))
update A Set A.maxcount = a.maxcount+1 from [dbo].[tagtype] A where a.id = @tagid insert into #Temp
SELECT cast(datepart(YY,getdate()) as varchar )
+ right('0' + cast(datepart(MM,getdate()) as varchar),2)
+ right('0' + cast(datepart(DD,getdate()) as varchar),2)
+ right('0' + cast(datepart(HH,getdate()) as varchar),2)
+ right('0' + cast(datepart(mi,getdate()) as varchar),2)
+ RIGHT('000' + @tagid,4)
+ right('00000000' + cast(maxcount as varchar),8) as Tag
, maxcount as TagLabel
from dbo.tagtype where tagtype.id =@tagid
insert into Taglist (Tag) select tag from #Temp
select * from #Temp