I want to create a dynamic stored procedure that would do some simple checks and that is setting these variables
SET @valuesInput = (select count(distinct COLUMN_1) from [TABLE_1] where [COLUMN_1] is not null)
SET @valuesInserted = (select count(distinct COLUMN_2) from [TABLE_2])
SET @countDuplicates = (select count(*) from [TABLE_2] group by COLUMN_2 having count(*) > 1)
SET @error_message = 'FAILED: xxxxxxxx'
That I can call from other stored procedures that need these controls to be done.
What I need help for - is how I make it dynamic? I mean, I would call this stored procedure in another stored procedure which are using different table names and columns.
For example - I want to call this stored procedure in another stored procedure where TABLE_1: employee, COLUMN_1: name
Then in another stored procedure, where TABLE_1: orders, COLUMN_1: product.