Hi,
I have an issue with this stored procedure (code below), it returns me the following error:
An expression of non-boolean type specified in a context where a condition is expected, near 'seque'.
Can you please help me with it ?
Thank you
DECLARE @table_name nvarchar(max);
DECLARE @sequence nvarchar(max);
DECLARE @batch_no nvarchar(max);
DECLARE @SQL nvarchar(500);
DECLARE @ParmDef nvarchar(500)
SELECT @SQL ='select @batch_no_output=(select max(batch_no) from [glb_ops_tsq_audit].[batch]), @table_name_out=a.table_name, @sequence_out=a.sequence from [glb_ops_tsq_audit].[table_config] a
left join (select table_name,sequence,max_batch from (select table_name,sequence,max(batch_no) max_batch from [glb_ops_tsq_audit].[batch_processing_log]
group by table_name,sequence) a
where max_batch=(select(max(batch_no)) aa from [glb_ops_tsq_audit].[batch])) b
on trim(a.table_name)=trim(a.table_name) and a.sequence=b.sequence
where b.table_name is null' ;
SET @ParmDef = N'@table_name_out nvarchar(max) OUTPUT,@sequence_out nvarchar(max) OUTPUT,@batch_no_output nvarchar(max) OUTPUT';
EXEC sp_executesql @SQL, @ParmDef, @table_name_out=@table_name OUTPUT,@sequence_out=@sequence OUTPUT,@batch_no_output=@batch_no OUTPUT;
select @batch_no, @table_name ,@sequence