Skip to main content
Commonmark migration
Source Link

#MS SQL Server 2017, 152 150 146 bytes

MS SQL Server 2017, 152 150 146 bytes

CREATE FUNCTION f(@ NVARCHAR(MAX))RETURNS
TABLE RETURN SELECT IIF(2=ALL(SELECT
COUNT(*)FROM STRING_SPLIT(@,',')GROUP BY
PARSE(value AS INT)),1,0)r

The readable version:

CREATE FUNCTION f(@ NVARCHAR(MAX)) RETURNS TABLE RETURN
  SELECT IIF(2 = ALL(SELECT COUNT(*)
                     FROM STRING_SPLIT(@, ',')
                     GROUP BY PARSE(value AS INT)), 1, 0) AS r

Try it on SQL Fiddle!

-2 bytes thanks to Kevin Cruijssen

#MS SQL Server 2017, 152 150 146 bytes

CREATE FUNCTION f(@ NVARCHAR(MAX))RETURNS
TABLE RETURN SELECT IIF(2=ALL(SELECT
COUNT(*)FROM STRING_SPLIT(@,',')GROUP BY
PARSE(value AS INT)),1,0)r

The readable version:

CREATE FUNCTION f(@ NVARCHAR(MAX)) RETURNS TABLE RETURN
  SELECT IIF(2 = ALL(SELECT COUNT(*)
                     FROM STRING_SPLIT(@, ',')
                     GROUP BY PARSE(value AS INT)), 1, 0) AS r

Try it on SQL Fiddle!

-2 bytes thanks to Kevin Cruijssen

MS SQL Server 2017, 152 150 146 bytes

CREATE FUNCTION f(@ NVARCHAR(MAX))RETURNS
TABLE RETURN SELECT IIF(2=ALL(SELECT
COUNT(*)FROM STRING_SPLIT(@,',')GROUP BY
PARSE(value AS INT)),1,0)r

The readable version:

CREATE FUNCTION f(@ NVARCHAR(MAX)) RETURNS TABLE RETURN
  SELECT IIF(2 = ALL(SELECT COUNT(*)
                     FROM STRING_SPLIT(@, ',')
                     GROUP BY PARSE(value AS INT)), 1, 0) AS r

Try it on SQL Fiddle!

-2 bytes thanks to Kevin Cruijssen

added 38 characters in body
Source Link

#MS SQL Server 2017, 152152 150 146 bytes

CREATE FUNCTION f(@ NVARCHAR(MAX))RETURNS TABLE
TABLE RETURN SELECT IIF(2=ALL(SELECT  
COUNT(*)c
FROM STRING_SPLIT(@,',')GROUP BY
TRY_PARSEPARSE(value AS INT)),1,0)r

The readable version:

CREATE FUNCTION f(@ NVARCHAR(MAX)) RETURNS TABLE RETURN
  SELECT IIF(2 = ALL(SELECT COUNT(*) AS c
                     FROM STRING_SPLIT(@, ',')
                     GROUP BY TRY_PARSEPARSE(value AS INT)), 1, 0) AS r

Try it on SQL FiddleSQL Fiddle!

-2 bytes thanks to Kevin Cruijssen

#MS SQL Server 2017, 152 bytes

CREATE FUNCTION f(@ NVARCHAR(MAX))RETURNS TABLE
RETURN SELECT IIF(2=ALL(SELECT COUNT(*)c
FROM STRING_SPLIT(@,',')GROUP BY
TRY_PARSE(value AS INT)),1,0)r

The readable version:

CREATE FUNCTION f(@ NVARCHAR(MAX)) RETURNS TABLE RETURN
  SELECT IIF(2 = ALL(SELECT COUNT(*) AS c
                     FROM STRING_SPLIT(@, ',')
                     GROUP BY TRY_PARSE(value AS INT)), 1, 0) AS r

Try it on SQL Fiddle!

#MS SQL Server 2017, 152 150 146 bytes

CREATE FUNCTION f(@ NVARCHAR(MAX))RETURNS
TABLE RETURN SELECT IIF(2=ALL(SELECT 
COUNT(*)FROM STRING_SPLIT(@,',')GROUP BY
PARSE(value AS INT)),1,0)r

The readable version:

CREATE FUNCTION f(@ NVARCHAR(MAX)) RETURNS TABLE RETURN
  SELECT IIF(2 = ALL(SELECT COUNT(*)
                     FROM STRING_SPLIT(@, ',')
                     GROUP BY PARSE(value AS INT)), 1, 0) AS r

Try it on SQL Fiddle!

-2 bytes thanks to Kevin Cruijssen

Source Link

#MS SQL Server 2017, 152 bytes

CREATE FUNCTION f(@ NVARCHAR(MAX))RETURNS TABLE
RETURN SELECT IIF(2=ALL(SELECT COUNT(*)c
FROM STRING_SPLIT(@,',')GROUP BY
TRY_PARSE(value AS INT)),1,0)r

The readable version:

CREATE FUNCTION f(@ NVARCHAR(MAX)) RETURNS TABLE RETURN
  SELECT IIF(2 = ALL(SELECT COUNT(*) AS c
                     FROM STRING_SPLIT(@, ',')
                     GROUP BY TRY_PARSE(value AS INT)), 1, 0) AS r

Try it on SQL Fiddle!