%w in ruby allows one to separate array using whitespace instead of using quotes:
Ruby
%w(one two three)
Is there an equivalent function in SQL Server?
SQL Server
select case when 'one' in ('one', 'two','three') then 1 else 0 end
%w in ruby allows one to separate array using whitespace instead of using quotes:
Ruby
%w(one two three)
Is there an equivalent function in SQL Server?
SQL Server
select case when 'one' in ('one', 'two','three') then 1 else 0 end
Since this is SQL everything is either a table, a column or a row. You can sort of do it like this:
DECLARE @Numbers TABLE (Number varchar(10))
INSERT INTO @Numbers(Number) VALUES ('one'),('two'),('three')
SELECT CASE WHEN 'one' IN (SELECT Number FROM @Numbers) THEN 1 ELSE 0 END
Super-verbose, I know, but you have to consider this is a 70s-era language.
No.
The %w method is Ruby Syntatic Sugar for initializing an array of strings separated by spaces.
As mentioned by Zoff, SQL being a much older language, does not have anything like this.