-- Get Table Summary declare @tableId varchar(20), @totalTraysInTable int, @goodTraysInTable int, @badTraysInTable int, @reviewTraysInTable int, @traysToScanInTable int set @tableId = '{0}' select @totalTraysInTable = count(*) from [Green Circle Growers$Container Entry] (nolock) where [Container Type] = 1 and [Storage No_]=@tableId select @goodTraysInTable = count(*) from [Green Circle Growers$Container Entry] (nolock) where [Container Type] = 1 and [Storage No_]=@tableId and [Fixing Status]=1 select @badTraysInTable = count(*) from [Green Circle Growers$Container Entry] (nolock) where [Container Type] = 1 and [Storage No_]=@tableId and [Fixing Status]=2 select @reviewTraysInTable = count(*) from [Green Circle Growers$Container Entry] (nolock) where [Container Type] = 1 and [Storage No_]=@tableId and [Fixing Status]=3 select @traysToScanInTable = count(*) from [Green Circle Growers$Container Entry] (nolock) where [Container Type] = 1 and [Storage No_]=@tableId and [Fixing Status] Not in (1,2,3) select @totalTraysInTable [TotalTraysInTable] , @goodTraysInTable [GoodTraysInTable] , @badTraysInTable [BadTraysInTable] , @reviewTraysInTable [ReviewTraysInTable] , @traysToScanInTable [TraysToScanInTable]