Showing posts with the label dynamic-sql

[FIXED] How secure is format() for dynamic queries inside a function?

Issue After reading Postgres manual and many posts here, I wrote this function tacking in mind all …

[FIXED] Dynamic SQL select multiple columns based on json field(s) without exposing SQL Injection risks

Issue I'm creating a 'select colA, colB, colC, ...' stored proc, and I want the choice …

[FIXED] How to cleanse (prevent SQL injection) dynamic SQL in SQL Server?

Issue We have a ton of SQL Server stored procedures which rely on dynamic SQL. The parameters to …

[FIXED] Building dynamic where condition in SQL statement

Issue I want to build custom Where condition based on stored procedure inputs, if not null then I w…

[FIXED] SQL server Select statement, dynamically select 1 more column for each new distinct value in a column

Issue Thank you for the help in advance! Say I have a table like this (it is basically gonna be us…

[FIXED] Rolling up records by referencing values from one column to another

Issue I have a table where I have two columns- col1 & col2. The table need to be rolled up such…

[FIXED] Truncating all tables in a Postgres database

Issue I regularly need to delete all the data from my PostgreSQL database before a rebuild. How wou…

[FIXED] Drop all tables whose names begin with a certain string

Issue How can I drop all tables whose names begin with a given string? I think this can be done w…