Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat. The purpose of this eBook is to educate the reader about ransomware attacks.
declare @sql varchar(max)
declare @a int ,@b int , @c int , @d int
set @sql = '';
if @a = 1
set @sql = 'WHERE a = 1'
if @b = 1
if @sql <> ''
set @sql = 'AND b = 1'
else
set @sql = 'WHERE b = 1'
if @c = 1
if @sql <> ''
set @sql = 'AND c = 1'
else
set @sql = 'WHERE c = 1'
if @d = 1
if @sql <> ''
set @sql = 'AND d = 1'
else
set @sql = 'WHERE d = 1'
set @sql = 'SELECT * FROM TABLEA ' + @sql
exec(@sql)
declare @sql varchar(max)
declare @a int ,@b int , @c int , @d int
set @sql = '';
if @a = 1
set @sql = ' WHERE a = 1'
if @b = 1
if @sql <> ''
set @sql = ' AND b = 1'
else
set @sql = ' WHERE b = 1'
if @c = 1
if @sql <> ''
set @sql = ' AND c = 1'
else
set @sql = ' WHERE c = 1'
if @d = 1
if @sql <> ''
set @sql = ' AND d = 1'
else
set @sql = ' WHERE d = 1'
set @sql = 'SELECT * FROM TABLEA ' + @sql
exec(@sql)
Declare @s int
SET @s = @a + @b + @c + @d
SELECT * FROM table
WHERE
a = CASE WHEN @s = 0 THEN a WHEN @a = 1 THEN 1 ELSE 2 END
OR b = CASE WHEN @s = 0 THEN b WHEN @b = 1 THEN 1 ELSE 2 END
OR c = CASE WHEN @s = 0 THEN c WHEN @c = 1 THEN 1 ELSE 2 END
OR d = CASE WHEN @s = 0 THEN d WHEN @d = 1 THEN 1 ELSE 2 END
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
SQL create line numbers for data sampling | 11 | 26 | |
RESTORE MASTER DATABASE -- NOW | 2 | 16 | |
SQL Error when trigger fires in SQL Server 2008 R2 | 6 | 13 | |
SQL - Simple Pivot query | 8 | 11 |
Join the community of 500,000 technology professionals and ask your questions.