This project contains an SQL stored procedure named GetTotalData
, which is designed to extract and count records from a specified table based on a date filter. The procedure dynamically constructs SQL queries to count records for each table and stores the results in a temporary table before returning the final dataset.
- Uses a cursor to iterate over a list of tables.
- Dynamically constructs and executes SQL queries.
- Filters records based on the current date.
- Stores and returns results in a temporary table.
- Declares a temporary table
#TempResult
to store the results. - Declares necessary variables for processing.
- Uses a cursor to iterate through the
extraccions_test
table to retrieve table names and related metadata. - Dynamically constructs and executes a SQL query to count records where the date field matches the current date.
- Stores the results in the temporary table.
- Returns the final dataset.
- Cleans up by closing and deallocating the cursor.
To execute the stored procedure, use the following command in SQL Server:
EXEC GetTotalData;