Try increasing the size:
DECLARE @SQL nvarchar(max)
Show the new errors, if any.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
Try increasing the size:
DECLARE @SQL nvarchar(max)
Show the new errors, if any.
Start by correcting the SQL statement in @alenzi . Run it standalone to get it right.
btw, you don't need dynamic SQL in general here.
Hi,
The issue was in @alenzi value declared with limit of 500, I changed it to max and the stored proc worked fine.
Thank you all for your help.