Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql server set variable if exists

-- set @my_var = @my_val IF ALL values in a specified col(s) of @table1
-- also exist in a specified col(s) of @table2
-- OTHERWISE, set @my_var = 0
SET @my_var = CASE
WHEN NOT EXISTS (
SELECT my_col FROM @table1
EXCEPT                
SELECT my_col FROM @table2
THEN @my_val
ELSE 0
END
Comment

PREVIOUS NEXT
Code Example
Sql :: what is the default password for sql server sa 
Sql :: sql where keyword 
Sql :: sql truncate statement 
Sql :: mysql update row 
Sql :: check if record exists mysql 
Sql :: check if sql temp table exists 
Sql :: get count of duplicate records 
Sql :: oracle show index columns 
Sql :: get name of day in sql 
Sql :: allow external access to mysql 
Sql :: oracle replace 
Sql :: oracle trigger after logon on schema 
Sql :: calculate distance between two latitude longitude points sql 
Sql :: snap remove mysql workbench 
Sql :: mamp mysql path mac 
Sql :: SQL Count UNIQUE Rows 
Sql :: how to connect to xampp sql server on windows cmd 
Sql :: replace string value in sql 
Sql :: mariadb add foreign key 
Sql :: get date from timestamp oracle 
Sql :: rename column sql 
Sql :: pad zero sql server 
Sql :: install squirrel sql ubuntu 
Sql :: mysqldump ignore table 
Sql :: sql percentage 
Sql :: zsh-syntax-highlighting zsh-autosuggestions 
Sql :: mysql milliseconds 
Sql :: plpgsql create function 
Sql :: what is delimiter in mysql 
Sql :: sql line numbers 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =