Skip to content

Instantly share code, notes, and snippets.

@bdcravens
Last active December 12, 2015 04:28
Show Gist options
  • Save bdcravens/4714774 to your computer and use it in GitHub Desktop.
Save bdcravens/4714774 to your computer and use it in GitHub Desktop.
Generates SQL (SQL Server 2000) for searching all text columns for a given string. (Need to remove last UNION) Good for catching SQL injection results.
SELECT
'select ' + column_name + ' as txt,
''' + column_name + ''' as [column_name],
id from applications where ' + column_name + ' like ''%payday%'' union '
FROM INFORMATION_SCHEMA.COLUMNS
where table_name = 'applications'
and data_type in ('nvarchar','varchar','char','nchar')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment