From 22dd334fe6d546a46365a7631694dc4fd837d8b6 Mon Sep 17 00:00:00 2001 From: yashneet vinayak Date: Thu, 5 Dec 2024 11:32:55 +0000 Subject: [PATCH 01/21] handling edge case Signed-off-by: yashneet vinayak --- contrib/babelfishpg_tsql/src/pltsql_coerce.c | 135 ++++++++++++------ .../expected/BABEL-CASE_EXPR-vu-verify.out | 6 +- 2 files changed, 92 insertions(+), 49 deletions(-) diff --git a/contrib/babelfishpg_tsql/src/pltsql_coerce.c b/contrib/babelfishpg_tsql/src/pltsql_coerce.c index b245878aaf..36f0cbc15b 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_coerce.c +++ b/contrib/babelfishpg_tsql/src/pltsql_coerce.c @@ -2112,7 +2112,13 @@ select_common_type_for_coalesce_function(ParseState *pstate, List *exprs) static int32 tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) { - int32 max_typmods=0; + int32 max_typmods=0, + max_precision = 0, + max_scale = 0, + precision = 0, + scale = 0, + integralDigitCount = 0, + result_typmod = -1; ListCell *lc; common_utility_plugin *utilptr = common_utility_plugin_ptr; @@ -2123,7 +2129,9 @@ tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) !utilptr->is_tsql_binary_datatype(common_type) && !utilptr->is_tsql_sys_binary_datatype(common_type) && !utilptr->is_tsql_varbinary_datatype(common_type) && - !utilptr->is_tsql_sys_varbinary_datatype(common_type)) + !utilptr->is_tsql_sys_varbinary_datatype(common_type) && + !utilptr->is_tsql_decimal_datatype(common_type) && + !((common_type == NUMERICOID))) return -1; /* If resulting type is a length, need to be max of length types */ @@ -2133,26 +2141,78 @@ tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) int32 typmod = exprTypmod(expr); Oid type = exprType(expr); Oid immediate_base_type = get_immediate_base_type_of_UDT_internal(type); + - /* - * Handling for UDT, If immediate_base_type is Valid Oid that mean we need to handle typmod for UDT, - * By calculating typmod of its base type using getBaseTypeAndTypmod. - * Other wise if immediate_base_type is not Valid Oid We don't need any handling for UDT. - */ - if (OidIsValid(immediate_base_type)) + if (common_type == NUMERICOID || getBaseType(common_type) == NUMERICOID) { - /* Finding the typmod of base type of UDT using getBaseTypeAndTypmod() */ - int32 base_typmod = -1; - Oid base_type = getBaseTypeAndTypmod(type, &base_typmod); + if(typmod == -1) + continue; + scale = (typmod - VARHDRSZ) & 0xffff; + precision = ((typmod - VARHDRSZ) >> 16) & 0xffff; + integralDigitCount = Max(precision - scale, max_precision - max_scale); + max_scale = Max(max_scale, scale); + max_precision = integralDigitCount + max_scale; + /* + * If max_precision is more than TDS_MAX_NUM_PRECISION then adjust precision + * to TDS_MAX_NUM_PRECISION at the cost of scale. + */ + if (max_precision > 38) + { + max_scale = Max(0, max_scale - (max_precision - 38)); + max_precision = 38; + } + result_typmod = ((max_precision << 16) | max_scale) + VARHDRSZ; + } + else + { /* - * This conditon is for the datatype with MAX typmod. + * Handling for UDT, If immediate_base_type is Valid Oid that mean we need to handle typmod for UDT, + * By calculating typmod of its base type using getBaseTypeAndTypmod. + * Other wise if immediate_base_type is not Valid Oid We don't need any handling for UDT. + */ + if (OidIsValid(immediate_base_type)) + { + /* Finding the typmod of base type of UDT using getBaseTypeAndTypmod() */ + int32 base_typmod = -1; + Oid base_type = getBaseTypeAndTypmod(type, &base_typmod); + + /* + * This conditon is for the datatype with MAX typmod. + * -1 will only be returned if common_type is a datatype + * that supports MAX typmod. If common type is nchar(maxtypmod = 4000) + * or bpchar(maxtypmod = 8000) return the MAX typmod for them. + */ + if (base_typmod == -1 && + is_tsql_datatype_with_max_scale_expr_allowed(base_type)) + { + if ((*common_utility_plugin_ptr->is_tsql_bpchar_datatype)(common_type)) + return BPCHAR_MAX_TYPMOD + VARHDRSZ; + else if ((*common_utility_plugin_ptr->is_tsql_nchar_datatype)(common_type)) + return NCHAR_MAX_TYPMOD + VARHDRSZ; + else if (is_tsql_datatype_with_max_scale_expr_allowed(common_type)) + return -1; + } + + typmod = base_typmod; + } + + /* + * Handling for sysname, In CASE expression if one of the branch is + * of type sysname then set typmod as SYSNAME_TYPMOD (i.e. 128). + */ + if ((*common_utility_plugin_ptr->is_tsql_sysname_datatype) (type)) + typmod = SYSNAME_TYPMOD + VARHDRSZ; + + if (is_tsql_str_const(expr)) + typmod = strlen(DatumGetCString( ((Const*)expr)->constvalue )) + VARHDRSZ; + + /* This conditon is for the datatype with MAX typmod. * -1 will only be returned if common_type is a datatype - * that supports MAX typmod. If common type is nchar(maxtypmod = 4000) + * that supports MAX typmod.If common type is nchar(maxtypmod = 4000) * or bpchar(maxtypmod = 8000) return the MAX typmod for them. */ - if (base_typmod == -1 && - is_tsql_datatype_with_max_scale_expr_allowed(base_type)) + if (expr_is_var_max(expr)) { if ((*common_utility_plugin_ptr->is_tsql_bpchar_datatype)(common_type)) return BPCHAR_MAX_TYPMOD + VARHDRSZ; @@ -2161,42 +2221,25 @@ tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) else if (is_tsql_datatype_with_max_scale_expr_allowed(common_type)) return -1; } - - typmod = base_typmod; - } - - /* - * Handling for sysname, In CASE expression if one of the branch is - * of type sysname then set typmod as SYSNAME_TYPMOD (i.e. 128). - */ - if ((*common_utility_plugin_ptr->is_tsql_sysname_datatype) (type)) - typmod = SYSNAME_TYPMOD + VARHDRSZ; - - if (is_tsql_str_const(expr)) - typmod = strlen(DatumGetCString( ((Const*)expr)->constvalue )) + VARHDRSZ; - /* This conditon is for the datatype with MAX typmod. - * -1 will only be returned if common_type is a datatype - * that supports MAX typmod.If common type is nchar(maxtypmod = 4000) - * or bpchar(maxtypmod = 8000) return the MAX typmod for them. - */ - if (expr_is_var_max(expr)) - { - if ((*common_utility_plugin_ptr->is_tsql_bpchar_datatype)(common_type)) - return BPCHAR_MAX_TYPMOD + VARHDRSZ; - else if ((*common_utility_plugin_ptr->is_tsql_nchar_datatype)(common_type)) - return NCHAR_MAX_TYPMOD + VARHDRSZ; - else if (is_tsql_datatype_with_max_scale_expr_allowed(common_type)) - return -1; + if (lc == list_head(exprs)) + max_typmods = typmod; + else + max_typmods = Max(max_typmods, typmod); } - - if (lc == list_head(exprs)) - max_typmods = typmod; - else - max_typmods = Max(max_typmods, typmod); + } + if (common_type == NUMERICOID || getBaseType(common_type) == NUMERICOID) + { + if (result_typmod == -1) + return -1; + return result_typmod; + } + return max_typmods; + + } /* diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out index 76e7e954ca..d7b3fd3996 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out @@ -4658,7 +4658,7 @@ END AS RESULT GO ~~START~~ numeric -123 +123.00 ~~END~~ @@ -4691,7 +4691,7 @@ END AS RESULT GO ~~START~~ numeric -123 +123.00 ~~END~~ @@ -4702,7 +4702,7 @@ END AS RESULT GO ~~START~~ numeric -123.00000000 +123.000 ~~END~~ From 5c27a9010674e393b52228005e8244e4056bfc02 Mon Sep 17 00:00:00 2001 From: yashneet vinayak Date: Fri, 6 Dec 2024 09:09:00 +0000 Subject: [PATCH 02/21] testing commit Signed-off-by: yashneet vinayak --- contrib/babelfishpg_tsql/src/pltsql_coerce.c | 24 +- test/JDBC/expected/BABEL-4424.out | 16 +- ...SE_EXPR-before-16_5-or-15_9-vu-cleanup.out | 24 + ...SE_EXPR-before-16_5-or-15_9-vu-prepare.out | 103 ++ ...ASE_EXPR-before-16_5-or-15_9-vu-verify.out | 972 ++++++++++++++++++ .../expected/BABEL-CASE_EXPR-vu-cleanup.out | 24 + .../expected/BABEL-CASE_EXPR-vu-prepare.out | 103 ++ .../expected/BABEL-CASE_EXPR-vu-verify.out | 972 ++++++++++++++++++ ...SE_EXPR-before-16_5-or-15_9-vu-cleanup.sql | 26 +- ...SE_EXPR-before-16_5-or-15_9-vu-prepare.sql | 95 +- ...ASE_EXPR-before-16_5-or-15_9-vu-verify.sql | 589 +++++++++++ .../JDBC/input/BABEL-CASE_EXPR-vu-cleanup.sql | 26 +- .../JDBC/input/BABEL-CASE_EXPR-vu-prepare.sql | 95 +- test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql | 591 ++++++++++- 14 files changed, 3638 insertions(+), 22 deletions(-) diff --git a/contrib/babelfishpg_tsql/src/pltsql_coerce.c b/contrib/babelfishpg_tsql/src/pltsql_coerce.c index 36f0cbc15b..0a1cb41356 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_coerce.c +++ b/contrib/babelfishpg_tsql/src/pltsql_coerce.c @@ -51,6 +51,8 @@ #define NCHAR_MAX_TYPMOD 4000 #define BPCHAR_MAX_TYPMOD 8000 +#define TDS_MAX_NUM_PRECISION 38 + /* Hooks for engine*/ extern find_coercion_pathway_hook_type find_coercion_pathway_hook; extern determine_datatype_precedence_hook_type determine_datatype_precedence_hook; @@ -2103,10 +2105,9 @@ select_common_type_for_coalesce_function(ParseState *pstate, List *exprs) } /* - * When we must merge types together (i.e. UNION), if the target type - * is CHAR, NCHAR, or BINARY, make the typmod (representing the length) - * equal to that of the largest expression - * + * When we must merge types together (i.e. UNION, CASE), if the target + * type is CHAR, NCHAR, BINARY, NUMERIC or DECIMAL make the typmod + * (representing the length) equal to that of the largest expression * If -1 is returned, engine will handle finding a common typmod as usual */ static int32 @@ -2134,7 +2135,11 @@ tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) !((common_type == NUMERICOID))) return -1; - /* If resulting type is a length, need to be max of length types */ + /* If resulting type is a length, need to be max of length types, + * If the type is numeric or decimal then we calculate scale as + * max(s1, s2) and precision as max(s1, s2) + max(p1 - s1, p2 - s2) + * where s1, s2 are the scale of branches and p1, p2 are the precision. + */ foreach(lc, exprs) { Node *expr = (Node*) lfirst(lc); @@ -2143,7 +2148,8 @@ tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) Oid immediate_base_type = get_immediate_base_type_of_UDT_internal(type); - if (common_type == NUMERICOID || getBaseType(common_type) == NUMERICOID) + if (common_type == NUMERICOID || + getBaseType(common_type) == NUMERICOID) { if(typmod == -1) continue; @@ -2157,10 +2163,10 @@ tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) * If max_precision is more than TDS_MAX_NUM_PRECISION then adjust precision * to TDS_MAX_NUM_PRECISION at the cost of scale. */ - if (max_precision > 38) + if (max_precision > TDS_MAX_NUM_PRECISION) { - max_scale = Max(0, max_scale - (max_precision - 38)); - max_precision = 38; + max_scale = Max(0, max_scale - (max_precision - TDS_MAX_NUM_PRECISION)); + max_precision = TDS_MAX_NUM_PRECISION; } result_typmod = ((max_precision << 16) | max_scale) + VARHDRSZ; } diff --git a/test/JDBC/expected/BABEL-4424.out b/test/JDBC/expected/BABEL-4424.out index 5659724c1a..ce1388f540 100644 --- a/test/JDBC/expected/BABEL-4424.out +++ b/test/JDBC/expected/BABEL-4424.out @@ -261,7 +261,7 @@ go ~~START~~ numeric 11 -99 +100 1111111111111111111111111111111111111 9999999999999999999999999999999999999 ~~END~~ @@ -353,7 +353,7 @@ GO ~~START~~ numeric 11.11 -99.99 +100.00 111111111111111111111111111111111111.10 999999999999999999999999999999999999.90 ~~END~~ @@ -802,12 +802,12 @@ numeric 1.1111111111111 9.9999999990000 9.9999999990000 -9.9999999999999 -9.9999999999999 -9.9999999999999 -9.9999999999999 -9.9999999999999 -9.9999999999999 +10.0000000000000 +10.0000000000000 +10.0000000000000 +10.0000000000000 +10.0000000000000 +10.0000000000000 11.1000000000000 11.1000000000000 99.9000000000000 diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out index 66fe560185..1765f5a25e 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out @@ -10,3 +10,27 @@ GO DROP FUNCTION BABEL_5103_F1; GO + +DROP TABLE BABEL_5341_T1; +GO + +DROP VIEW BABEL_5341_V1; +GO + +DROP VIEW BABEL_5341_V2; +GO + +DROP VIEW BABEL_5341_V3; +GO + +DROP VIEW BABEL_5341_V4; +GO + +DROP VIEW BABEL_5341_V5; +GO + +DROP VIEW BABEL_5341_V6; +GO + +DROP FUNCTION BABEL_5341_F1; +GO diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out index 6299c6aaa4..901221c721 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out @@ -52,3 +52,106 @@ BEGIN ); END; GO + +CREATE TABLE BABEL_5341_T1 ( + COL1 NUMERIC(20,2), + COL2 DECIMAL(20,2), + COL3 NUMERIC(38,0), + COL4 DECIMAL(38,0), + COL5 NUMERIC(2,0), + COL6 DECIMAL(2,0) +); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (12345.67, 54321.98, 1234567890123456789, 9876543210987654321, 42, 99); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (98765.43, 12345.67, 9876543210987654321, 1234567890123456789, 10, 50); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (11111.11, 22222.22, 1111111111111111111, 2222222222222222222, 11, 22); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (33333.33, 44444.44, 3333333333333333333, 4444444444444444444, 33, 44); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (55555.55, 66666.66, 5555555555555555555, 6666666666666666666, 55, 66); +GO +~~ROW COUNT: 1~~ + + +CREATE VIEW BABEL_5341_V1 AS +SELECT CASE 3 + WHEN 1 THEN CAST(123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(678.90 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(1234.56 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V2 AS +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(6789 AS NUMERIC(10,0)) + WHEN 3 THEN CAST(12.3456 AS NUMERIC(10,4)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V3 AS +SELECT CASE 1 + WHEN 1 THEN CAST(1234567890123456 AS NUMERIC(20,0)) + WHEN 2 THEN CAST(9876543210987654 AS NUMERIC(20,0)) + WHEN 3 THEN CAST(1111222233334444 AS NUMERIC(20,0)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V4 AS +SELECT CASE 3 + WHEN 1 THEN CAST(0.0001 AS NUMERIC(10,4)) + WHEN 2 THEN CAST(0.0002 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(0.0003 AS NUMERIC(10,4)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V5 AS +SELECT CASE 2 + WHEN 1 THEN CAST(-123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(678.90 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(-1234.56 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V6 AS +SELECT CASE 3 + WHEN 1 THEN CAST(100 + 23.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(1000 - 321.10 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(500 * 2.5 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE FUNCTION BABEL_5341_F1(@ARG NUMERIC(20,2)) +RETURNS NUMERIC(20,4) +AS +BEGIN + RETURN ( + CASE + WHEN @ARG = 100.00 THEN CAST(123.45 AS NUMERIC(20,2)) + WHEN @ARG = 200.00 THEN CAST(6789 AS NUMERIC(20,0)) + WHEN @ARG = 300.00 THEN CAST(12.3456 AS NUMERIC(20,4)) + ELSE @ARG + END + ); +END; +GO diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index d162a5a3e5..5664bbe40d 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -13014,3 +13014,975 @@ GO ~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + +-- Testing for numeric and decimal +-- Test Case 1: Basic CASE with 6 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 0 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 2: CASE with 5 columns and ELSE +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +99 +50 +22 +44 +66 +~~END~~ + + +-- Test Case 3: CASE with 4 columns and ELSE +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + ELSE COL5 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +42 +10 +11 +33 +55 +~~END~~ + + +-- Test Case 4: CASE with 3 columns and ELSE +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + ELSE COL4 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 5: CASE with 2 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + ELSE COL3 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 6: CASE with 1 column and ELSE +SELECT CASE 2 + WHEN 1 THEN COL1 + ELSE COL2 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +54321.98 +12345.67 +22222.22 +44444.44 +66666.66 +~~END~~ + + +-- Test Case 7: CASE with all columns returning a constant value +SELECT CASE 7 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 999.99 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1000 +1000 +1000 +1000 +1000 +~~END~~ + + +-- Test Case 8: CASE with mixed constant and column values +SELECT CASE 4 + WHEN 1 THEN 100 + WHEN 2 THEN COL2 + WHEN 3 THEN 300 + WHEN 4 THEN COL4 + WHEN 5 THEN 500 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 9: CASE with views +SELECT * FROM BABEL_5341_V1; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +SELECT * FROM BABEL_5341_V2; +GO +~~START~~ +numeric +6789.0000 +~~END~~ + + +SELECT * FROM BABEL_5341_V3; +GO +~~START~~ +numeric +1234567890123456 +~~END~~ + + +SELECT * FROM BABEL_5341_V4; +GO +~~START~~ +numeric +0.0003 +~~END~~ + + +SELECT * FROM BABEL_5341_V5; +GO +~~START~~ +numeric +678.90 +~~END~~ + + +SELECT * FROM BABEL_5341_V6; +GO +~~START~~ +numeric +1250.00 +~~END~~ + + +-- Test Case 10: Using the function +SELECT BABEL_5341_F1(100.00); +GO +~~START~~ +numeric +123.4500 +~~END~~ + + +SELECT BABEL_5341_F1(200.00); +GO +~~START~~ +numeric +6789.0000 +~~END~~ + + +SELECT BABEL_5341_F1(300.00); +GO +~~START~~ +numeric +12.3456 +~~END~~ + + +SELECT BABEL_5341_F1(400.00); +GO +~~START~~ +numeric +400.0000 +~~END~~ + + +-- Test Case 11: Basic DECIMAL and NUMERIC usage +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +1234567.89000000 +~~END~~ + + +-- Test Case 12: Different scales within the same precision +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.43 AS DECIMAL(10,2)) + WHEN 3 THEN CAST(123456.7 AS DECIMAL(10,1)) + WHEN 4 THEN CAST(1234567 AS DECIMAL(10,0)) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS RESULT +GO +~~START~~ +numeric +98765.4300 +~~END~~ + + +-- Test Case 13: Mixing DECIMAL and NUMERIC with different precisions +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(12,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(15,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +9.87654321 +~~END~~ + + +-- Test Case 14: Large precisions and scales +SELECT CASE 2 + WHEN 1 THEN CAST(12345678901234567890.1234567890 AS DECIMAL(30,10)) + WHEN 2 THEN CAST(98765432109876543210.9876543210 AS NUMERIC(30,10)) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS DECIMAL(25,10)) + WHEN 4 THEN CAST(9.8765432109876543210 AS NUMERIC(20,19)) + ELSE CAST(0 AS DECIMAL(30,10)) +END AS RESULT +GO +~~START~~ +numeric +98765432109876543210.987654321000000000 +~~END~~ + + +-- Test Case 15: Small fractional parts +SELECT CASE 3 + WHEN 1 THEN CAST(12345.000001 AS DECIMAL(12,6)) + WHEN 2 THEN CAST(98765.0000001 AS NUMERIC(14,7)) + WHEN 3 THEN CAST(1234567.0000000001 AS DECIMAL(18,10)) + WHEN 4 THEN CAST(9.000000000000001 AS NUMERIC(17,15)) + ELSE CAST(0.00000001 AS DECIMAL(10,8)) +END AS RESULT +GO +~~START~~ +numeric +1234567.000000000100000 +~~END~~ + + +-- Test Case 16: Negative numbers +SELECT CASE 2 + WHEN 1 THEN CAST(-12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(-98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(-1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(-9.87654321 AS NUMERIC(9,8)) + ELSE CAST(-0.01 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +-98765.43210000 +~~END~~ + + +-- Test Case 17: Potential overflow scenarios +SELECT CASE 3 + WHEN 1 THEN CAST(99999.9999 AS DECIMAL(9,4)) + WHEN 2 THEN CAST(999999.999 AS NUMERIC(9,3)) + WHEN 3 THEN CAST(9999999.99 AS DECIMAL(9,2)) + WHEN 4 THEN CAST(99999999.9 AS NUMERIC(9,1)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT +GO +~~START~~ +numeric +9999999.9900 +~~END~~ + + +-- Test Case 18: Mixing with other numeric types +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765 AS INT) + WHEN 3 THEN CAST(1234567.89 AS FLOAT) + WHEN 4 THEN CAST(9 AS BIGINT) + ELSE CAST(0 AS NUMERIC(5,2)) +END AS RESULT +GO +~~START~~ +float +9.0 +~~END~~ + + + +-- Test Case 19: NUMERIC, DATETIME, and SQL_VARIANT in different branches +DECLARE @var SQL_VARIANT +SET @var = CAST(12345.6789 AS NUMERIC(10,4)) +SELECT CASE + WHEN CAST('2023-05-15' AS DATETIME) > '2023-01-01' THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN @var > 10000 THEN CAST('2023-12-31' AS DATETIME) + WHEN YEAR(GETDATE()) = 2023 THEN @var + ELSE CAST(11111.1111 AS NUMERIC(10,4)) +END AS RESULT +GO +~~START~~ +sql_variant +98765.4321 +~~END~~ + + + +-- Test Case 20: NUMERIC with different precisions, DATETIME, and SQL_VARIANT +DECLARE @var SQL_VARIANT +SET @var = CAST(123456.789 AS NUMERIC(15,3)) +SELECT CASE + WHEN CAST(12345.6789 AS NUMERIC(10,4)) > 10000 THEN CAST(9876543.21 AS NUMERIC(15,2)) + WHEN CAST('2023-05-15' AS DATETIME) < GETDATE() THEN CAST(123.456789 AS NUMERIC(9,6)) + WHEN SQL_VARIANT_PROPERTY(@var, 'Scale') > 2 THEN CAST(GETDATE() AS DATETIME) + ELSE @var +END AS RESULT +GO +~~START~~ +sql_variant +9876543.21 +~~END~~ + + +-- Test Case 21: SQL_VARIANT from BIGINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9223372036854775807 AS BIGINT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 22: SQL_VARIANT from DECIMAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(123.456 AS DECIMAL(10,3)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 23: SQL_VARIANT from FLOAT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(3.14159265359 AS FLOAT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 24: SQL_VARIANT from CHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('A' AS CHAR(1)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 25: SQL_VARIANT from VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('Hello, World!' AS VARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 26: SQL_VARIANT from NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(N'こんにちは' AS NVARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 27: SQL_VARIANT from DATE +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15' AS DATE) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 28: SQL_VARIANT from TIME +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('14:30:00' AS TIME) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 29: SQL_VARIANT from DATETIME2 +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00.1234567' AS DATETIME2(7)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 30: SQL_VARIANT from DATETIMEOFFSET +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00 +01:00' AS DATETIMEOFFSET) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 31: SQL_VARIANT from BIT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1 AS BIT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 32: SQL_VARIANT from UNIQUEIDENTIFIER +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(NEWID() AS UNIQUEIDENTIFIER) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 33: SQL_VARIANT from VARBINARY +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0x1234567890 AS VARBINARY(10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 34: SQL_VARIANT from NUMERIC(10,2) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567.89 AS NUMERIC(10,2)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 35: SQL_VARIANT from NUMERIC(5,4) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.1234 AS NUMERIC(5,4)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 36: SQL_VARIANT from NUMERIC(20,10) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567890.1234567890 AS NUMERIC(20,10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 37: SQL_VARIANT from NUMERIC(38,0) (maximum precision, no decimal places) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(12345678901234567890123456789012345678 AS NUMERIC(38,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 38: SQL_VARIANT from NUMERIC(38,38) (maximum precision and scale) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.12345678901234567890123456789012345678 AS NUMERIC(38,38)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 39: SQL_VARIANT from NUMERIC(1,0) (minimum precision) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9 AS NUMERIC(1,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 40: SQL_VARIANT from negative NUMERIC +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(-9876.54321 AS NUMERIC(10,5)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 41: Numeric branch with time +select case 1 + when 1 then cast(1.23 as numeric(20,2)) + when 2 then cast(1900-01-01 as datetime) +END +go +~~START~~ +datetime +1900-01-02 05:31:12.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type date to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('12:34:56' AS TIME) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type time without time zone to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetime2 to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetimeoffset to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-02 05:31:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) + WHEN 3 THEN CAST('12:34:56' AS TIME) + WHEN 4 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) + WHEN 5 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) + WHEN 6 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-01 00:00:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(GETDATE() AS DATE) + WHEN 3 THEN CAST(GETDATE() AS TIME) + WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) + WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) + WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +2024-12-06 00:00:00.0 +~~END~~ + + +-- Test Case 42: NUMERIC and TINYINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(255 AS TINYINT) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Test Case 43: NUMERIC and REAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(3.14 AS REAL) +END AS Result +GO +~~START~~ +real +1.23 +~~END~~ + + +-- Test Case 44: NUMERIC and NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(N'A' AS NCHAR(1)) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Create UDTs +CREATE TYPE NumericType_BABEL_5341 FROM NUMERIC(20,2); +GO + +CREATE TYPE DecimalType_BABEL_5341 FROM DECIMAL(18,4); +GO + +CREATE TYPE BigNumericType_BABEL_5341 FROM NUMERIC(38,10); +GO + +CREATE TYPE SmallDecimalType_BABEL_5341 FROM DECIMAL(5,2); +GO + +-- Test Case 45: Basic CASE with all UDTs +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.99 +~~END~~ + + +-- Test Case 46: CASE with UDTs and different precisions +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS DecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567890123456.7890123456 +~~END~~ + + +-- Test Case 47: CASE with UDTs and mathematical operations +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 * 2 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 / 2 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 + 1000 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 - 50 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +49382.7161 +~~END~~ + + +-- Test Case 48: CASE with UDTs and rounding +SELECT CASE 1 + WHEN 1 THEN CAST(ROUND(12345.6789, 2) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(ROUND(98765.4321, 4) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(ROUND(1234567.8901234567890, 10) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(ROUND(99.99, 1) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345.68 +~~END~~ + + +-- Test Case 49: CASE with UDTs and type conversion +SELECT CASE 4 + WHEN 1 THEN CAST(CAST(12345.6789 AS NumericType_BABEL_5341) AS BigNumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(98765.4321 AS DecimalType_BABEL_5341) AS SmallDecimalType_BABEL_5341) + WHEN 3 THEN CAST(CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) AS NumericType_BABEL_5341) + WHEN 4 THEN CAST(CAST(99.99 AS SmallDecimalType_BABEL_5341) AS DecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.9900 +~~END~~ + + +-- Test Case 50: CASE with UDTs and potential overflow +SELECT CASE 3 + WHEN 1 THEN CAST(9999999999999999.99 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(99999999999999.9999 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(12345678901234567890.1234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(999.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345678901234567890.1234567890 +~~END~~ + + +-- Test Case 51: CASE with UDTs and aggregate functions +SELECT CASE 2 + WHEN 1 THEN CAST(AVG(CAST(COLUMN_VALUE AS NumericType_BABEL_5341)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(SUM(CAST(COLUMN_VALUE AS DecimalType_BABEL_5341)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(MAX(CAST(COLUMN_VALUE AS BigNumericType_BABEL_5341)) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(MIN(CAST(COLUMN_VALUE AS SmallDecimalType_BABEL_5341)) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) +GO +~~START~~ +numeric +600.0000 +~~END~~ + + +-- Test Case 52: UDTs with INT and BIGINT +SELECT CASE 3 + WHEN 1 THEN CAST(12345 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(9876543210 AS BigNumericType_BABEL_5341) + WHEN 3 THEN CAST(1000 AS INT) + WHEN 4 THEN CAST(9223372036854775807 AS BIGINT) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1000 +~~END~~ + + +-- Test Case 53: UDTs with FLOAT and REAL +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS DecimalType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS FLOAT) + WHEN 3 THEN CAST(1234.56 AS REAL) + WHEN 4 THEN CAST(9.87654321 AS NumericType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +float +98765.4321 +~~END~~ + + +-- Test Case 54: UDTs with MONEY and SMALLMONEY +SELECT CASE 4 + WHEN 1 THEN CAST(12345.67 AS MONEY) + WHEN 2 THEN CAST(98.76 AS SMALLMONEY) + WHEN 3 THEN CAST(1234.5678 AS DecimalType_BABEL_5341) + WHEN 4 THEN CAST(9876.54 AS NumericType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +9876.54 +~~END~~ + + +-- Test Case 55: UDTs with VARCHAR and NVARCHAR +SELECT CASE 3 + WHEN 1 THEN CAST(CAST('12345.67' AS VARCHAR(20)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(N'98765.4321' AS NVARCHAR(20)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST('1234567.8901' AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(N'99.99' AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567.8901000000 +~~END~~ + + +-- Test Case 56: UDTs with BIT and mathematical operations +SELECT CASE 3 + WHEN 1 THEN CAST(1 AS BIT) * CAST(12345.67 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(0 AS BIT) * CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1 AS BIT) + CAST(1234567.8901 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(1 AS BIT) - CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234568.8901000000 +~~END~~ + + +DROP TYPE NumericType_BABEL_5341; +GO + +DROP TYPE DecimalType_BABEL_5341; +GO + +DROP TYPE BigNumericType_BABEL_5341; +GO + +DROP TYPE SmallDecimalType_BABEL_5341; +GO diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-cleanup.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-cleanup.out index 66fe560185..1765f5a25e 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-cleanup.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-cleanup.out @@ -10,3 +10,27 @@ GO DROP FUNCTION BABEL_5103_F1; GO + +DROP TABLE BABEL_5341_T1; +GO + +DROP VIEW BABEL_5341_V1; +GO + +DROP VIEW BABEL_5341_V2; +GO + +DROP VIEW BABEL_5341_V3; +GO + +DROP VIEW BABEL_5341_V4; +GO + +DROP VIEW BABEL_5341_V5; +GO + +DROP VIEW BABEL_5341_V6; +GO + +DROP FUNCTION BABEL_5341_F1; +GO diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out index 6299c6aaa4..901221c721 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out @@ -52,3 +52,106 @@ BEGIN ); END; GO + +CREATE TABLE BABEL_5341_T1 ( + COL1 NUMERIC(20,2), + COL2 DECIMAL(20,2), + COL3 NUMERIC(38,0), + COL4 DECIMAL(38,0), + COL5 NUMERIC(2,0), + COL6 DECIMAL(2,0) +); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (12345.67, 54321.98, 1234567890123456789, 9876543210987654321, 42, 99); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (98765.43, 12345.67, 9876543210987654321, 1234567890123456789, 10, 50); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (11111.11, 22222.22, 1111111111111111111, 2222222222222222222, 11, 22); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (33333.33, 44444.44, 3333333333333333333, 4444444444444444444, 33, 44); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (55555.55, 66666.66, 5555555555555555555, 6666666666666666666, 55, 66); +GO +~~ROW COUNT: 1~~ + + +CREATE VIEW BABEL_5341_V1 AS +SELECT CASE 3 + WHEN 1 THEN CAST(123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(678.90 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(1234.56 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V2 AS +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(6789 AS NUMERIC(10,0)) + WHEN 3 THEN CAST(12.3456 AS NUMERIC(10,4)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V3 AS +SELECT CASE 1 + WHEN 1 THEN CAST(1234567890123456 AS NUMERIC(20,0)) + WHEN 2 THEN CAST(9876543210987654 AS NUMERIC(20,0)) + WHEN 3 THEN CAST(1111222233334444 AS NUMERIC(20,0)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V4 AS +SELECT CASE 3 + WHEN 1 THEN CAST(0.0001 AS NUMERIC(10,4)) + WHEN 2 THEN CAST(0.0002 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(0.0003 AS NUMERIC(10,4)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V5 AS +SELECT CASE 2 + WHEN 1 THEN CAST(-123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(678.90 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(-1234.56 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V6 AS +SELECT CASE 3 + WHEN 1 THEN CAST(100 + 23.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(1000 - 321.10 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(500 * 2.5 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE FUNCTION BABEL_5341_F1(@ARG NUMERIC(20,2)) +RETURNS NUMERIC(20,4) +AS +BEGIN + RETURN ( + CASE + WHEN @ARG = 100.00 THEN CAST(123.45 AS NUMERIC(20,2)) + WHEN @ARG = 200.00 THEN CAST(6789 AS NUMERIC(20,0)) + WHEN @ARG = 300.00 THEN CAST(12.3456 AS NUMERIC(20,4)) + ELSE @ARG + END + ); +END; +GO diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out index d7b3fd3996..f7823448f0 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out @@ -13014,3 +13014,975 @@ GO ~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + +-- Testing for numeric and decimal +-- Test Case 1: Basic CASE with 6 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 0 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 2: CASE with 5 columns and ELSE +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +99 +50 +22 +44 +66 +~~END~~ + + +-- Test Case 3: CASE with 4 columns and ELSE +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + ELSE COL5 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +42 +10 +11 +33 +55 +~~END~~ + + +-- Test Case 4: CASE with 3 columns and ELSE +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + ELSE COL4 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 5: CASE with 2 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + ELSE COL3 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 6: CASE with 1 column and ELSE +SELECT CASE 2 + WHEN 1 THEN COL1 + ELSE COL2 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +54321.98 +12345.67 +22222.22 +44444.44 +66666.66 +~~END~~ + + +-- Test Case 7: CASE with all columns returning a constant value +SELECT CASE 7 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 999.99 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1000 +1000 +1000 +1000 +1000 +~~END~~ + + +-- Test Case 8: CASE with mixed constant and column values +SELECT CASE 4 + WHEN 1 THEN 100 + WHEN 2 THEN COL2 + WHEN 3 THEN 300 + WHEN 4 THEN COL4 + WHEN 5 THEN 500 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 9: CASE with views +SELECT * FROM BABEL_5341_V1; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +SELECT * FROM BABEL_5341_V2; +GO +~~START~~ +numeric +6789.0000 +~~END~~ + + +SELECT * FROM BABEL_5341_V3; +GO +~~START~~ +numeric +1234567890123456 +~~END~~ + + +SELECT * FROM BABEL_5341_V4; +GO +~~START~~ +numeric +0.0003 +~~END~~ + + +SELECT * FROM BABEL_5341_V5; +GO +~~START~~ +numeric +678.90 +~~END~~ + + +SELECT * FROM BABEL_5341_V6; +GO +~~START~~ +numeric +1250.00 +~~END~~ + + +-- Test Case 10: Using the function +SELECT BABEL_5341_F1(100.00); +GO +~~START~~ +numeric +123.4500 +~~END~~ + + +SELECT BABEL_5341_F1(200.00); +GO +~~START~~ +numeric +6789.0000 +~~END~~ + + +SELECT BABEL_5341_F1(300.00); +GO +~~START~~ +numeric +12.3456 +~~END~~ + + +SELECT BABEL_5341_F1(400.00); +GO +~~START~~ +numeric +400.0000 +~~END~~ + + +-- Test Case 11: Basic DECIMAL and NUMERIC usage +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +1234567.89000000 +~~END~~ + + +-- Test Case 12: Different scales within the same precision +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.43 AS DECIMAL(10,2)) + WHEN 3 THEN CAST(123456.7 AS DECIMAL(10,1)) + WHEN 4 THEN CAST(1234567 AS DECIMAL(10,0)) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS RESULT +GO +~~START~~ +numeric +98765.4300 +~~END~~ + + +-- Test Case 13: Mixing DECIMAL and NUMERIC with different precisions +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(12,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(15,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +9.87654321 +~~END~~ + + +-- Test Case 14: Large precisions and scales +SELECT CASE 2 + WHEN 1 THEN CAST(12345678901234567890.1234567890 AS DECIMAL(30,10)) + WHEN 2 THEN CAST(98765432109876543210.9876543210 AS NUMERIC(30,10)) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS DECIMAL(25,10)) + WHEN 4 THEN CAST(9.8765432109876543210 AS NUMERIC(20,19)) + ELSE CAST(0 AS DECIMAL(30,10)) +END AS RESULT +GO +~~START~~ +numeric +98765432109876543210.987654321000000000 +~~END~~ + + +-- Test Case 15: Small fractional parts +SELECT CASE 3 + WHEN 1 THEN CAST(12345.000001 AS DECIMAL(12,6)) + WHEN 2 THEN CAST(98765.0000001 AS NUMERIC(14,7)) + WHEN 3 THEN CAST(1234567.0000000001 AS DECIMAL(18,10)) + WHEN 4 THEN CAST(9.000000000000001 AS NUMERIC(17,15)) + ELSE CAST(0.00000001 AS DECIMAL(10,8)) +END AS RESULT +GO +~~START~~ +numeric +1234567.000000000100000 +~~END~~ + + +-- Test Case 16: Negative numbers +SELECT CASE 2 + WHEN 1 THEN CAST(-12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(-98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(-1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(-9.87654321 AS NUMERIC(9,8)) + ELSE CAST(-0.01 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +-98765.43210000 +~~END~~ + + +-- Test Case 17: Potential overflow scenarios +SELECT CASE 3 + WHEN 1 THEN CAST(99999.9999 AS DECIMAL(9,4)) + WHEN 2 THEN CAST(999999.999 AS NUMERIC(9,3)) + WHEN 3 THEN CAST(9999999.99 AS DECIMAL(9,2)) + WHEN 4 THEN CAST(99999999.9 AS NUMERIC(9,1)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT +GO +~~START~~ +numeric +9999999.9900 +~~END~~ + + +-- Test Case 18: Mixing with other numeric types +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765 AS INT) + WHEN 3 THEN CAST(1234567.89 AS FLOAT) + WHEN 4 THEN CAST(9 AS BIGINT) + ELSE CAST(0 AS NUMERIC(5,2)) +END AS RESULT +GO +~~START~~ +float +9.0 +~~END~~ + + + +-- Test Case 19: NUMERIC, DATETIME, and SQL_VARIANT in different branches +DECLARE @var SQL_VARIANT +SET @var = CAST(12345.6789 AS NUMERIC(10,4)) +SELECT CASE + WHEN CAST('2023-05-15' AS DATETIME) > '2023-01-01' THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN @var > 10000 THEN CAST('2023-12-31' AS DATETIME) + WHEN YEAR(GETDATE()) = 2023 THEN @var + ELSE CAST(11111.1111 AS NUMERIC(10,4)) +END AS RESULT +GO +~~START~~ +sql_variant +98765.4321 +~~END~~ + + + +-- Test Case 20: NUMERIC with different precisions, DATETIME, and SQL_VARIANT +DECLARE @var SQL_VARIANT +SET @var = CAST(123456.789 AS NUMERIC(15,3)) +SELECT CASE + WHEN CAST(12345.6789 AS NUMERIC(10,4)) > 10000 THEN CAST(9876543.21 AS NUMERIC(15,2)) + WHEN CAST('2023-05-15' AS DATETIME) < GETDATE() THEN CAST(123.456789 AS NUMERIC(9,6)) + WHEN SQL_VARIANT_PROPERTY(@var, 'Scale') > 2 THEN CAST(GETDATE() AS DATETIME) + ELSE @var +END AS RESULT +GO +~~START~~ +sql_variant +9876543.21 +~~END~~ + + +-- Test Case 21: SQL_VARIANT from BIGINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9223372036854775807 AS BIGINT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 22: SQL_VARIANT from DECIMAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(123.456 AS DECIMAL(10,3)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 23: SQL_VARIANT from FLOAT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(3.14159265359 AS FLOAT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 24: SQL_VARIANT from CHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('A' AS CHAR(1)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 25: SQL_VARIANT from VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('Hello, World!' AS VARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 26: SQL_VARIANT from NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(N'こんにちは' AS NVARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 27: SQL_VARIANT from DATE +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15' AS DATE) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 28: SQL_VARIANT from TIME +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('14:30:00' AS TIME) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 29: SQL_VARIANT from DATETIME2 +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00.1234567' AS DATETIME2(7)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 30: SQL_VARIANT from DATETIMEOFFSET +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00 +01:00' AS DATETIMEOFFSET) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 31: SQL_VARIANT from BIT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1 AS BIT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 32: SQL_VARIANT from UNIQUEIDENTIFIER +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(NEWID() AS UNIQUEIDENTIFIER) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 33: SQL_VARIANT from VARBINARY +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0x1234567890 AS VARBINARY(10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 34: SQL_VARIANT from NUMERIC(10,2) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567.89 AS NUMERIC(10,2)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 35: SQL_VARIANT from NUMERIC(5,4) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.1234 AS NUMERIC(5,4)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 36: SQL_VARIANT from NUMERIC(20,10) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567890.1234567890 AS NUMERIC(20,10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 37: SQL_VARIANT from NUMERIC(38,0) (maximum precision, no decimal places) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(12345678901234567890123456789012345678 AS NUMERIC(38,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 38: SQL_VARIANT from NUMERIC(38,38) (maximum precision and scale) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.12345678901234567890123456789012345678 AS NUMERIC(38,38)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 39: SQL_VARIANT from NUMERIC(1,0) (minimum precision) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9 AS NUMERIC(1,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 40: SQL_VARIANT from negative NUMERIC +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(-9876.54321 AS NUMERIC(10,5)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 41: Numeric branch with time +select case 1 + when 1 then cast(1.23 as numeric(20,2)) + when 2 then cast(1900-01-01 as datetime) +END +go +~~START~~ +datetime +1900-01-02 05:31:12.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type date to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('12:34:56' AS TIME) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type time without time zone to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetime2 to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetimeoffset to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-02 05:31:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) + WHEN 3 THEN CAST('12:34:56' AS TIME) + WHEN 4 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) + WHEN 5 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) + WHEN 6 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-01 00:00:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(GETDATE() AS DATE) + WHEN 3 THEN CAST(GETDATE() AS TIME) + WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) + WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) + WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +2024-12-06 00:00:00.0 +~~END~~ + + +-- Test Case 42: NUMERIC and TINYINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(255 AS TINYINT) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Test Case 43: NUMERIC and REAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(3.14 AS REAL) +END AS Result +GO +~~START~~ +real +1.23 +~~END~~ + + +-- Test Case 44: NUMERIC and NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(N'A' AS NCHAR(1)) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Create UDTs +CREATE TYPE NumericType_BABEL_5341 FROM NUMERIC(20,2); +GO + +CREATE TYPE DecimalType_BABEL_5341 FROM DECIMAL(18,4); +GO + +CREATE TYPE BigNumericType_BABEL_5341 FROM NUMERIC(38,10); +GO + +CREATE TYPE SmallDecimalType_BABEL_5341 FROM DECIMAL(5,2); +GO + +-- Test Case 45: Basic CASE with all UDTs +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.99 +~~END~~ + + +-- Test Case 46: CASE with UDTs and different precisions +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS DecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567890123456.7890123456 +~~END~~ + + +-- Test Case 47: CASE with UDTs and mathematical operations +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 * 2 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 / 2 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 + 1000 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 - 50 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +49382.7161 +~~END~~ + + +-- Test Case 48: CASE with UDTs and rounding +SELECT CASE 1 + WHEN 1 THEN CAST(ROUND(12345.6789, 2) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(ROUND(98765.4321, 4) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(ROUND(1234567.8901234567890, 10) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(ROUND(99.99, 1) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345.68 +~~END~~ + + +-- Test Case 49: CASE with UDTs and type conversion +SELECT CASE 4 + WHEN 1 THEN CAST(CAST(12345.6789 AS NumericType_BABEL_5341) AS BigNumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(98765.4321 AS DecimalType_BABEL_5341) AS SmallDecimalType_BABEL_5341) + WHEN 3 THEN CAST(CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) AS NumericType_BABEL_5341) + WHEN 4 THEN CAST(CAST(99.99 AS SmallDecimalType_BABEL_5341) AS DecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.9900 +~~END~~ + + +-- Test Case 50: CASE with UDTs and potential overflow +SELECT CASE 3 + WHEN 1 THEN CAST(9999999999999999.99 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(99999999999999.9999 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(12345678901234567890.1234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(999.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345678901234567890.1234567890 +~~END~~ + + +-- Test Case 51: CASE with UDTs and aggregate functions +SELECT CASE 2 + WHEN 1 THEN CAST(AVG(CAST(COLUMN_VALUE AS NumericType_BABEL_5341)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(SUM(CAST(COLUMN_VALUE AS DecimalType_BABEL_5341)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(MAX(CAST(COLUMN_VALUE AS BigNumericType_BABEL_5341)) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(MIN(CAST(COLUMN_VALUE AS SmallDecimalType_BABEL_5341)) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) +GO +~~START~~ +numeric +600.0000 +~~END~~ + + +-- Test Case 52: UDTs with INT and BIGINT +SELECT CASE 3 + WHEN 1 THEN CAST(12345 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(9876543210 AS BigNumericType_BABEL_5341) + WHEN 3 THEN CAST(1000 AS INT) + WHEN 4 THEN CAST(9223372036854775807 AS BIGINT) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1000 +~~END~~ + + +-- Test Case 53: UDTs with FLOAT and REAL +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS DecimalType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS FLOAT) + WHEN 3 THEN CAST(1234.56 AS REAL) + WHEN 4 THEN CAST(9.87654321 AS NumericType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +float +98765.4321 +~~END~~ + + +-- Test Case 54: UDTs with MONEY and SMALLMONEY +SELECT CASE 4 + WHEN 1 THEN CAST(12345.67 AS MONEY) + WHEN 2 THEN CAST(98.76 AS SMALLMONEY) + WHEN 3 THEN CAST(1234.5678 AS DecimalType_BABEL_5341) + WHEN 4 THEN CAST(9876.54 AS NumericType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +9876.54 +~~END~~ + + +-- Test Case 55: UDTs with VARCHAR and NVARCHAR +SELECT CASE 3 + WHEN 1 THEN CAST(CAST('12345.67' AS VARCHAR(20)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(N'98765.4321' AS NVARCHAR(20)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST('1234567.8901' AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(N'99.99' AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567.8901000000 +~~END~~ + + +-- Test Case 56: UDTs with BIT and mathematical operations +SELECT CASE 3 + WHEN 1 THEN CAST(1 AS BIT) * CAST(12345.67 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(0 AS BIT) * CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1 AS BIT) + CAST(1234567.8901 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(1 AS BIT) - CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234568.8901000000 +~~END~~ + + +DROP TYPE NumericType_BABEL_5341; +GO + +DROP TYPE DecimalType_BABEL_5341; +GO + +DROP TYPE BigNumericType_BABEL_5341; +GO + +DROP TYPE SmallDecimalType_BABEL_5341; +GO diff --git a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.sql b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.sql index 1c7e215b30..1765f5a25e 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.sql @@ -9,4 +9,28 @@ DROP VIEW BABEL_5103_V2; GO DROP FUNCTION BABEL_5103_F1; -GO \ No newline at end of file +GO + +DROP TABLE BABEL_5341_T1; +GO + +DROP VIEW BABEL_5341_V1; +GO + +DROP VIEW BABEL_5341_V2; +GO + +DROP VIEW BABEL_5341_V3; +GO + +DROP VIEW BABEL_5341_V4; +GO + +DROP VIEW BABEL_5341_V5; +GO + +DROP VIEW BABEL_5341_V6; +GO + +DROP FUNCTION BABEL_5341_F1; +GO diff --git a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.sql b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.sql index 5e2ee38e00..9a14e11351 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.sql @@ -45,4 +45,97 @@ BEGIN END ); END; -GO \ No newline at end of file +GO + +CREATE TABLE BABEL_5341_T1 ( + COL1 NUMERIC(20,2), + COL2 DECIMAL(20,2), + COL3 NUMERIC(38,0), + COL4 DECIMAL(38,0), + COL5 NUMERIC(2,0), + COL6 DECIMAL(2,0) +); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (12345.67, 54321.98, 1234567890123456789, 9876543210987654321, 42, 99); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (98765.43, 12345.67, 9876543210987654321, 1234567890123456789, 10, 50); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (11111.11, 22222.22, 1111111111111111111, 2222222222222222222, 11, 22); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (33333.33, 44444.44, 3333333333333333333, 4444444444444444444, 33, 44); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (55555.55, 66666.66, 5555555555555555555, 6666666666666666666, 55, 66); +GO + +CREATE VIEW BABEL_5341_V1 AS +SELECT CASE 3 + WHEN 1 THEN CAST(123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(678.90 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(1234.56 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V2 AS +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(6789 AS NUMERIC(10,0)) + WHEN 3 THEN CAST(12.3456 AS NUMERIC(10,4)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V3 AS +SELECT CASE 1 + WHEN 1 THEN CAST(1234567890123456 AS NUMERIC(20,0)) + WHEN 2 THEN CAST(9876543210987654 AS NUMERIC(20,0)) + WHEN 3 THEN CAST(1111222233334444 AS NUMERIC(20,0)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V4 AS +SELECT CASE 3 + WHEN 1 THEN CAST(0.0001 AS NUMERIC(10,4)) + WHEN 2 THEN CAST(0.0002 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(0.0003 AS NUMERIC(10,4)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V5 AS +SELECT CASE 2 + WHEN 1 THEN CAST(-123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(678.90 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(-1234.56 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V6 AS +SELECT CASE 3 + WHEN 1 THEN CAST(100 + 23.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(1000 - 321.10 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(500 * 2.5 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE FUNCTION BABEL_5341_F1(@ARG NUMERIC(20,2)) +RETURNS NUMERIC(20,4) +AS +BEGIN + RETURN ( + CASE + WHEN @ARG = 100.00 THEN CAST(123.45 AS NUMERIC(20,2)) + WHEN @ARG = 200.00 THEN CAST(6789 AS NUMERIC(20,0)) + WHEN @ARG = 300.00 THEN CAST(12.3456 AS NUMERIC(20,4)) + ELSE @ARG + END + ); +END; +GO diff --git a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql index 4f4c0a0ece..a5956d1ce3 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql @@ -7403,3 +7403,592 @@ SELECT CASE 2 WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) END AS RESULT GO + +-- Testing for numeric and decimal +-- Test Case 1: Basic CASE with 6 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 0 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 2: CASE with 5 columns and ELSE +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 3: CASE with 4 columns and ELSE +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + ELSE COL5 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 4: CASE with 3 columns and ELSE +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + ELSE COL4 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 5: CASE with 2 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + ELSE COL3 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 6: CASE with 1 column and ELSE +SELECT CASE 2 + WHEN 1 THEN COL1 + ELSE COL2 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 7: CASE with all columns returning a constant value +SELECT CASE 7 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 999.99 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 8: CASE with mixed constant and column values +SELECT CASE 4 + WHEN 1 THEN 100 + WHEN 2 THEN COL2 + WHEN 3 THEN 300 + WHEN 4 THEN COL4 + WHEN 5 THEN 500 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 9: CASE with views +SELECT * FROM BABEL_5341_V1; +GO + +SELECT * FROM BABEL_5341_V2; +GO + +SELECT * FROM BABEL_5341_V3; +GO + +SELECT * FROM BABEL_5341_V4; +GO + +SELECT * FROM BABEL_5341_V5; +GO + +SELECT * FROM BABEL_5341_V6; +GO + +-- Test Case 10: Using the function +SELECT BABEL_5341_F1(100.00); +GO + +SELECT BABEL_5341_F1(200.00); +GO + +SELECT BABEL_5341_F1(300.00); +GO + +SELECT BABEL_5341_F1(400.00); +GO + +-- Test Case 11: Basic DECIMAL and NUMERIC usage +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO + +-- Test Case 12: Different scales within the same precision +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.43 AS DECIMAL(10,2)) + WHEN 3 THEN CAST(123456.7 AS DECIMAL(10,1)) + WHEN 4 THEN CAST(1234567 AS DECIMAL(10,0)) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS RESULT +GO + +-- Test Case 13: Mixing DECIMAL and NUMERIC with different precisions +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(12,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(15,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO + +-- Test Case 14: Large precisions and scales +SELECT CASE 2 + WHEN 1 THEN CAST(12345678901234567890.1234567890 AS DECIMAL(30,10)) + WHEN 2 THEN CAST(98765432109876543210.9876543210 AS NUMERIC(30,10)) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS DECIMAL(25,10)) + WHEN 4 THEN CAST(9.8765432109876543210 AS NUMERIC(20,19)) + ELSE CAST(0 AS DECIMAL(30,10)) +END AS RESULT +GO + +-- Test Case 15: Small fractional parts +SELECT CASE 3 + WHEN 1 THEN CAST(12345.000001 AS DECIMAL(12,6)) + WHEN 2 THEN CAST(98765.0000001 AS NUMERIC(14,7)) + WHEN 3 THEN CAST(1234567.0000000001 AS DECIMAL(18,10)) + WHEN 4 THEN CAST(9.000000000000001 AS NUMERIC(17,15)) + ELSE CAST(0.00000001 AS DECIMAL(10,8)) +END AS RESULT +GO + +-- Test Case 16: Negative numbers +SELECT CASE 2 + WHEN 1 THEN CAST(-12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(-98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(-1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(-9.87654321 AS NUMERIC(9,8)) + ELSE CAST(-0.01 AS DECIMAL(5,2)) +END AS RESULT +GO + +-- Test Case 17: Potential overflow scenarios +SELECT CASE 3 + WHEN 1 THEN CAST(99999.9999 AS DECIMAL(9,4)) + WHEN 2 THEN CAST(999999.999 AS NUMERIC(9,3)) + WHEN 3 THEN CAST(9999999.99 AS DECIMAL(9,2)) + WHEN 4 THEN CAST(99999999.9 AS NUMERIC(9,1)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT +GO + +-- Test Case 18: Mixing with other numeric types +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765 AS INT) + WHEN 3 THEN CAST(1234567.89 AS FLOAT) + WHEN 4 THEN CAST(9 AS BIGINT) + ELSE CAST(0 AS NUMERIC(5,2)) +END AS RESULT +GO + +-- Test Case 19: NUMERIC, DATETIME, and SQL_VARIANT in different branches +DECLARE @var SQL_VARIANT +SET @var = CAST(12345.6789 AS NUMERIC(10,4)) + +SELECT CASE + WHEN CAST('2023-05-15' AS DATETIME) > '2023-01-01' THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN @var > 10000 THEN CAST('2023-12-31' AS DATETIME) + WHEN YEAR(GETDATE()) = 2023 THEN @var + ELSE CAST(11111.1111 AS NUMERIC(10,4)) +END AS RESULT +GO + +-- Test Case 20: NUMERIC with different precisions, DATETIME, and SQL_VARIANT +DECLARE @var SQL_VARIANT +SET @var = CAST(123456.789 AS NUMERIC(15,3)) + +SELECT CASE + WHEN CAST(12345.6789 AS NUMERIC(10,4)) > 10000 THEN CAST(9876543.21 AS NUMERIC(15,2)) + WHEN CAST('2023-05-15' AS DATETIME) < GETDATE() THEN CAST(123.456789 AS NUMERIC(9,6)) + WHEN SQL_VARIANT_PROPERTY(@var, 'Scale') > 2 THEN CAST(GETDATE() AS DATETIME) + ELSE @var +END AS RESULT +GO + +-- Test Case 21: SQL_VARIANT from BIGINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9223372036854775807 AS BIGINT) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 22: SQL_VARIANT from DECIMAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(123.456 AS DECIMAL(10,3)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 23: SQL_VARIANT from FLOAT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(3.14159265359 AS FLOAT) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 24: SQL_VARIANT from CHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('A' AS CHAR(1)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 25: SQL_VARIANT from VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('Hello, World!' AS VARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 26: SQL_VARIANT from NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(N'こんにちは' AS NVARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 27: SQL_VARIANT from DATE +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15' AS DATE) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 28: SQL_VARIANT from TIME +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('14:30:00' AS TIME) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 29: SQL_VARIANT from DATETIME2 +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00.1234567' AS DATETIME2(7)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 30: SQL_VARIANT from DATETIMEOFFSET +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00 +01:00' AS DATETIMEOFFSET) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 31: SQL_VARIANT from BIT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1 AS BIT) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 32: SQL_VARIANT from UNIQUEIDENTIFIER +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(NEWID() AS UNIQUEIDENTIFIER) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 33: SQL_VARIANT from VARBINARY +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0x1234567890 AS VARBINARY(10)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 34: SQL_VARIANT from NUMERIC(10,2) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567.89 AS NUMERIC(10,2)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 35: SQL_VARIANT from NUMERIC(5,4) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.1234 AS NUMERIC(5,4)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 36: SQL_VARIANT from NUMERIC(20,10) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567890.1234567890 AS NUMERIC(20,10)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 37: SQL_VARIANT from NUMERIC(38,0) (maximum precision, no decimal places) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(12345678901234567890123456789012345678 AS NUMERIC(38,0)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 38: SQL_VARIANT from NUMERIC(38,38) (maximum precision and scale) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.12345678901234567890123456789012345678 AS NUMERIC(38,38)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 39: SQL_VARIANT from NUMERIC(1,0) (minimum precision) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9 AS NUMERIC(1,0)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 40: SQL_VARIANT from negative NUMERIC +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(-9876.54321 AS NUMERIC(10,5)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 41: Numeric branch with time +select case 1 + when 1 then cast(1.23 as numeric(20,2)) + when 2 then cast(1900-01-01 as datetime) +END +go + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) +END AS Result +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('12:34:56' AS TIME) +END AS Result +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) +END AS Result +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) +END AS Result +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) + WHEN 3 THEN CAST('12:34:56' AS TIME) + WHEN 4 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) + WHEN 5 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) + WHEN 6 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(GETDATE() AS DATE) + WHEN 3 THEN CAST(GETDATE() AS TIME) + WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) + WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) + WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) +END AS Result +GO + +-- Test Case 42: NUMERIC and TINYINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(255 AS TINYINT) +END AS Result +GO + +-- Test Case 43: NUMERIC and REAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(3.14 AS REAL) +END AS Result +GO + +-- Test Case 44: NUMERIC and NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(N'A' AS NCHAR(1)) +END AS Result +GO + +-- Create UDTs +CREATE TYPE NumericType_BABEL_5341 FROM NUMERIC(20,2); +GO + +CREATE TYPE DecimalType_BABEL_5341 FROM DECIMAL(18,4); +GO + +CREATE TYPE BigNumericType_BABEL_5341 FROM NUMERIC(38,10); +GO + +CREATE TYPE SmallDecimalType_BABEL_5341 FROM DECIMAL(5,2); +GO + +-- Test Case 45: Basic CASE with all UDTs +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 46: CASE with UDTs and different precisions +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS DecimalType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 47: CASE with UDTs and mathematical operations +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 * 2 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 / 2 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 + 1000 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 - 50 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 48: CASE with UDTs and rounding +SELECT CASE 1 + WHEN 1 THEN CAST(ROUND(12345.6789, 2) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(ROUND(98765.4321, 4) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(ROUND(1234567.8901234567890, 10) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(ROUND(99.99, 1) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 49: CASE with UDTs and type conversion +SELECT CASE 4 + WHEN 1 THEN CAST(CAST(12345.6789 AS NumericType_BABEL_5341) AS BigNumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(98765.4321 AS DecimalType_BABEL_5341) AS SmallDecimalType_BABEL_5341) + WHEN 3 THEN CAST(CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) AS NumericType_BABEL_5341) + WHEN 4 THEN CAST(CAST(99.99 AS SmallDecimalType_BABEL_5341) AS DecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 50: CASE with UDTs and potential overflow +SELECT CASE 3 + WHEN 1 THEN CAST(9999999999999999.99 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(99999999999999.9999 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(12345678901234567890.1234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(999.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 51: CASE with UDTs and aggregate functions +SELECT CASE 2 + WHEN 1 THEN CAST(AVG(CAST(COLUMN_VALUE AS NumericType_BABEL_5341)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(SUM(CAST(COLUMN_VALUE AS DecimalType_BABEL_5341)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(MAX(CAST(COLUMN_VALUE AS BigNumericType_BABEL_5341)) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(MIN(CAST(COLUMN_VALUE AS SmallDecimalType_BABEL_5341)) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) +GO + +-- Test Case 52: UDTs with INT and BIGINT +SELECT CASE 3 + WHEN 1 THEN CAST(12345 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(9876543210 AS BigNumericType_BABEL_5341) + WHEN 3 THEN CAST(1000 AS INT) + WHEN 4 THEN CAST(9223372036854775807 AS BIGINT) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 53: UDTs with FLOAT and REAL +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS DecimalType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS FLOAT) + WHEN 3 THEN CAST(1234.56 AS REAL) + WHEN 4 THEN CAST(9.87654321 AS NumericType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 54: UDTs with MONEY and SMALLMONEY +SELECT CASE 4 + WHEN 1 THEN CAST(12345.67 AS MONEY) + WHEN 2 THEN CAST(98.76 AS SMALLMONEY) + WHEN 3 THEN CAST(1234.5678 AS DecimalType_BABEL_5341) + WHEN 4 THEN CAST(9876.54 AS NumericType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 55: UDTs with VARCHAR and NVARCHAR +SELECT CASE 3 + WHEN 1 THEN CAST(CAST('12345.67' AS VARCHAR(20)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(N'98765.4321' AS NVARCHAR(20)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST('1234567.8901' AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(N'99.99' AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 56: UDTs with BIT and mathematical operations +SELECT CASE 3 + WHEN 1 THEN CAST(1 AS BIT) * CAST(12345.67 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(0 AS BIT) * CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1 AS BIT) + CAST(1234567.8901 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(1 AS BIT) - CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO + +DROP TYPE NumericType_BABEL_5341; +GO + +DROP TYPE DecimalType_BABEL_5341; +GO + +DROP TYPE BigNumericType_BABEL_5341; +GO + +DROP TYPE SmallDecimalType_BABEL_5341; +GO diff --git a/test/JDBC/input/BABEL-CASE_EXPR-vu-cleanup.sql b/test/JDBC/input/BABEL-CASE_EXPR-vu-cleanup.sql index 1c7e215b30..1765f5a25e 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-vu-cleanup.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-vu-cleanup.sql @@ -9,4 +9,28 @@ DROP VIEW BABEL_5103_V2; GO DROP FUNCTION BABEL_5103_F1; -GO \ No newline at end of file +GO + +DROP TABLE BABEL_5341_T1; +GO + +DROP VIEW BABEL_5341_V1; +GO + +DROP VIEW BABEL_5341_V2; +GO + +DROP VIEW BABEL_5341_V3; +GO + +DROP VIEW BABEL_5341_V4; +GO + +DROP VIEW BABEL_5341_V5; +GO + +DROP VIEW BABEL_5341_V6; +GO + +DROP FUNCTION BABEL_5341_F1; +GO diff --git a/test/JDBC/input/BABEL-CASE_EXPR-vu-prepare.sql b/test/JDBC/input/BABEL-CASE_EXPR-vu-prepare.sql index 5e2ee38e00..9a14e11351 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-vu-prepare.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-vu-prepare.sql @@ -45,4 +45,97 @@ BEGIN END ); END; -GO \ No newline at end of file +GO + +CREATE TABLE BABEL_5341_T1 ( + COL1 NUMERIC(20,2), + COL2 DECIMAL(20,2), + COL3 NUMERIC(38,0), + COL4 DECIMAL(38,0), + COL5 NUMERIC(2,0), + COL6 DECIMAL(2,0) +); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (12345.67, 54321.98, 1234567890123456789, 9876543210987654321, 42, 99); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (98765.43, 12345.67, 9876543210987654321, 1234567890123456789, 10, 50); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (11111.11, 22222.22, 1111111111111111111, 2222222222222222222, 11, 22); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (33333.33, 44444.44, 3333333333333333333, 4444444444444444444, 33, 44); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (55555.55, 66666.66, 5555555555555555555, 6666666666666666666, 55, 66); +GO + +CREATE VIEW BABEL_5341_V1 AS +SELECT CASE 3 + WHEN 1 THEN CAST(123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(678.90 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(1234.56 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V2 AS +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(6789 AS NUMERIC(10,0)) + WHEN 3 THEN CAST(12.3456 AS NUMERIC(10,4)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V3 AS +SELECT CASE 1 + WHEN 1 THEN CAST(1234567890123456 AS NUMERIC(20,0)) + WHEN 2 THEN CAST(9876543210987654 AS NUMERIC(20,0)) + WHEN 3 THEN CAST(1111222233334444 AS NUMERIC(20,0)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V4 AS +SELECT CASE 3 + WHEN 1 THEN CAST(0.0001 AS NUMERIC(10,4)) + WHEN 2 THEN CAST(0.0002 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(0.0003 AS NUMERIC(10,4)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V5 AS +SELECT CASE 2 + WHEN 1 THEN CAST(-123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(678.90 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(-1234.56 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V6 AS +SELECT CASE 3 + WHEN 1 THEN CAST(100 + 23.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(1000 - 321.10 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(500 * 2.5 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE FUNCTION BABEL_5341_F1(@ARG NUMERIC(20,2)) +RETURNS NUMERIC(20,4) +AS +BEGIN + RETURN ( + CASE + WHEN @ARG = 100.00 THEN CAST(123.45 AS NUMERIC(20,2)) + WHEN @ARG = 200.00 THEN CAST(6789 AS NUMERIC(20,0)) + WHEN @ARG = 300.00 THEN CAST(12.3456 AS NUMERIC(20,4)) + ELSE @ARG + END + ); +END; +GO diff --git a/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql b/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql index 8d4c246d38..775302fc0c 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql @@ -1,4 +1,4 @@ --- sla 80000 +-- sla 100000 SELECT CASE 1 WHEN 1 THEN COL1 WHEN 2 THEN COL2 @@ -7404,3 +7404,592 @@ SELECT CASE 2 WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) END AS RESULT GO + +-- Testing for numeric and decimal +-- Test Case 1: Basic CASE with 6 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 0 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 2: CASE with 5 columns and ELSE +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 3: CASE with 4 columns and ELSE +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + ELSE COL5 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 4: CASE with 3 columns and ELSE +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + ELSE COL4 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 5: CASE with 2 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + ELSE COL3 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 6: CASE with 1 column and ELSE +SELECT CASE 2 + WHEN 1 THEN COL1 + ELSE COL2 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 7: CASE with all columns returning a constant value +SELECT CASE 7 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 999.99 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 8: CASE with mixed constant and column values +SELECT CASE 4 + WHEN 1 THEN 100 + WHEN 2 THEN COL2 + WHEN 3 THEN 300 + WHEN 4 THEN COL4 + WHEN 5 THEN 500 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 9: CASE with views +SELECT * FROM BABEL_5341_V1; +GO + +SELECT * FROM BABEL_5341_V2; +GO + +SELECT * FROM BABEL_5341_V3; +GO + +SELECT * FROM BABEL_5341_V4; +GO + +SELECT * FROM BABEL_5341_V5; +GO + +SELECT * FROM BABEL_5341_V6; +GO + +-- Test Case 10: Using the function +SELECT BABEL_5341_F1(100.00); +GO + +SELECT BABEL_5341_F1(200.00); +GO + +SELECT BABEL_5341_F1(300.00); +GO + +SELECT BABEL_5341_F1(400.00); +GO + +-- Test Case 11: Basic DECIMAL and NUMERIC usage +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO + +-- Test Case 12: Different scales within the same precision +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.43 AS DECIMAL(10,2)) + WHEN 3 THEN CAST(123456.7 AS DECIMAL(10,1)) + WHEN 4 THEN CAST(1234567 AS DECIMAL(10,0)) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS RESULT +GO + +-- Test Case 13: Mixing DECIMAL and NUMERIC with different precisions +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(12,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(15,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO + +-- Test Case 14: Large precisions and scales +SELECT CASE 2 + WHEN 1 THEN CAST(12345678901234567890.1234567890 AS DECIMAL(30,10)) + WHEN 2 THEN CAST(98765432109876543210.9876543210 AS NUMERIC(30,10)) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS DECIMAL(25,10)) + WHEN 4 THEN CAST(9.8765432109876543210 AS NUMERIC(20,19)) + ELSE CAST(0 AS DECIMAL(30,10)) +END AS RESULT +GO + +-- Test Case 15: Small fractional parts +SELECT CASE 3 + WHEN 1 THEN CAST(12345.000001 AS DECIMAL(12,6)) + WHEN 2 THEN CAST(98765.0000001 AS NUMERIC(14,7)) + WHEN 3 THEN CAST(1234567.0000000001 AS DECIMAL(18,10)) + WHEN 4 THEN CAST(9.000000000000001 AS NUMERIC(17,15)) + ELSE CAST(0.00000001 AS DECIMAL(10,8)) +END AS RESULT +GO + +-- Test Case 16: Negative numbers +SELECT CASE 2 + WHEN 1 THEN CAST(-12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(-98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(-1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(-9.87654321 AS NUMERIC(9,8)) + ELSE CAST(-0.01 AS DECIMAL(5,2)) +END AS RESULT +GO + +-- Test Case 17: Potential overflow scenarios +SELECT CASE 3 + WHEN 1 THEN CAST(99999.9999 AS DECIMAL(9,4)) + WHEN 2 THEN CAST(999999.999 AS NUMERIC(9,3)) + WHEN 3 THEN CAST(9999999.99 AS DECIMAL(9,2)) + WHEN 4 THEN CAST(99999999.9 AS NUMERIC(9,1)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT +GO + +-- Test Case 18: Mixing with other numeric types +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765 AS INT) + WHEN 3 THEN CAST(1234567.89 AS FLOAT) + WHEN 4 THEN CAST(9 AS BIGINT) + ELSE CAST(0 AS NUMERIC(5,2)) +END AS RESULT +GO + +-- Test Case 19: NUMERIC, DATETIME, and SQL_VARIANT in different branches +DECLARE @var SQL_VARIANT +SET @var = CAST(12345.6789 AS NUMERIC(10,4)) + +SELECT CASE + WHEN CAST('2023-05-15' AS DATETIME) > '2023-01-01' THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN @var > 10000 THEN CAST('2023-12-31' AS DATETIME) + WHEN YEAR(GETDATE()) = 2023 THEN @var + ELSE CAST(11111.1111 AS NUMERIC(10,4)) +END AS RESULT +GO + +-- Test Case 20: NUMERIC with different precisions, DATETIME, and SQL_VARIANT +DECLARE @var SQL_VARIANT +SET @var = CAST(123456.789 AS NUMERIC(15,3)) + +SELECT CASE + WHEN CAST(12345.6789 AS NUMERIC(10,4)) > 10000 THEN CAST(9876543.21 AS NUMERIC(15,2)) + WHEN CAST('2023-05-15' AS DATETIME) < GETDATE() THEN CAST(123.456789 AS NUMERIC(9,6)) + WHEN SQL_VARIANT_PROPERTY(@var, 'Scale') > 2 THEN CAST(GETDATE() AS DATETIME) + ELSE @var +END AS RESULT +GO + +-- Test Case 21: SQL_VARIANT from BIGINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9223372036854775807 AS BIGINT) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 22: SQL_VARIANT from DECIMAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(123.456 AS DECIMAL(10,3)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 23: SQL_VARIANT from FLOAT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(3.14159265359 AS FLOAT) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 24: SQL_VARIANT from CHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('A' AS CHAR(1)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 25: SQL_VARIANT from VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('Hello, World!' AS VARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 26: SQL_VARIANT from NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(N'こんにちは' AS NVARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 27: SQL_VARIANT from DATE +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15' AS DATE) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 28: SQL_VARIANT from TIME +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('14:30:00' AS TIME) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 29: SQL_VARIANT from DATETIME2 +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00.1234567' AS DATETIME2(7)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 30: SQL_VARIANT from DATETIMEOFFSET +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00 +01:00' AS DATETIMEOFFSET) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 31: SQL_VARIANT from BIT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1 AS BIT) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 32: SQL_VARIANT from UNIQUEIDENTIFIER +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(NEWID() AS UNIQUEIDENTIFIER) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 33: SQL_VARIANT from VARBINARY +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0x1234567890 AS VARBINARY(10)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 34: SQL_VARIANT from NUMERIC(10,2) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567.89 AS NUMERIC(10,2)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 35: SQL_VARIANT from NUMERIC(5,4) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.1234 AS NUMERIC(5,4)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 36: SQL_VARIANT from NUMERIC(20,10) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567890.1234567890 AS NUMERIC(20,10)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 37: SQL_VARIANT from NUMERIC(38,0) (maximum precision, no decimal places) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(12345678901234567890123456789012345678 AS NUMERIC(38,0)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 38: SQL_VARIANT from NUMERIC(38,38) (maximum precision and scale) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.12345678901234567890123456789012345678 AS NUMERIC(38,38)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 39: SQL_VARIANT from NUMERIC(1,0) (minimum precision) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9 AS NUMERIC(1,0)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 40: SQL_VARIANT from negative NUMERIC +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(-9876.54321 AS NUMERIC(10,5)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 41: Numeric branch with time +select case 1 + when 1 then cast(1.23 as numeric(20,2)) + when 2 then cast(1900-01-01 as datetime) +END +go + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) +END AS Result +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('12:34:56' AS TIME) +END AS Result +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) +END AS Result +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) +END AS Result +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) + WHEN 3 THEN CAST('12:34:56' AS TIME) + WHEN 4 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) + WHEN 5 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) + WHEN 6 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(GETDATE() AS DATE) + WHEN 3 THEN CAST(GETDATE() AS TIME) + WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) + WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) + WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) +END AS Result +GO + +-- Test Case 42: NUMERIC and TINYINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(255 AS TINYINT) +END AS Result +GO + +-- Test Case 43: NUMERIC and REAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(3.14 AS REAL) +END AS Result +GO + +-- Test Case 44: NUMERIC and NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(N'A' AS NCHAR(1)) +END AS Result +GO + +-- Create UDTs +CREATE TYPE NumericType_BABEL_5341 FROM NUMERIC(20,2); +GO + +CREATE TYPE DecimalType_BABEL_5341 FROM DECIMAL(18,4); +GO + +CREATE TYPE BigNumericType_BABEL_5341 FROM NUMERIC(38,10); +GO + +CREATE TYPE SmallDecimalType_BABEL_5341 FROM DECIMAL(5,2); +GO + +-- Test Case 45: Basic CASE with all UDTs +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 46: CASE with UDTs and different precisions +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS DecimalType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 47: CASE with UDTs and mathematical operations +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 * 2 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 / 2 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 + 1000 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 - 50 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 48: CASE with UDTs and rounding +SELECT CASE 1 + WHEN 1 THEN CAST(ROUND(12345.6789, 2) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(ROUND(98765.4321, 4) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(ROUND(1234567.8901234567890, 10) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(ROUND(99.99, 1) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 49: CASE with UDTs and type conversion +SELECT CASE 4 + WHEN 1 THEN CAST(CAST(12345.6789 AS NumericType_BABEL_5341) AS BigNumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(98765.4321 AS DecimalType_BABEL_5341) AS SmallDecimalType_BABEL_5341) + WHEN 3 THEN CAST(CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) AS NumericType_BABEL_5341) + WHEN 4 THEN CAST(CAST(99.99 AS SmallDecimalType_BABEL_5341) AS DecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 50: CASE with UDTs and potential overflow +SELECT CASE 3 + WHEN 1 THEN CAST(9999999999999999.99 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(99999999999999.9999 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(12345678901234567890.1234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(999.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 51: CASE with UDTs and aggregate functions +SELECT CASE 2 + WHEN 1 THEN CAST(AVG(CAST(COLUMN_VALUE AS NumericType_BABEL_5341)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(SUM(CAST(COLUMN_VALUE AS DecimalType_BABEL_5341)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(MAX(CAST(COLUMN_VALUE AS BigNumericType_BABEL_5341)) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(MIN(CAST(COLUMN_VALUE AS SmallDecimalType_BABEL_5341)) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) +GO + +-- Test Case 52: UDTs with INT and BIGINT +SELECT CASE 3 + WHEN 1 THEN CAST(12345 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(9876543210 AS BigNumericType_BABEL_5341) + WHEN 3 THEN CAST(1000 AS INT) + WHEN 4 THEN CAST(9223372036854775807 AS BIGINT) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 53: UDTs with FLOAT and REAL +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS DecimalType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS FLOAT) + WHEN 3 THEN CAST(1234.56 AS REAL) + WHEN 4 THEN CAST(9.87654321 AS NumericType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 54: UDTs with MONEY and SMALLMONEY +SELECT CASE 4 + WHEN 1 THEN CAST(12345.67 AS MONEY) + WHEN 2 THEN CAST(98.76 AS SMALLMONEY) + WHEN 3 THEN CAST(1234.5678 AS DecimalType_BABEL_5341) + WHEN 4 THEN CAST(9876.54 AS NumericType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 55: UDTs with VARCHAR and NVARCHAR +SELECT CASE 3 + WHEN 1 THEN CAST(CAST('12345.67' AS VARCHAR(20)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(N'98765.4321' AS NVARCHAR(20)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST('1234567.8901' AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(N'99.99' AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 56: UDTs with BIT and mathematical operations +SELECT CASE 3 + WHEN 1 THEN CAST(1 AS BIT) * CAST(12345.67 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(0 AS BIT) * CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1 AS BIT) + CAST(1234567.8901 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(1 AS BIT) - CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO + +DROP TYPE NumericType_BABEL_5341; +GO + +DROP TYPE DecimalType_BABEL_5341; +GO + +DROP TYPE BigNumericType_BABEL_5341; +GO + +DROP TYPE SmallDecimalType_BABEL_5341; +GO From edc3c562dec446e46cd5e70f82ce375bab8f6d43 Mon Sep 17 00:00:00 2001 From: yashneet vinayak Date: Fri, 6 Dec 2024 11:03:49 +0000 Subject: [PATCH 03/21] test changes Signed-off-by: yashneet vinayak --- contrib/babelfishpg_tsql/src/pltsql_coerce.c | 12 +- ...ASE_EXPR-before-16_5-or-15_9-vu-verify.out | 8 +- .../expected/BABEL-CASE_EXPR-vu-verify.out | 2 +- ...ASE_EXPR-before-16_5-or-15_9-vu-verify.out | 978 +++++++++++++++++- .../BABEL-CASE_EXPR-vu-verify.out | 978 +++++++++++++++++- ...ASE_EXPR-before-16_5-or-15_9-vu-verify.out | 978 +++++++++++++++++- .../BABEL-CASE_EXPR-vu-verify.out | 978 +++++++++++++++++- 7 files changed, 3911 insertions(+), 23 deletions(-) diff --git a/contrib/babelfishpg_tsql/src/pltsql_coerce.c b/contrib/babelfishpg_tsql/src/pltsql_coerce.c index 0a1cb41356..2c0fc2fc6a 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_coerce.c +++ b/contrib/babelfishpg_tsql/src/pltsql_coerce.c @@ -2114,12 +2114,12 @@ static int32 tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) { int32 max_typmods=0, - max_precision = 0, - max_scale = 0, - precision = 0, - scale = 0, - integralDigitCount = 0, - result_typmod = -1; + max_precision = 0, + max_scale = 0, + precision = 0, + scale = 0, + integralDigitCount = 0, + result_typmod = -1; ListCell *lc; common_utility_plugin *utilptr = common_utility_plugin_ptr; diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index 5664bbe40d..8c3181a4b1 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -4658,7 +4658,7 @@ END AS RESULT GO ~~START~~ numeric -123 +123.00 ~~END~~ @@ -4691,7 +4691,7 @@ END AS RESULT GO ~~START~~ numeric -123 +123.00 ~~END~~ @@ -4702,7 +4702,7 @@ END AS RESULT GO ~~START~~ numeric -123.00000000 +123.000 ~~END~~ @@ -13189,7 +13189,7 @@ SELECT * FROM BABEL_5341_V2; GO ~~START~~ numeric -6789.0000 +6789 ~~END~~ diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out index f7823448f0..5e5467f942 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out @@ -13189,7 +13189,7 @@ SELECT * FROM BABEL_5341_V2; GO ~~START~~ numeric -6789.0000 +6789 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index d311f1b907..7229a7cee0 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -4658,7 +4658,7 @@ END AS RESULT GO ~~START~~ numeric -123 +123.00 ~~END~~ @@ -4691,7 +4691,7 @@ END AS RESULT GO ~~START~~ numeric -123 +123.00 ~~END~~ @@ -4702,7 +4702,7 @@ END AS RESULT GO ~~START~~ numeric -123.00000000 +123.000 ~~END~~ @@ -13014,3 +13014,975 @@ GO ~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + +-- Testing for numeric and decimal +-- Test Case 1: Basic CASE with 6 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 0 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 2: CASE with 5 columns and ELSE +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +99 +50 +22 +44 +66 +~~END~~ + + +-- Test Case 3: CASE with 4 columns and ELSE +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + ELSE COL5 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +42 +10 +11 +33 +55 +~~END~~ + + +-- Test Case 4: CASE with 3 columns and ELSE +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + ELSE COL4 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 5: CASE with 2 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + ELSE COL3 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 6: CASE with 1 column and ELSE +SELECT CASE 2 + WHEN 1 THEN COL1 + ELSE COL2 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +54321.98 +12345.67 +22222.22 +44444.44 +66666.66 +~~END~~ + + +-- Test Case 7: CASE with all columns returning a constant value +SELECT CASE 7 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 999.99 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1000 +1000 +1000 +1000 +1000 +~~END~~ + + +-- Test Case 8: CASE with mixed constant and column values +SELECT CASE 4 + WHEN 1 THEN 100 + WHEN 2 THEN COL2 + WHEN 3 THEN 300 + WHEN 4 THEN COL4 + WHEN 5 THEN 500 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 9: CASE with views +SELECT * FROM BABEL_5341_V1; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +SELECT * FROM BABEL_5341_V2; +GO +~~START~~ +numeric +6789 +~~END~~ + + +SELECT * FROM BABEL_5341_V3; +GO +~~START~~ +numeric +1234567890123456 +~~END~~ + + +SELECT * FROM BABEL_5341_V4; +GO +~~START~~ +numeric +0.0003 +~~END~~ + + +SELECT * FROM BABEL_5341_V5; +GO +~~START~~ +numeric +678.90 +~~END~~ + + +SELECT * FROM BABEL_5341_V6; +GO +~~START~~ +numeric +1250.00 +~~END~~ + + +-- Test Case 10: Using the function +SELECT BABEL_5341_F1(100.00); +GO +~~START~~ +numeric +123.4500 +~~END~~ + + +SELECT BABEL_5341_F1(200.00); +GO +~~START~~ +numeric +6789.0000 +~~END~~ + + +SELECT BABEL_5341_F1(300.00); +GO +~~START~~ +numeric +12.3456 +~~END~~ + + +SELECT BABEL_5341_F1(400.00); +GO +~~START~~ +numeric +400.0000 +~~END~~ + + +-- Test Case 11: Basic DECIMAL and NUMERIC usage +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +1234567.89000000 +~~END~~ + + +-- Test Case 12: Different scales within the same precision +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.43 AS DECIMAL(10,2)) + WHEN 3 THEN CAST(123456.7 AS DECIMAL(10,1)) + WHEN 4 THEN CAST(1234567 AS DECIMAL(10,0)) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS RESULT +GO +~~START~~ +numeric +98765.4300 +~~END~~ + + +-- Test Case 13: Mixing DECIMAL and NUMERIC with different precisions +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(12,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(15,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +9.87654321 +~~END~~ + + +-- Test Case 14: Large precisions and scales +SELECT CASE 2 + WHEN 1 THEN CAST(12345678901234567890.1234567890 AS DECIMAL(30,10)) + WHEN 2 THEN CAST(98765432109876543210.9876543210 AS NUMERIC(30,10)) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS DECIMAL(25,10)) + WHEN 4 THEN CAST(9.8765432109876543210 AS NUMERIC(20,19)) + ELSE CAST(0 AS DECIMAL(30,10)) +END AS RESULT +GO +~~START~~ +numeric +98765432109876543210.987654321000000000 +~~END~~ + + +-- Test Case 15: Small fractional parts +SELECT CASE 3 + WHEN 1 THEN CAST(12345.000001 AS DECIMAL(12,6)) + WHEN 2 THEN CAST(98765.0000001 AS NUMERIC(14,7)) + WHEN 3 THEN CAST(1234567.0000000001 AS DECIMAL(18,10)) + WHEN 4 THEN CAST(9.000000000000001 AS NUMERIC(17,15)) + ELSE CAST(0.00000001 AS DECIMAL(10,8)) +END AS RESULT +GO +~~START~~ +numeric +1234567.000000000100000 +~~END~~ + + +-- Test Case 16: Negative numbers +SELECT CASE 2 + WHEN 1 THEN CAST(-12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(-98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(-1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(-9.87654321 AS NUMERIC(9,8)) + ELSE CAST(-0.01 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +-98765.43210000 +~~END~~ + + +-- Test Case 17: Potential overflow scenarios +SELECT CASE 3 + WHEN 1 THEN CAST(99999.9999 AS DECIMAL(9,4)) + WHEN 2 THEN CAST(999999.999 AS NUMERIC(9,3)) + WHEN 3 THEN CAST(9999999.99 AS DECIMAL(9,2)) + WHEN 4 THEN CAST(99999999.9 AS NUMERIC(9,1)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT +GO +~~START~~ +numeric +9999999.9900 +~~END~~ + + +-- Test Case 18: Mixing with other numeric types +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765 AS INT) + WHEN 3 THEN CAST(1234567.89 AS FLOAT) + WHEN 4 THEN CAST(9 AS BIGINT) + ELSE CAST(0 AS NUMERIC(5,2)) +END AS RESULT +GO +~~START~~ +float +9.0 +~~END~~ + + + +-- Test Case 19: NUMERIC, DATETIME, and SQL_VARIANT in different branches +DECLARE @var SQL_VARIANT +SET @var = CAST(12345.6789 AS NUMERIC(10,4)) +SELECT CASE + WHEN CAST('2023-05-15' AS DATETIME) > '2023-01-01' THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN @var > 10000 THEN CAST('2023-12-31' AS DATETIME) + WHEN YEAR(GETDATE()) = 2023 THEN @var + ELSE CAST(11111.1111 AS NUMERIC(10,4)) +END AS RESULT +GO +~~START~~ +sql_variant +98765.4321 +~~END~~ + + + +-- Test Case 20: NUMERIC with different precisions, DATETIME, and SQL_VARIANT +DECLARE @var SQL_VARIANT +SET @var = CAST(123456.789 AS NUMERIC(15,3)) +SELECT CASE + WHEN CAST(12345.6789 AS NUMERIC(10,4)) > 10000 THEN CAST(9876543.21 AS NUMERIC(15,2)) + WHEN CAST('2023-05-15' AS DATETIME) < GETDATE() THEN CAST(123.456789 AS NUMERIC(9,6)) + WHEN SQL_VARIANT_PROPERTY(@var, 'Scale') > 2 THEN CAST(GETDATE() AS DATETIME) + ELSE @var +END AS RESULT +GO +~~START~~ +sql_variant +9876543.21 +~~END~~ + + +-- Test Case 21: SQL_VARIANT from BIGINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9223372036854775807 AS BIGINT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 22: SQL_VARIANT from DECIMAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(123.456 AS DECIMAL(10,3)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 23: SQL_VARIANT from FLOAT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(3.14159265359 AS FLOAT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 24: SQL_VARIANT from CHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('A' AS CHAR(1)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 25: SQL_VARIANT from VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('Hello, World!' AS VARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 26: SQL_VARIANT from NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(N'こんにちは' AS NVARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 27: SQL_VARIANT from DATE +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15' AS DATE) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 28: SQL_VARIANT from TIME +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('14:30:00' AS TIME) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 29: SQL_VARIANT from DATETIME2 +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00.1234567' AS DATETIME2(7)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 30: SQL_VARIANT from DATETIMEOFFSET +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00 +01:00' AS DATETIMEOFFSET) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 31: SQL_VARIANT from BIT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1 AS BIT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 32: SQL_VARIANT from UNIQUEIDENTIFIER +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(NEWID() AS UNIQUEIDENTIFIER) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 33: SQL_VARIANT from VARBINARY +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0x1234567890 AS VARBINARY(10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 34: SQL_VARIANT from NUMERIC(10,2) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567.89 AS NUMERIC(10,2)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 35: SQL_VARIANT from NUMERIC(5,4) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.1234 AS NUMERIC(5,4)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 36: SQL_VARIANT from NUMERIC(20,10) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567890.1234567890 AS NUMERIC(20,10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 37: SQL_VARIANT from NUMERIC(38,0) (maximum precision, no decimal places) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(12345678901234567890123456789012345678 AS NUMERIC(38,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 38: SQL_VARIANT from NUMERIC(38,38) (maximum precision and scale) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.12345678901234567890123456789012345678 AS NUMERIC(38,38)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 39: SQL_VARIANT from NUMERIC(1,0) (minimum precision) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9 AS NUMERIC(1,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 40: SQL_VARIANT from negative NUMERIC +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(-9876.54321 AS NUMERIC(10,5)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 41: Numeric branch with time +select case 1 + when 1 then cast(1.23 as numeric(20,2)) + when 2 then cast(1900-01-01 as datetime) +END +go +~~START~~ +datetime +1900-01-02 05:31:12.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type date to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('12:34:56' AS TIME) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type time without time zone to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetime2 to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetimeoffset to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-02 05:31:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) + WHEN 3 THEN CAST('12:34:56' AS TIME) + WHEN 4 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) + WHEN 5 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) + WHEN 6 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-01 00:00:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(GETDATE() AS DATE) + WHEN 3 THEN CAST(GETDATE() AS TIME) + WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) + WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) + WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +2024-12-06 00:00:00.0 +~~END~~ + + +-- Test Case 42: NUMERIC and TINYINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(255 AS TINYINT) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Test Case 43: NUMERIC and REAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(3.14 AS REAL) +END AS Result +GO +~~START~~ +real +1.23 +~~END~~ + + +-- Test Case 44: NUMERIC and NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(N'A' AS NCHAR(1)) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Create UDTs +CREATE TYPE NumericType_BABEL_5341 FROM NUMERIC(20,2); +GO + +CREATE TYPE DecimalType_BABEL_5341 FROM DECIMAL(18,4); +GO + +CREATE TYPE BigNumericType_BABEL_5341 FROM NUMERIC(38,10); +GO + +CREATE TYPE SmallDecimalType_BABEL_5341 FROM DECIMAL(5,2); +GO + +-- Test Case 45: Basic CASE with all UDTs +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.99 +~~END~~ + + +-- Test Case 46: CASE with UDTs and different precisions +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS DecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567890123456.7890123456 +~~END~~ + + +-- Test Case 47: CASE with UDTs and mathematical operations +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 * 2 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 / 2 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 + 1000 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 - 50 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +49382.7161 +~~END~~ + + +-- Test Case 48: CASE with UDTs and rounding +SELECT CASE 1 + WHEN 1 THEN CAST(ROUND(12345.6789, 2) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(ROUND(98765.4321, 4) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(ROUND(1234567.8901234567890, 10) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(ROUND(99.99, 1) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345.68 +~~END~~ + + +-- Test Case 49: CASE with UDTs and type conversion +SELECT CASE 4 + WHEN 1 THEN CAST(CAST(12345.6789 AS NumericType_BABEL_5341) AS BigNumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(98765.4321 AS DecimalType_BABEL_5341) AS SmallDecimalType_BABEL_5341) + WHEN 3 THEN CAST(CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) AS NumericType_BABEL_5341) + WHEN 4 THEN CAST(CAST(99.99 AS SmallDecimalType_BABEL_5341) AS DecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.9900 +~~END~~ + + +-- Test Case 50: CASE with UDTs and potential overflow +SELECT CASE 3 + WHEN 1 THEN CAST(9999999999999999.99 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(99999999999999.9999 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(12345678901234567890.1234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(999.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345678901234567890.1234567890 +~~END~~ + + +-- Test Case 51: CASE with UDTs and aggregate functions +SELECT CASE 2 + WHEN 1 THEN CAST(AVG(CAST(COLUMN_VALUE AS NumericType_BABEL_5341)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(SUM(CAST(COLUMN_VALUE AS DecimalType_BABEL_5341)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(MAX(CAST(COLUMN_VALUE AS BigNumericType_BABEL_5341)) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(MIN(CAST(COLUMN_VALUE AS SmallDecimalType_BABEL_5341)) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) +GO +~~START~~ +numeric +600.0000 +~~END~~ + + +-- Test Case 52: UDTs with INT and BIGINT +SELECT CASE 3 + WHEN 1 THEN CAST(12345 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(9876543210 AS BigNumericType_BABEL_5341) + WHEN 3 THEN CAST(1000 AS INT) + WHEN 4 THEN CAST(9223372036854775807 AS BIGINT) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1000 +~~END~~ + + +-- Test Case 53: UDTs with FLOAT and REAL +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS DecimalType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS FLOAT) + WHEN 3 THEN CAST(1234.56 AS REAL) + WHEN 4 THEN CAST(9.87654321 AS NumericType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +float +98765.4321 +~~END~~ + + +-- Test Case 54: UDTs with MONEY and SMALLMONEY +SELECT CASE 4 + WHEN 1 THEN CAST(12345.67 AS MONEY) + WHEN 2 THEN CAST(98.76 AS SMALLMONEY) + WHEN 3 THEN CAST(1234.5678 AS DecimalType_BABEL_5341) + WHEN 4 THEN CAST(9876.54 AS NumericType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +9876.54 +~~END~~ + + +-- Test Case 55: UDTs with VARCHAR and NVARCHAR +SELECT CASE 3 + WHEN 1 THEN CAST(CAST('12345.67' AS VARCHAR(20)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(N'98765.4321' AS NVARCHAR(20)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST('1234567.8901' AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(N'99.99' AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567.8901000000 +~~END~~ + + +-- Test Case 56: UDTs with BIT and mathematical operations +SELECT CASE 3 + WHEN 1 THEN CAST(1 AS BIT) * CAST(12345.67 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(0 AS BIT) * CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1 AS BIT) + CAST(1234567.8901 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(1 AS BIT) - CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234568.8901000000 +~~END~~ + + +DROP TYPE NumericType_BABEL_5341; +GO + +DROP TYPE DecimalType_BABEL_5341; +GO + +DROP TYPE BigNumericType_BABEL_5341; +GO + +DROP TYPE SmallDecimalType_BABEL_5341; +GO diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out index f0332904d4..47262b50ce 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out @@ -4658,7 +4658,7 @@ END AS RESULT GO ~~START~~ numeric -123 +123.00 ~~END~~ @@ -4691,7 +4691,7 @@ END AS RESULT GO ~~START~~ numeric -123 +123.00 ~~END~~ @@ -4702,7 +4702,7 @@ END AS RESULT GO ~~START~~ numeric -123.00000000 +123.000 ~~END~~ @@ -13014,3 +13014,975 @@ GO ~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + +-- Testing for numeric and decimal +-- Test Case 1: Basic CASE with 6 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 0 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 2: CASE with 5 columns and ELSE +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +99 +50 +22 +44 +66 +~~END~~ + + +-- Test Case 3: CASE with 4 columns and ELSE +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + ELSE COL5 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +42 +10 +11 +33 +55 +~~END~~ + + +-- Test Case 4: CASE with 3 columns and ELSE +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + ELSE COL4 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 5: CASE with 2 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + ELSE COL3 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 6: CASE with 1 column and ELSE +SELECT CASE 2 + WHEN 1 THEN COL1 + ELSE COL2 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +54321.98 +12345.67 +22222.22 +44444.44 +66666.66 +~~END~~ + + +-- Test Case 7: CASE with all columns returning a constant value +SELECT CASE 7 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 999.99 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1000 +1000 +1000 +1000 +1000 +~~END~~ + + +-- Test Case 8: CASE with mixed constant and column values +SELECT CASE 4 + WHEN 1 THEN 100 + WHEN 2 THEN COL2 + WHEN 3 THEN 300 + WHEN 4 THEN COL4 + WHEN 5 THEN 500 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 9: CASE with views +SELECT * FROM BABEL_5341_V1; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +SELECT * FROM BABEL_5341_V2; +GO +~~START~~ +numeric +6789 +~~END~~ + + +SELECT * FROM BABEL_5341_V3; +GO +~~START~~ +numeric +1234567890123456 +~~END~~ + + +SELECT * FROM BABEL_5341_V4; +GO +~~START~~ +numeric +0.0003 +~~END~~ + + +SELECT * FROM BABEL_5341_V5; +GO +~~START~~ +numeric +678.90 +~~END~~ + + +SELECT * FROM BABEL_5341_V6; +GO +~~START~~ +numeric +1250.00 +~~END~~ + + +-- Test Case 10: Using the function +SELECT BABEL_5341_F1(100.00); +GO +~~START~~ +numeric +123.4500 +~~END~~ + + +SELECT BABEL_5341_F1(200.00); +GO +~~START~~ +numeric +6789.0000 +~~END~~ + + +SELECT BABEL_5341_F1(300.00); +GO +~~START~~ +numeric +12.3456 +~~END~~ + + +SELECT BABEL_5341_F1(400.00); +GO +~~START~~ +numeric +400.0000 +~~END~~ + + +-- Test Case 11: Basic DECIMAL and NUMERIC usage +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +1234567.89000000 +~~END~~ + + +-- Test Case 12: Different scales within the same precision +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.43 AS DECIMAL(10,2)) + WHEN 3 THEN CAST(123456.7 AS DECIMAL(10,1)) + WHEN 4 THEN CAST(1234567 AS DECIMAL(10,0)) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS RESULT +GO +~~START~~ +numeric +98765.4300 +~~END~~ + + +-- Test Case 13: Mixing DECIMAL and NUMERIC with different precisions +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(12,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(15,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +9.87654321 +~~END~~ + + +-- Test Case 14: Large precisions and scales +SELECT CASE 2 + WHEN 1 THEN CAST(12345678901234567890.1234567890 AS DECIMAL(30,10)) + WHEN 2 THEN CAST(98765432109876543210.9876543210 AS NUMERIC(30,10)) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS DECIMAL(25,10)) + WHEN 4 THEN CAST(9.8765432109876543210 AS NUMERIC(20,19)) + ELSE CAST(0 AS DECIMAL(30,10)) +END AS RESULT +GO +~~START~~ +numeric +98765432109876543210.987654321000000000 +~~END~~ + + +-- Test Case 15: Small fractional parts +SELECT CASE 3 + WHEN 1 THEN CAST(12345.000001 AS DECIMAL(12,6)) + WHEN 2 THEN CAST(98765.0000001 AS NUMERIC(14,7)) + WHEN 3 THEN CAST(1234567.0000000001 AS DECIMAL(18,10)) + WHEN 4 THEN CAST(9.000000000000001 AS NUMERIC(17,15)) + ELSE CAST(0.00000001 AS DECIMAL(10,8)) +END AS RESULT +GO +~~START~~ +numeric +1234567.000000000100000 +~~END~~ + + +-- Test Case 16: Negative numbers +SELECT CASE 2 + WHEN 1 THEN CAST(-12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(-98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(-1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(-9.87654321 AS NUMERIC(9,8)) + ELSE CAST(-0.01 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +-98765.43210000 +~~END~~ + + +-- Test Case 17: Potential overflow scenarios +SELECT CASE 3 + WHEN 1 THEN CAST(99999.9999 AS DECIMAL(9,4)) + WHEN 2 THEN CAST(999999.999 AS NUMERIC(9,3)) + WHEN 3 THEN CAST(9999999.99 AS DECIMAL(9,2)) + WHEN 4 THEN CAST(99999999.9 AS NUMERIC(9,1)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT +GO +~~START~~ +numeric +9999999.9900 +~~END~~ + + +-- Test Case 18: Mixing with other numeric types +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765 AS INT) + WHEN 3 THEN CAST(1234567.89 AS FLOAT) + WHEN 4 THEN CAST(9 AS BIGINT) + ELSE CAST(0 AS NUMERIC(5,2)) +END AS RESULT +GO +~~START~~ +float +9.0 +~~END~~ + + + +-- Test Case 19: NUMERIC, DATETIME, and SQL_VARIANT in different branches +DECLARE @var SQL_VARIANT +SET @var = CAST(12345.6789 AS NUMERIC(10,4)) +SELECT CASE + WHEN CAST('2023-05-15' AS DATETIME) > '2023-01-01' THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN @var > 10000 THEN CAST('2023-12-31' AS DATETIME) + WHEN YEAR(GETDATE()) = 2023 THEN @var + ELSE CAST(11111.1111 AS NUMERIC(10,4)) +END AS RESULT +GO +~~START~~ +sql_variant +98765.4321 +~~END~~ + + + +-- Test Case 20: NUMERIC with different precisions, DATETIME, and SQL_VARIANT +DECLARE @var SQL_VARIANT +SET @var = CAST(123456.789 AS NUMERIC(15,3)) +SELECT CASE + WHEN CAST(12345.6789 AS NUMERIC(10,4)) > 10000 THEN CAST(9876543.21 AS NUMERIC(15,2)) + WHEN CAST('2023-05-15' AS DATETIME) < GETDATE() THEN CAST(123.456789 AS NUMERIC(9,6)) + WHEN SQL_VARIANT_PROPERTY(@var, 'Scale') > 2 THEN CAST(GETDATE() AS DATETIME) + ELSE @var +END AS RESULT +GO +~~START~~ +sql_variant +9876543.21 +~~END~~ + + +-- Test Case 21: SQL_VARIANT from BIGINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9223372036854775807 AS BIGINT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 22: SQL_VARIANT from DECIMAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(123.456 AS DECIMAL(10,3)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 23: SQL_VARIANT from FLOAT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(3.14159265359 AS FLOAT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 24: SQL_VARIANT from CHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('A' AS CHAR(1)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 25: SQL_VARIANT from VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('Hello, World!' AS VARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 26: SQL_VARIANT from NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(N'こんにちは' AS NVARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 27: SQL_VARIANT from DATE +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15' AS DATE) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 28: SQL_VARIANT from TIME +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('14:30:00' AS TIME) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 29: SQL_VARIANT from DATETIME2 +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00.1234567' AS DATETIME2(7)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 30: SQL_VARIANT from DATETIMEOFFSET +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00 +01:00' AS DATETIMEOFFSET) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 31: SQL_VARIANT from BIT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1 AS BIT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 32: SQL_VARIANT from UNIQUEIDENTIFIER +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(NEWID() AS UNIQUEIDENTIFIER) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 33: SQL_VARIANT from VARBINARY +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0x1234567890 AS VARBINARY(10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 34: SQL_VARIANT from NUMERIC(10,2) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567.89 AS NUMERIC(10,2)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 35: SQL_VARIANT from NUMERIC(5,4) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.1234 AS NUMERIC(5,4)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 36: SQL_VARIANT from NUMERIC(20,10) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567890.1234567890 AS NUMERIC(20,10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 37: SQL_VARIANT from NUMERIC(38,0) (maximum precision, no decimal places) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(12345678901234567890123456789012345678 AS NUMERIC(38,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 38: SQL_VARIANT from NUMERIC(38,38) (maximum precision and scale) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.12345678901234567890123456789012345678 AS NUMERIC(38,38)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 39: SQL_VARIANT from NUMERIC(1,0) (minimum precision) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9 AS NUMERIC(1,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 40: SQL_VARIANT from negative NUMERIC +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(-9876.54321 AS NUMERIC(10,5)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 41: Numeric branch with time +select case 1 + when 1 then cast(1.23 as numeric(20,2)) + when 2 then cast(1900-01-01 as datetime) +END +go +~~START~~ +datetime +1900-01-02 05:31:12.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type date to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('12:34:56' AS TIME) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type time without time zone to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetime2 to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetimeoffset to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-02 05:31:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) + WHEN 3 THEN CAST('12:34:56' AS TIME) + WHEN 4 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) + WHEN 5 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) + WHEN 6 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-01 00:00:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(GETDATE() AS DATE) + WHEN 3 THEN CAST(GETDATE() AS TIME) + WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) + WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) + WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +2024-12-06 00:00:00.0 +~~END~~ + + +-- Test Case 42: NUMERIC and TINYINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(255 AS TINYINT) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Test Case 43: NUMERIC and REAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(3.14 AS REAL) +END AS Result +GO +~~START~~ +real +1.23 +~~END~~ + + +-- Test Case 44: NUMERIC and NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(N'A' AS NCHAR(1)) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Create UDTs +CREATE TYPE NumericType_BABEL_5341 FROM NUMERIC(20,2); +GO + +CREATE TYPE DecimalType_BABEL_5341 FROM DECIMAL(18,4); +GO + +CREATE TYPE BigNumericType_BABEL_5341 FROM NUMERIC(38,10); +GO + +CREATE TYPE SmallDecimalType_BABEL_5341 FROM DECIMAL(5,2); +GO + +-- Test Case 45: Basic CASE with all UDTs +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.99 +~~END~~ + + +-- Test Case 46: CASE with UDTs and different precisions +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS DecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567890123456.7890123456 +~~END~~ + + +-- Test Case 47: CASE with UDTs and mathematical operations +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 * 2 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 / 2 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 + 1000 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 - 50 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +49382.7161 +~~END~~ + + +-- Test Case 48: CASE with UDTs and rounding +SELECT CASE 1 + WHEN 1 THEN CAST(ROUND(12345.6789, 2) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(ROUND(98765.4321, 4) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(ROUND(1234567.8901234567890, 10) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(ROUND(99.99, 1) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345.68 +~~END~~ + + +-- Test Case 49: CASE with UDTs and type conversion +SELECT CASE 4 + WHEN 1 THEN CAST(CAST(12345.6789 AS NumericType_BABEL_5341) AS BigNumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(98765.4321 AS DecimalType_BABEL_5341) AS SmallDecimalType_BABEL_5341) + WHEN 3 THEN CAST(CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) AS NumericType_BABEL_5341) + WHEN 4 THEN CAST(CAST(99.99 AS SmallDecimalType_BABEL_5341) AS DecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.9900 +~~END~~ + + +-- Test Case 50: CASE with UDTs and potential overflow +SELECT CASE 3 + WHEN 1 THEN CAST(9999999999999999.99 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(99999999999999.9999 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(12345678901234567890.1234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(999.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345678901234567890.1234567890 +~~END~~ + + +-- Test Case 51: CASE with UDTs and aggregate functions +SELECT CASE 2 + WHEN 1 THEN CAST(AVG(CAST(COLUMN_VALUE AS NumericType_BABEL_5341)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(SUM(CAST(COLUMN_VALUE AS DecimalType_BABEL_5341)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(MAX(CAST(COLUMN_VALUE AS BigNumericType_BABEL_5341)) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(MIN(CAST(COLUMN_VALUE AS SmallDecimalType_BABEL_5341)) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) +GO +~~START~~ +numeric +600.0000 +~~END~~ + + +-- Test Case 52: UDTs with INT and BIGINT +SELECT CASE 3 + WHEN 1 THEN CAST(12345 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(9876543210 AS BigNumericType_BABEL_5341) + WHEN 3 THEN CAST(1000 AS INT) + WHEN 4 THEN CAST(9223372036854775807 AS BIGINT) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1000 +~~END~~ + + +-- Test Case 53: UDTs with FLOAT and REAL +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS DecimalType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS FLOAT) + WHEN 3 THEN CAST(1234.56 AS REAL) + WHEN 4 THEN CAST(9.87654321 AS NumericType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +float +98765.4321 +~~END~~ + + +-- Test Case 54: UDTs with MONEY and SMALLMONEY +SELECT CASE 4 + WHEN 1 THEN CAST(12345.67 AS MONEY) + WHEN 2 THEN CAST(98.76 AS SMALLMONEY) + WHEN 3 THEN CAST(1234.5678 AS DecimalType_BABEL_5341) + WHEN 4 THEN CAST(9876.54 AS NumericType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +9876.54 +~~END~~ + + +-- Test Case 55: UDTs with VARCHAR and NVARCHAR +SELECT CASE 3 + WHEN 1 THEN CAST(CAST('12345.67' AS VARCHAR(20)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(N'98765.4321' AS NVARCHAR(20)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST('1234567.8901' AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(N'99.99' AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567.8901000000 +~~END~~ + + +-- Test Case 56: UDTs with BIT and mathematical operations +SELECT CASE 3 + WHEN 1 THEN CAST(1 AS BIT) * CAST(12345.67 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(0 AS BIT) * CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1 AS BIT) + CAST(1234567.8901 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(1 AS BIT) - CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234568.8901000000 +~~END~~ + + +DROP TYPE NumericType_BABEL_5341; +GO + +DROP TYPE DecimalType_BABEL_5341; +GO + +DROP TYPE BigNumericType_BABEL_5341; +GO + +DROP TYPE SmallDecimalType_BABEL_5341; +GO diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index ad3b761a5b..492a77f4f9 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -4658,7 +4658,7 @@ END AS RESULT GO ~~START~~ numeric -123 +123.00 ~~END~~ @@ -4691,7 +4691,7 @@ END AS RESULT GO ~~START~~ numeric -123 +123.00 ~~END~~ @@ -4702,7 +4702,7 @@ END AS RESULT GO ~~START~~ numeric -123.00000000 +123.000 ~~END~~ @@ -13014,3 +13014,975 @@ GO ~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + +-- Testing for numeric and decimal +-- Test Case 1: Basic CASE with 6 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 0 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 2: CASE with 5 columns and ELSE +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +99 +50 +22 +44 +66 +~~END~~ + + +-- Test Case 3: CASE with 4 columns and ELSE +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + ELSE COL5 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +42 +10 +11 +33 +55 +~~END~~ + + +-- Test Case 4: CASE with 3 columns and ELSE +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + ELSE COL4 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 5: CASE with 2 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + ELSE COL3 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 6: CASE with 1 column and ELSE +SELECT CASE 2 + WHEN 1 THEN COL1 + ELSE COL2 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +54321.98 +12345.67 +22222.22 +44444.44 +66666.66 +~~END~~ + + +-- Test Case 7: CASE with all columns returning a constant value +SELECT CASE 7 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 999.99 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1000 +1000 +1000 +1000 +1000 +~~END~~ + + +-- Test Case 8: CASE with mixed constant and column values +SELECT CASE 4 + WHEN 1 THEN 100 + WHEN 2 THEN COL2 + WHEN 3 THEN 300 + WHEN 4 THEN COL4 + WHEN 5 THEN 500 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 9: CASE with views +SELECT * FROM BABEL_5341_V1; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +SELECT * FROM BABEL_5341_V2; +GO +~~START~~ +numeric +6789 +~~END~~ + + +SELECT * FROM BABEL_5341_V3; +GO +~~START~~ +numeric +1234567890123456 +~~END~~ + + +SELECT * FROM BABEL_5341_V4; +GO +~~START~~ +numeric +0.0003 +~~END~~ + + +SELECT * FROM BABEL_5341_V5; +GO +~~START~~ +numeric +678.90 +~~END~~ + + +SELECT * FROM BABEL_5341_V6; +GO +~~START~~ +numeric +1250.00 +~~END~~ + + +-- Test Case 10: Using the function +SELECT BABEL_5341_F1(100.00); +GO +~~START~~ +numeric +123.4500 +~~END~~ + + +SELECT BABEL_5341_F1(200.00); +GO +~~START~~ +numeric +6789.0000 +~~END~~ + + +SELECT BABEL_5341_F1(300.00); +GO +~~START~~ +numeric +12.3456 +~~END~~ + + +SELECT BABEL_5341_F1(400.00); +GO +~~START~~ +numeric +400.0000 +~~END~~ + + +-- Test Case 11: Basic DECIMAL and NUMERIC usage +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +1234567.89000000 +~~END~~ + + +-- Test Case 12: Different scales within the same precision +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.43 AS DECIMAL(10,2)) + WHEN 3 THEN CAST(123456.7 AS DECIMAL(10,1)) + WHEN 4 THEN CAST(1234567 AS DECIMAL(10,0)) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS RESULT +GO +~~START~~ +numeric +98765.4300 +~~END~~ + + +-- Test Case 13: Mixing DECIMAL and NUMERIC with different precisions +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(12,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(15,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +9.87654321 +~~END~~ + + +-- Test Case 14: Large precisions and scales +SELECT CASE 2 + WHEN 1 THEN CAST(12345678901234567890.1234567890 AS DECIMAL(30,10)) + WHEN 2 THEN CAST(98765432109876543210.9876543210 AS NUMERIC(30,10)) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS DECIMAL(25,10)) + WHEN 4 THEN CAST(9.8765432109876543210 AS NUMERIC(20,19)) + ELSE CAST(0 AS DECIMAL(30,10)) +END AS RESULT +GO +~~START~~ +numeric +98765432109876543210.987654321000000000 +~~END~~ + + +-- Test Case 15: Small fractional parts +SELECT CASE 3 + WHEN 1 THEN CAST(12345.000001 AS DECIMAL(12,6)) + WHEN 2 THEN CAST(98765.0000001 AS NUMERIC(14,7)) + WHEN 3 THEN CAST(1234567.0000000001 AS DECIMAL(18,10)) + WHEN 4 THEN CAST(9.000000000000001 AS NUMERIC(17,15)) + ELSE CAST(0.00000001 AS DECIMAL(10,8)) +END AS RESULT +GO +~~START~~ +numeric +1234567.000000000100000 +~~END~~ + + +-- Test Case 16: Negative numbers +SELECT CASE 2 + WHEN 1 THEN CAST(-12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(-98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(-1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(-9.87654321 AS NUMERIC(9,8)) + ELSE CAST(-0.01 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +-98765.43210000 +~~END~~ + + +-- Test Case 17: Potential overflow scenarios +SELECT CASE 3 + WHEN 1 THEN CAST(99999.9999 AS DECIMAL(9,4)) + WHEN 2 THEN CAST(999999.999 AS NUMERIC(9,3)) + WHEN 3 THEN CAST(9999999.99 AS DECIMAL(9,2)) + WHEN 4 THEN CAST(99999999.9 AS NUMERIC(9,1)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT +GO +~~START~~ +numeric +9999999.9900 +~~END~~ + + +-- Test Case 18: Mixing with other numeric types +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765 AS INT) + WHEN 3 THEN CAST(1234567.89 AS FLOAT) + WHEN 4 THEN CAST(9 AS BIGINT) + ELSE CAST(0 AS NUMERIC(5,2)) +END AS RESULT +GO +~~START~~ +float +9.0 +~~END~~ + + + +-- Test Case 19: NUMERIC, DATETIME, and SQL_VARIANT in different branches +DECLARE @var SQL_VARIANT +SET @var = CAST(12345.6789 AS NUMERIC(10,4)) +SELECT CASE + WHEN CAST('2023-05-15' AS DATETIME) > '2023-01-01' THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN @var > 10000 THEN CAST('2023-12-31' AS DATETIME) + WHEN YEAR(GETDATE()) = 2023 THEN @var + ELSE CAST(11111.1111 AS NUMERIC(10,4)) +END AS RESULT +GO +~~START~~ +sql_variant +98765.4321 +~~END~~ + + + +-- Test Case 20: NUMERIC with different precisions, DATETIME, and SQL_VARIANT +DECLARE @var SQL_VARIANT +SET @var = CAST(123456.789 AS NUMERIC(15,3)) +SELECT CASE + WHEN CAST(12345.6789 AS NUMERIC(10,4)) > 10000 THEN CAST(9876543.21 AS NUMERIC(15,2)) + WHEN CAST('2023-05-15' AS DATETIME) < GETDATE() THEN CAST(123.456789 AS NUMERIC(9,6)) + WHEN SQL_VARIANT_PROPERTY(@var, 'Scale') > 2 THEN CAST(GETDATE() AS DATETIME) + ELSE @var +END AS RESULT +GO +~~START~~ +sql_variant +9876543.21 +~~END~~ + + +-- Test Case 21: SQL_VARIANT from BIGINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9223372036854775807 AS BIGINT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 22: SQL_VARIANT from DECIMAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(123.456 AS DECIMAL(10,3)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 23: SQL_VARIANT from FLOAT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(3.14159265359 AS FLOAT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 24: SQL_VARIANT from CHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('A' AS CHAR(1)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 25: SQL_VARIANT from VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('Hello, World!' AS VARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 26: SQL_VARIANT from NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(N'こんにちは' AS NVARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 27: SQL_VARIANT from DATE +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15' AS DATE) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 28: SQL_VARIANT from TIME +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('14:30:00' AS TIME) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 29: SQL_VARIANT from DATETIME2 +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00.1234567' AS DATETIME2(7)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 30: SQL_VARIANT from DATETIMEOFFSET +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00 +01:00' AS DATETIMEOFFSET) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 31: SQL_VARIANT from BIT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1 AS BIT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 32: SQL_VARIANT from UNIQUEIDENTIFIER +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(NEWID() AS UNIQUEIDENTIFIER) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 33: SQL_VARIANT from VARBINARY +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0x1234567890 AS VARBINARY(10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 34: SQL_VARIANT from NUMERIC(10,2) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567.89 AS NUMERIC(10,2)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 35: SQL_VARIANT from NUMERIC(5,4) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.1234 AS NUMERIC(5,4)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 36: SQL_VARIANT from NUMERIC(20,10) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567890.1234567890 AS NUMERIC(20,10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 37: SQL_VARIANT from NUMERIC(38,0) (maximum precision, no decimal places) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(12345678901234567890123456789012345678 AS NUMERIC(38,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 38: SQL_VARIANT from NUMERIC(38,38) (maximum precision and scale) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.12345678901234567890123456789012345678 AS NUMERIC(38,38)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 39: SQL_VARIANT from NUMERIC(1,0) (minimum precision) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9 AS NUMERIC(1,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 40: SQL_VARIANT from negative NUMERIC +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(-9876.54321 AS NUMERIC(10,5)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 41: Numeric branch with time +select case 1 + when 1 then cast(1.23 as numeric(20,2)) + when 2 then cast(1900-01-01 as datetime) +END +go +~~START~~ +datetime +1900-01-02 05:31:12.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type date to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('12:34:56' AS TIME) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type time without time zone to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetime2 to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetimeoffset to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-02 05:31:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) + WHEN 3 THEN CAST('12:34:56' AS TIME) + WHEN 4 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) + WHEN 5 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) + WHEN 6 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-01 00:00:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(GETDATE() AS DATE) + WHEN 3 THEN CAST(GETDATE() AS TIME) + WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) + WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) + WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +2024-12-06 00:00:00.0 +~~END~~ + + +-- Test Case 42: NUMERIC and TINYINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(255 AS TINYINT) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Test Case 43: NUMERIC and REAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(3.14 AS REAL) +END AS Result +GO +~~START~~ +real +1.23 +~~END~~ + + +-- Test Case 44: NUMERIC and NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(N'A' AS NCHAR(1)) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Create UDTs +CREATE TYPE NumericType_BABEL_5341 FROM NUMERIC(20,2); +GO + +CREATE TYPE DecimalType_BABEL_5341 FROM DECIMAL(18,4); +GO + +CREATE TYPE BigNumericType_BABEL_5341 FROM NUMERIC(38,10); +GO + +CREATE TYPE SmallDecimalType_BABEL_5341 FROM DECIMAL(5,2); +GO + +-- Test Case 45: Basic CASE with all UDTs +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.99 +~~END~~ + + +-- Test Case 46: CASE with UDTs and different precisions +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS DecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567890123456.7890123456 +~~END~~ + + +-- Test Case 47: CASE with UDTs and mathematical operations +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 * 2 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 / 2 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 + 1000 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 - 50 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +49382.7161 +~~END~~ + + +-- Test Case 48: CASE with UDTs and rounding +SELECT CASE 1 + WHEN 1 THEN CAST(ROUND(12345.6789, 2) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(ROUND(98765.4321, 4) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(ROUND(1234567.8901234567890, 10) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(ROUND(99.99, 1) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345.68 +~~END~~ + + +-- Test Case 49: CASE with UDTs and type conversion +SELECT CASE 4 + WHEN 1 THEN CAST(CAST(12345.6789 AS NumericType_BABEL_5341) AS BigNumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(98765.4321 AS DecimalType_BABEL_5341) AS SmallDecimalType_BABEL_5341) + WHEN 3 THEN CAST(CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) AS NumericType_BABEL_5341) + WHEN 4 THEN CAST(CAST(99.99 AS SmallDecimalType_BABEL_5341) AS DecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.9900 +~~END~~ + + +-- Test Case 50: CASE with UDTs and potential overflow +SELECT CASE 3 + WHEN 1 THEN CAST(9999999999999999.99 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(99999999999999.9999 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(12345678901234567890.1234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(999.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345678901234567890.1234567890 +~~END~~ + + +-- Test Case 51: CASE with UDTs and aggregate functions +SELECT CASE 2 + WHEN 1 THEN CAST(AVG(CAST(COLUMN_VALUE AS NumericType_BABEL_5341)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(SUM(CAST(COLUMN_VALUE AS DecimalType_BABEL_5341)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(MAX(CAST(COLUMN_VALUE AS BigNumericType_BABEL_5341)) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(MIN(CAST(COLUMN_VALUE AS SmallDecimalType_BABEL_5341)) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) +GO +~~START~~ +numeric +600.0000 +~~END~~ + + +-- Test Case 52: UDTs with INT and BIGINT +SELECT CASE 3 + WHEN 1 THEN CAST(12345 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(9876543210 AS BigNumericType_BABEL_5341) + WHEN 3 THEN CAST(1000 AS INT) + WHEN 4 THEN CAST(9223372036854775807 AS BIGINT) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1000 +~~END~~ + + +-- Test Case 53: UDTs with FLOAT and REAL +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS DecimalType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS FLOAT) + WHEN 3 THEN CAST(1234.56 AS REAL) + WHEN 4 THEN CAST(9.87654321 AS NumericType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +float +98765.4321 +~~END~~ + + +-- Test Case 54: UDTs with MONEY and SMALLMONEY +SELECT CASE 4 + WHEN 1 THEN CAST(12345.67 AS MONEY) + WHEN 2 THEN CAST(98.76 AS SMALLMONEY) + WHEN 3 THEN CAST(1234.5678 AS DecimalType_BABEL_5341) + WHEN 4 THEN CAST(9876.54 AS NumericType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +9876.54 +~~END~~ + + +-- Test Case 55: UDTs with VARCHAR and NVARCHAR +SELECT CASE 3 + WHEN 1 THEN CAST(CAST('12345.67' AS VARCHAR(20)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(N'98765.4321' AS NVARCHAR(20)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST('1234567.8901' AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(N'99.99' AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567.8901000000 +~~END~~ + + +-- Test Case 56: UDTs with BIT and mathematical operations +SELECT CASE 3 + WHEN 1 THEN CAST(1 AS BIT) * CAST(12345.67 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(0 AS BIT) * CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1 AS BIT) + CAST(1234567.8901 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(1 AS BIT) - CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234568.8901000000 +~~END~~ + + +DROP TYPE NumericType_BABEL_5341; +GO + +DROP TYPE DecimalType_BABEL_5341; +GO + +DROP TYPE BigNumericType_BABEL_5341; +GO + +DROP TYPE SmallDecimalType_BABEL_5341; +GO diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out index 3e7235a458..8c161b466c 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out @@ -4658,7 +4658,7 @@ END AS RESULT GO ~~START~~ numeric -123 +123.00 ~~END~~ @@ -4691,7 +4691,7 @@ END AS RESULT GO ~~START~~ numeric -123 +123.00 ~~END~~ @@ -4702,7 +4702,7 @@ END AS RESULT GO ~~START~~ numeric -123.00000000 +123.000 ~~END~~ @@ -13014,3 +13014,975 @@ GO ~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + +-- Testing for numeric and decimal +-- Test Case 1: Basic CASE with 6 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 0 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 2: CASE with 5 columns and ELSE +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +99 +50 +22 +44 +66 +~~END~~ + + +-- Test Case 3: CASE with 4 columns and ELSE +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + ELSE COL5 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +42 +10 +11 +33 +55 +~~END~~ + + +-- Test Case 4: CASE with 3 columns and ELSE +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + ELSE COL4 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 5: CASE with 2 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + ELSE COL3 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 6: CASE with 1 column and ELSE +SELECT CASE 2 + WHEN 1 THEN COL1 + ELSE COL2 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +54321.98 +12345.67 +22222.22 +44444.44 +66666.66 +~~END~~ + + +-- Test Case 7: CASE with all columns returning a constant value +SELECT CASE 7 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 999.99 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1000 +1000 +1000 +1000 +1000 +~~END~~ + + +-- Test Case 8: CASE with mixed constant and column values +SELECT CASE 4 + WHEN 1 THEN 100 + WHEN 2 THEN COL2 + WHEN 3 THEN 300 + WHEN 4 THEN COL4 + WHEN 5 THEN 500 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 9: CASE with views +SELECT * FROM BABEL_5341_V1; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +SELECT * FROM BABEL_5341_V2; +GO +~~START~~ +numeric +6789 +~~END~~ + + +SELECT * FROM BABEL_5341_V3; +GO +~~START~~ +numeric +1234567890123456 +~~END~~ + + +SELECT * FROM BABEL_5341_V4; +GO +~~START~~ +numeric +0.0003 +~~END~~ + + +SELECT * FROM BABEL_5341_V5; +GO +~~START~~ +numeric +678.90 +~~END~~ + + +SELECT * FROM BABEL_5341_V6; +GO +~~START~~ +numeric +1250.00 +~~END~~ + + +-- Test Case 10: Using the function +SELECT BABEL_5341_F1(100.00); +GO +~~START~~ +numeric +123.4500 +~~END~~ + + +SELECT BABEL_5341_F1(200.00); +GO +~~START~~ +numeric +6789.0000 +~~END~~ + + +SELECT BABEL_5341_F1(300.00); +GO +~~START~~ +numeric +12.3456 +~~END~~ + + +SELECT BABEL_5341_F1(400.00); +GO +~~START~~ +numeric +400.0000 +~~END~~ + + +-- Test Case 11: Basic DECIMAL and NUMERIC usage +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +1234567.89000000 +~~END~~ + + +-- Test Case 12: Different scales within the same precision +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.43 AS DECIMAL(10,2)) + WHEN 3 THEN CAST(123456.7 AS DECIMAL(10,1)) + WHEN 4 THEN CAST(1234567 AS DECIMAL(10,0)) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS RESULT +GO +~~START~~ +numeric +98765.4300 +~~END~~ + + +-- Test Case 13: Mixing DECIMAL and NUMERIC with different precisions +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(12,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(15,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +9.87654321 +~~END~~ + + +-- Test Case 14: Large precisions and scales +SELECT CASE 2 + WHEN 1 THEN CAST(12345678901234567890.1234567890 AS DECIMAL(30,10)) + WHEN 2 THEN CAST(98765432109876543210.9876543210 AS NUMERIC(30,10)) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS DECIMAL(25,10)) + WHEN 4 THEN CAST(9.8765432109876543210 AS NUMERIC(20,19)) + ELSE CAST(0 AS DECIMAL(30,10)) +END AS RESULT +GO +~~START~~ +numeric +98765432109876543210.987654321000000000 +~~END~~ + + +-- Test Case 15: Small fractional parts +SELECT CASE 3 + WHEN 1 THEN CAST(12345.000001 AS DECIMAL(12,6)) + WHEN 2 THEN CAST(98765.0000001 AS NUMERIC(14,7)) + WHEN 3 THEN CAST(1234567.0000000001 AS DECIMAL(18,10)) + WHEN 4 THEN CAST(9.000000000000001 AS NUMERIC(17,15)) + ELSE CAST(0.00000001 AS DECIMAL(10,8)) +END AS RESULT +GO +~~START~~ +numeric +1234567.000000000100000 +~~END~~ + + +-- Test Case 16: Negative numbers +SELECT CASE 2 + WHEN 1 THEN CAST(-12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(-98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(-1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(-9.87654321 AS NUMERIC(9,8)) + ELSE CAST(-0.01 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +-98765.43210000 +~~END~~ + + +-- Test Case 17: Potential overflow scenarios +SELECT CASE 3 + WHEN 1 THEN CAST(99999.9999 AS DECIMAL(9,4)) + WHEN 2 THEN CAST(999999.999 AS NUMERIC(9,3)) + WHEN 3 THEN CAST(9999999.99 AS DECIMAL(9,2)) + WHEN 4 THEN CAST(99999999.9 AS NUMERIC(9,1)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT +GO +~~START~~ +numeric +9999999.9900 +~~END~~ + + +-- Test Case 18: Mixing with other numeric types +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765 AS INT) + WHEN 3 THEN CAST(1234567.89 AS FLOAT) + WHEN 4 THEN CAST(9 AS BIGINT) + ELSE CAST(0 AS NUMERIC(5,2)) +END AS RESULT +GO +~~START~~ +float +9.0 +~~END~~ + + + +-- Test Case 19: NUMERIC, DATETIME, and SQL_VARIANT in different branches +DECLARE @var SQL_VARIANT +SET @var = CAST(12345.6789 AS NUMERIC(10,4)) +SELECT CASE + WHEN CAST('2023-05-15' AS DATETIME) > '2023-01-01' THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN @var > 10000 THEN CAST('2023-12-31' AS DATETIME) + WHEN YEAR(GETDATE()) = 2023 THEN @var + ELSE CAST(11111.1111 AS NUMERIC(10,4)) +END AS RESULT +GO +~~START~~ +sql_variant +98765.4321 +~~END~~ + + + +-- Test Case 20: NUMERIC with different precisions, DATETIME, and SQL_VARIANT +DECLARE @var SQL_VARIANT +SET @var = CAST(123456.789 AS NUMERIC(15,3)) +SELECT CASE + WHEN CAST(12345.6789 AS NUMERIC(10,4)) > 10000 THEN CAST(9876543.21 AS NUMERIC(15,2)) + WHEN CAST('2023-05-15' AS DATETIME) < GETDATE() THEN CAST(123.456789 AS NUMERIC(9,6)) + WHEN SQL_VARIANT_PROPERTY(@var, 'Scale') > 2 THEN CAST(GETDATE() AS DATETIME) + ELSE @var +END AS RESULT +GO +~~START~~ +sql_variant +9876543.21 +~~END~~ + + +-- Test Case 21: SQL_VARIANT from BIGINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9223372036854775807 AS BIGINT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 22: SQL_VARIANT from DECIMAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(123.456 AS DECIMAL(10,3)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 23: SQL_VARIANT from FLOAT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(3.14159265359 AS FLOAT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 24: SQL_VARIANT from CHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('A' AS CHAR(1)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 25: SQL_VARIANT from VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('Hello, World!' AS VARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 26: SQL_VARIANT from NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(N'こんにちは' AS NVARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 27: SQL_VARIANT from DATE +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15' AS DATE) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 28: SQL_VARIANT from TIME +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('14:30:00' AS TIME) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 29: SQL_VARIANT from DATETIME2 +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00.1234567' AS DATETIME2(7)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 30: SQL_VARIANT from DATETIMEOFFSET +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00 +01:00' AS DATETIMEOFFSET) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 31: SQL_VARIANT from BIT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1 AS BIT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 32: SQL_VARIANT from UNIQUEIDENTIFIER +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(NEWID() AS UNIQUEIDENTIFIER) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 33: SQL_VARIANT from VARBINARY +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0x1234567890 AS VARBINARY(10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 34: SQL_VARIANT from NUMERIC(10,2) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567.89 AS NUMERIC(10,2)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 35: SQL_VARIANT from NUMERIC(5,4) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.1234 AS NUMERIC(5,4)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 36: SQL_VARIANT from NUMERIC(20,10) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567890.1234567890 AS NUMERIC(20,10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 37: SQL_VARIANT from NUMERIC(38,0) (maximum precision, no decimal places) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(12345678901234567890123456789012345678 AS NUMERIC(38,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 38: SQL_VARIANT from NUMERIC(38,38) (maximum precision and scale) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.12345678901234567890123456789012345678 AS NUMERIC(38,38)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 39: SQL_VARIANT from NUMERIC(1,0) (minimum precision) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9 AS NUMERIC(1,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 40: SQL_VARIANT from negative NUMERIC +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(-9876.54321 AS NUMERIC(10,5)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 41: Numeric branch with time +select case 1 + when 1 then cast(1.23 as numeric(20,2)) + when 2 then cast(1900-01-01 as datetime) +END +go +~~START~~ +datetime +1900-01-02 05:31:12.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type date to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('12:34:56' AS TIME) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type time without time zone to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetime2 to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetimeoffset to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-02 05:31:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) + WHEN 3 THEN CAST('12:34:56' AS TIME) + WHEN 4 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) + WHEN 5 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) + WHEN 6 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-01 00:00:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(GETDATE() AS DATE) + WHEN 3 THEN CAST(GETDATE() AS TIME) + WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) + WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) + WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +2024-12-06 00:00:00.0 +~~END~~ + + +-- Test Case 42: NUMERIC and TINYINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(255 AS TINYINT) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Test Case 43: NUMERIC and REAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(3.14 AS REAL) +END AS Result +GO +~~START~~ +real +1.23 +~~END~~ + + +-- Test Case 44: NUMERIC and NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(N'A' AS NCHAR(1)) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Create UDTs +CREATE TYPE NumericType_BABEL_5341 FROM NUMERIC(20,2); +GO + +CREATE TYPE DecimalType_BABEL_5341 FROM DECIMAL(18,4); +GO + +CREATE TYPE BigNumericType_BABEL_5341 FROM NUMERIC(38,10); +GO + +CREATE TYPE SmallDecimalType_BABEL_5341 FROM DECIMAL(5,2); +GO + +-- Test Case 45: Basic CASE with all UDTs +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.99 +~~END~~ + + +-- Test Case 46: CASE with UDTs and different precisions +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS DecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567890123456.7890123456 +~~END~~ + + +-- Test Case 47: CASE with UDTs and mathematical operations +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 * 2 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 / 2 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 + 1000 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 - 50 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +49382.7161 +~~END~~ + + +-- Test Case 48: CASE with UDTs and rounding +SELECT CASE 1 + WHEN 1 THEN CAST(ROUND(12345.6789, 2) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(ROUND(98765.4321, 4) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(ROUND(1234567.8901234567890, 10) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(ROUND(99.99, 1) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345.68 +~~END~~ + + +-- Test Case 49: CASE with UDTs and type conversion +SELECT CASE 4 + WHEN 1 THEN CAST(CAST(12345.6789 AS NumericType_BABEL_5341) AS BigNumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(98765.4321 AS DecimalType_BABEL_5341) AS SmallDecimalType_BABEL_5341) + WHEN 3 THEN CAST(CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) AS NumericType_BABEL_5341) + WHEN 4 THEN CAST(CAST(99.99 AS SmallDecimalType_BABEL_5341) AS DecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.9900 +~~END~~ + + +-- Test Case 50: CASE with UDTs and potential overflow +SELECT CASE 3 + WHEN 1 THEN CAST(9999999999999999.99 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(99999999999999.9999 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(12345678901234567890.1234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(999.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345678901234567890.1234567890 +~~END~~ + + +-- Test Case 51: CASE with UDTs and aggregate functions +SELECT CASE 2 + WHEN 1 THEN CAST(AVG(CAST(COLUMN_VALUE AS NumericType_BABEL_5341)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(SUM(CAST(COLUMN_VALUE AS DecimalType_BABEL_5341)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(MAX(CAST(COLUMN_VALUE AS BigNumericType_BABEL_5341)) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(MIN(CAST(COLUMN_VALUE AS SmallDecimalType_BABEL_5341)) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) +GO +~~START~~ +numeric +600.0000 +~~END~~ + + +-- Test Case 52: UDTs with INT and BIGINT +SELECT CASE 3 + WHEN 1 THEN CAST(12345 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(9876543210 AS BigNumericType_BABEL_5341) + WHEN 3 THEN CAST(1000 AS INT) + WHEN 4 THEN CAST(9223372036854775807 AS BIGINT) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1000 +~~END~~ + + +-- Test Case 53: UDTs with FLOAT and REAL +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS DecimalType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS FLOAT) + WHEN 3 THEN CAST(1234.56 AS REAL) + WHEN 4 THEN CAST(9.87654321 AS NumericType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +float +98765.4321 +~~END~~ + + +-- Test Case 54: UDTs with MONEY and SMALLMONEY +SELECT CASE 4 + WHEN 1 THEN CAST(12345.67 AS MONEY) + WHEN 2 THEN CAST(98.76 AS SMALLMONEY) + WHEN 3 THEN CAST(1234.5678 AS DecimalType_BABEL_5341) + WHEN 4 THEN CAST(9876.54 AS NumericType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +9876.54 +~~END~~ + + +-- Test Case 55: UDTs with VARCHAR and NVARCHAR +SELECT CASE 3 + WHEN 1 THEN CAST(CAST('12345.67' AS VARCHAR(20)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(N'98765.4321' AS NVARCHAR(20)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST('1234567.8901' AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(N'99.99' AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567.8901000000 +~~END~~ + + +-- Test Case 56: UDTs with BIT and mathematical operations +SELECT CASE 3 + WHEN 1 THEN CAST(1 AS BIT) * CAST(12345.67 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(0 AS BIT) * CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1 AS BIT) + CAST(1234567.8901 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(1 AS BIT) - CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234568.8901000000 +~~END~~ + + +DROP TYPE NumericType_BABEL_5341; +GO + +DROP TYPE DecimalType_BABEL_5341; +GO + +DROP TYPE BigNumericType_BABEL_5341; +GO + +DROP TYPE SmallDecimalType_BABEL_5341; +GO From 177a8c5db920fde78ac338c07e5dde15cae3157b Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 11 Dec 2024 11:34:01 +0000 Subject: [PATCH 04/21] babel-5454 initial commit to get the tle from parent rather than SubqueryScan Signed-off-by: Tanya Gupta --- .../src/backend/tds/tdsresponse.c | 19 +- contrib/babelfishpg_tsql/src/pltsql_coerce.c | 193 ++++++++++-------- 2 files changed, 120 insertions(+), 92 deletions(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index a1ab6b92d3..148cb20c39 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -439,16 +439,17 @@ resolve_numeric_typmod_from_append_or_mergeappend(Plan *plan, AttrNumber attno) foreach(lc, planlist) { TargetEntry *tle; - Plan *outerplan = (Plan *) lfirst(lc); + Plan *outerplan = (Plan *) lfirst(lc); // this is first part of union , in nect loop second part of union. here SUBQUERYSCAN correct order of elements and subplan that has left tree and right tree and hashcluase (join on condition). second time maybe its not SubqueryScan and thats why we dont enter that inside ??? -- second time only SEQSCAN tahts why - /* if outerplan is SubqueryScan then use actual subplan */ + tle = get_tle_by_resno(outerplan->targetlist, attno); // here? + + /* if outerplan is SubqueryScan then use actual subplan */// here if we sty out then we are picking correct and its vatatno is 1 which is correct column actually inside the subquery if (IsA(outerplan, SubqueryScan)) - outerplan = ((SubqueryScan *)outerplan)->subplan; + outerplan = ((SubqueryScan *)outerplan)->subplan; // this is inner query. first part of union. - tle = get_tle_by_resno(outerplan->targetlist, attno); if (IsA(tle->expr, Var)) { - Var *var = (Var *)tle->expr; + Var *var = (Var *)tle->expr; if (var->varno == OUTER_VAR) { typmod = resolve_numeric_typmod_outer_var(outerplan, var->varattno); @@ -464,7 +465,7 @@ resolve_numeric_typmod_from_append_or_mergeappend(Plan *plan, AttrNumber attno) } if (typmod == -1) continue; - scale = (typmod - VARHDRSZ) & 0xffff; + scale = (typmod - VARHDRSZ) & 0xffff; // scale 2 precision = ((typmod - VARHDRSZ) >> 16) & 0xffff; integralDigitCount = Max(precision - scale, max_precision - max_scale); max_scale = Max(max_scale, scale); @@ -511,7 +512,7 @@ resolve_numeric_typmod_outer_var(Plan *plan, AttrNumber attno) Var *var = (Var *)tle->expr; if (var->varno == OUTER_VAR) { - return resolve_numeric_typmod_outer_var(outerplan, var->varattno); + return resolve_numeric_typmod_outer_var(outerplan, var->varattno); // left tree has appoend thats why in nect call we see append } } return resolve_numeric_typmod_from_exp(outerplan, (Node *)tle->expr); @@ -612,8 +613,8 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) { arg1 = linitial(op->args); arg2 = lsecond(op->args); - typmod1 = resolve_numeric_typmod_from_exp(plan, arg1); - typmod2 = resolve_numeric_typmod_from_exp(plan, arg2); + typmod1 = resolve_numeric_typmod_from_exp(plan, arg1); // 3,2 + typmod2 = resolve_numeric_typmod_from_exp(plan, arg2); // send varattnosyn from here ? // 9,8 scale1 = (typmod1 - VARHDRSZ) & 0xffff; precision1 = ((typmod1 - VARHDRSZ) >> 16) & 0xffff; scale2 = (typmod2 - VARHDRSZ) & 0xffff; diff --git a/contrib/babelfishpg_tsql/src/pltsql_coerce.c b/contrib/babelfishpg_tsql/src/pltsql_coerce.c index b245878aaf..bfb2e3c053 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_coerce.c +++ b/contrib/babelfishpg_tsql/src/pltsql_coerce.c @@ -2112,91 +2112,118 @@ select_common_type_for_coalesce_function(ParseState *pstate, List *exprs) static int32 tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) { - int32 max_typmods=0; - ListCell *lc; - common_utility_plugin *utilptr = common_utility_plugin_ptr; - - if (sql_dialect != SQL_DIALECT_TSQL) - return -1; - - if (!is_tsql_char_type_with_len(common_type, false) && - !utilptr->is_tsql_binary_datatype(common_type) && - !utilptr->is_tsql_sys_binary_datatype(common_type) && - !utilptr->is_tsql_varbinary_datatype(common_type) && - !utilptr->is_tsql_sys_varbinary_datatype(common_type)) - return -1; - - /* If resulting type is a length, need to be max of length types */ - foreach(lc, exprs) - { - Node *expr = (Node*) lfirst(lc); - int32 typmod = exprTypmod(expr); - Oid type = exprType(expr); - Oid immediate_base_type = get_immediate_base_type_of_UDT_internal(type); - - /* - * Handling for UDT, If immediate_base_type is Valid Oid that mean we need to handle typmod for UDT, - * By calculating typmod of its base type using getBaseTypeAndTypmod. - * Other wise if immediate_base_type is not Valid Oid We don't need any handling for UDT. - */ - if (OidIsValid(immediate_base_type)) - { - /* Finding the typmod of base type of UDT using getBaseTypeAndTypmod() */ - int32 base_typmod = -1; - Oid base_type = getBaseTypeAndTypmod(type, &base_typmod); - - /* - * This conditon is for the datatype with MAX typmod. - * -1 will only be returned if common_type is a datatype - * that supports MAX typmod. If common type is nchar(maxtypmod = 4000) - * or bpchar(maxtypmod = 8000) return the MAX typmod for them. - */ - if (base_typmod == -1 && - is_tsql_datatype_with_max_scale_expr_allowed(base_type)) - { - if ((*common_utility_plugin_ptr->is_tsql_bpchar_datatype)(common_type)) - return BPCHAR_MAX_TYPMOD + VARHDRSZ; - else if ((*common_utility_plugin_ptr->is_tsql_nchar_datatype)(common_type)) - return NCHAR_MAX_TYPMOD + VARHDRSZ; - else if (is_tsql_datatype_with_max_scale_expr_allowed(common_type)) - return -1; - } - - typmod = base_typmod; - } - - /* - * Handling for sysname, In CASE expression if one of the branch is - * of type sysname then set typmod as SYSNAME_TYPMOD (i.e. 128). - */ - if ((*common_utility_plugin_ptr->is_tsql_sysname_datatype) (type)) - typmod = SYSNAME_TYPMOD + VARHDRSZ; - - if (is_tsql_str_const(expr)) - typmod = strlen(DatumGetCString( ((Const*)expr)->constvalue )) + VARHDRSZ; - - /* This conditon is for the datatype with MAX typmod. - * -1 will only be returned if common_type is a datatype - * that supports MAX typmod.If common type is nchar(maxtypmod = 4000) - * or bpchar(maxtypmod = 8000) return the MAX typmod for them. - */ - if (expr_is_var_max(expr)) - { - if ((*common_utility_plugin_ptr->is_tsql_bpchar_datatype)(common_type)) - return BPCHAR_MAX_TYPMOD + VARHDRSZ; - else if ((*common_utility_plugin_ptr->is_tsql_nchar_datatype)(common_type)) - return NCHAR_MAX_TYPMOD + VARHDRSZ; - else if (is_tsql_datatype_with_max_scale_expr_allowed(common_type)) - return -1; - } + int32 max_typmods=0; + int16 max_scale=0; + int16 max_precision_scale_diff=0; + ListCell *lc; + common_utility_plugin *utilptr = common_utility_plugin_ptr; + + if (sql_dialect != SQL_DIALECT_TSQL) + return -1; + + if (!is_tsql_char_type_with_len(common_type, false) && + !utilptr->is_tsql_binary_datatype(common_type) && + !utilptr->is_tsql_sys_binary_datatype(common_type) && + !utilptr->is_tsql_varbinary_datatype(common_type) && + !utilptr->is_tsql_sys_varbinary_datatype(common_type) && + !utilptr->is_tsql_decimal_datatype(common_type) && + !((common_type == NUMERICOID))) + return -1; + + /* If resulting type is a length, need to be max of length types */ + foreach(lc, exprs) + { + Node *expr = (Node*) lfirst(lc); + int32 typmod = exprTypmod(expr); + Oid type = exprType(expr); + Oid immediate_base_type = get_immediate_base_type_of_UDT_internal(type); + int16 scale = 0; + int16 precision = 0; + int16 precision_scale_diff; + + if (common_type == NUMERICOID || getBaseType(common_type) == NUMERICOID) + { + if (typmod == -1) + continue; + + scale = (typmod - VARHDRSZ) & 0xffff; + precision = ((typmod - VARHDRSZ) >> 16) & 0xffff; + precision_scale_diff = precision - scale; + max_scale = Max(scale, max_scale); + max_precision_scale_diff= Max(max_precision_scale_diff, precision_scale_diff); + } + else + { + /* + * Handling for UDT, If immediate_base_type is Valid Oid that mean we need to handle typmod for UDT, + * By calculating typmod of its base type using getBaseTypeAndTypmod. + * Other wise if immediate_base_type is not Valid Oid We don't need any handling for UDT. + */ + if (OidIsValid(immediate_base_type)) + { + /* Finding the typmod of base type of UDT using getBaseTypeAndTypmod() */ + int32 base_typmod = -1; + Oid base_type = getBaseTypeAndTypmod(type, &base_typmod); + + /* + * This conditon is for the datatype with MAX typmod. + * -1 will only be returned if common_type is a datatype + * that supports MAX typmod. If common type is nchar(maxtypmod = 4000) + * or bpchar(maxtypmod = 8000) return the MAX typmod for them. + */ + if (base_typmod == -1 && + is_tsql_datatype_with_max_scale_expr_allowed(base_type)) + { + if ((*common_utility_plugin_ptr->is_tsql_bpchar_datatype)(common_type)) + return BPCHAR_MAX_TYPMOD + VARHDRSZ; + else if ((*common_utility_plugin_ptr->is_tsql_nchar_datatype)(common_type)) + return NCHAR_MAX_TYPMOD + VARHDRSZ; + else if (is_tsql_datatype_with_max_scale_expr_allowed(common_type)) + return -1; + } + + typmod = base_typmod; + } + + /* + * Handling for sysname, In CASE expression if one of the branch is + * of type sysname then set typmod as SYSNAME_TYPMOD (i.e. 128). + */ + if ((*common_utility_plugin_ptr->is_tsql_sysname_datatype) (type)) + typmod = SYSNAME_TYPMOD + VARHDRSZ; + + if (is_tsql_str_const(expr)) + typmod = strlen(DatumGetCString( ((Const*)expr)->constvalue )) + VARHDRSZ; + + /* This conditon is for the datatype with MAX typmod. + * -1 will only be returned if common_type is a datatype + * that supports MAX typmod.If common type is nchar(maxtypmod = 4000) + * or bpchar(maxtypmod = 8000) return the MAX typmod for them. + */ + if (expr_is_var_max(expr)) + { + if ((*common_utility_plugin_ptr->is_tsql_bpchar_datatype)(common_type)) + return BPCHAR_MAX_TYPMOD + VARHDRSZ; + else if ((*common_utility_plugin_ptr->is_tsql_nchar_datatype)(common_type)) + return NCHAR_MAX_TYPMOD + VARHDRSZ; + else if (is_tsql_datatype_with_max_scale_expr_allowed(common_type)) + return -1; + } + + if (lc == list_head(exprs)) + max_typmods = typmod; + else + max_typmods = Max(max_typmods, typmod); + } + + } - if (lc == list_head(exprs)) - max_typmods = typmod; - else - max_typmods = Max(max_typmods, typmod); - } + if (common_type == NUMERICOID || getBaseType(common_type) == NUMERICOID) + return (((max_scale + max_precision_scale_diff) << 16) | max_scale) + VARHDRSZ; + + return max_typmods; - return max_typmods; + } /* From 966dc79b7a0d680acdb4ce90c0fe299e3ff240d4 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 11 Dec 2024 12:05:43 +0000 Subject: [PATCH 05/21] another approach Signed-off-by: Tanya Gupta --- contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index 148cb20c39..0b3904ab0c 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -444,8 +444,8 @@ resolve_numeric_typmod_from_append_or_mergeappend(Plan *plan, AttrNumber attno) tle = get_tle_by_resno(outerplan->targetlist, attno); // here? /* if outerplan is SubqueryScan then use actual subplan */// here if we sty out then we are picking correct and its vatatno is 1 which is correct column actually inside the subquery - if (IsA(outerplan, SubqueryScan)) - outerplan = ((SubqueryScan *)outerplan)->subplan; // this is inner query. first part of union. + // if (IsA(outerplan, SubqueryScan)) + // outerplan = ((SubqueryScan *)outerplan)->subplan; // this is inner query. first part of union. if (IsA(tle->expr, Var)) { From 559cf1f19802770002a25afc39c34ceb6dc2bb6b Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 11 Dec 2024 12:19:01 +0000 Subject: [PATCH 06/21] testing with only common typmod changes Signed-off-by: Tanya Gupta --- contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index 0b3904ab0c..c3d21e43ca 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -441,11 +441,11 @@ resolve_numeric_typmod_from_append_or_mergeappend(Plan *plan, AttrNumber attno) TargetEntry *tle; Plan *outerplan = (Plan *) lfirst(lc); // this is first part of union , in nect loop second part of union. here SUBQUERYSCAN correct order of elements and subplan that has left tree and right tree and hashcluase (join on condition). second time maybe its not SubqueryScan and thats why we dont enter that inside ??? -- second time only SEQSCAN tahts why - tle = get_tle_by_resno(outerplan->targetlist, attno); // here? - /* if outerplan is SubqueryScan then use actual subplan */// here if we sty out then we are picking correct and its vatatno is 1 which is correct column actually inside the subquery - // if (IsA(outerplan, SubqueryScan)) - // outerplan = ((SubqueryScan *)outerplan)->subplan; // this is inner query. first part of union. + if (IsA(outerplan, SubqueryScan)) + outerplan = ((SubqueryScan *)outerplan)->subplan; // this is inner query. first part of union. + + tle = get_tle_by_resno(outerplan->targetlist, attno); // here? if (IsA(tle->expr, Var)) { From 78183069ac4e1a9d3c94d8335eb45c0ea4b7a5e8 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 11 Dec 2024 13:27:48 +0000 Subject: [PATCH 07/21] indentation Signed-off-by: Tanya Gupta --- contrib/babelfishpg_tsql/src/pltsql_coerce.c | 34 ++++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/contrib/babelfishpg_tsql/src/pltsql_coerce.c b/contrib/babelfishpg_tsql/src/pltsql_coerce.c index 1056887962..27b60ced11 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_coerce.c +++ b/contrib/babelfishpg_tsql/src/pltsql_coerce.c @@ -2113,27 +2113,27 @@ select_common_type_for_coalesce_function(ParseState *pstate, List *exprs) static int32 tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) { - int32 max_typmods=0, - max_precision = 0, - max_scale = 0, - precision = 0, - scale = 0, - integralDigitCount = 0, - result_typmod = -1; - ListCell *lc; - common_utility_plugin *utilptr = common_utility_plugin_ptr; + int32 max_typmods=0, + max_precision = 0, + max_scale = 0, + precision = 0, + scale = 0, + integralDigitCount = 0, + result_typmod = -1; + ListCell *lc; + common_utility_plugin *utilptr = common_utility_plugin_ptr; if (sql_dialect != SQL_DIALECT_TSQL) return -1; - if (!is_tsql_char_type_with_len(common_type, false) && - !utilptr->is_tsql_binary_datatype(common_type) && - !utilptr->is_tsql_sys_binary_datatype(common_type) && - !utilptr->is_tsql_varbinary_datatype(common_type) && - !utilptr->is_tsql_sys_varbinary_datatype(common_type) && - !utilptr->is_tsql_decimal_datatype(common_type) && - !((common_type == NUMERICOID))) - return -1; + if (!is_tsql_char_type_with_len(common_type, false) && + !utilptr->is_tsql_binary_datatype(common_type) && + !utilptr->is_tsql_sys_binary_datatype(common_type) && + !utilptr->is_tsql_varbinary_datatype(common_type) && + !utilptr->is_tsql_sys_varbinary_datatype(common_type) && + !utilptr->is_tsql_decimal_datatype(common_type) && + !((common_type == NUMERICOID))) + return -1; /* If resulting type is a length, need to be max of length types, * If the type is numeric or decimal then we calculate scale as From 0d60ce13c0fe579f2d6d768f0e9ca5bdc92fbc2c Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 11 Dec 2024 13:32:08 +0000 Subject: [PATCH 08/21] babel-5454 Signed-off-by: Tanya Gupta --- .../src/backend/tds/tdsresponse.c | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index c3d21e43ca..4f9d3cb444 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -442,8 +442,8 @@ resolve_numeric_typmod_from_append_or_mergeappend(Plan *plan, AttrNumber attno) Plan *outerplan = (Plan *) lfirst(lc); // this is first part of union , in nect loop second part of union. here SUBQUERYSCAN correct order of elements and subplan that has left tree and right tree and hashcluase (join on condition). second time maybe its not SubqueryScan and thats why we dont enter that inside ??? -- second time only SEQSCAN tahts why /* if outerplan is SubqueryScan then use actual subplan */// here if we sty out then we are picking correct and its vatatno is 1 which is correct column actually inside the subquery - if (IsA(outerplan, SubqueryScan)) - outerplan = ((SubqueryScan *)outerplan)->subplan; // this is inner query. first part of union. + // if (IsA(outerplan, SubqueryScan)) + // outerplan = ((SubqueryScan *)outerplan)->subplan; // this is inner query. first part of union. tle = get_tle_by_resno(outerplan->targetlist, attno); // here? @@ -746,17 +746,25 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) precision = TDS_MAX_NUM_PRECISION; scale = 6; } - else if (precision - scale <= TDS_MAX_NUM_PRECISION) + // else if (precision - scale <= TDS_MAX_NUM_PRECISION) + // { + // /* + // * scale adjustment by delta is only applicable for + // * division and (multiplcation having no aggregate + // * operand) + // */ + // int delta = precision - TDS_MAX_NUM_PRECISION; + + // precision = TDS_MAX_NUM_PRECISION; + // scale = Max(scale - delta, 0); + // } + else if (precision - scale > 32 && scale < 6) { - /* - * scale adjustment by delta is only applicable for - * division and (multiplcation having no aggregate - * operand) - */ - int delta = precision - TDS_MAX_NUM_PRECISION; - precision = TDS_MAX_NUM_PRECISION; - scale = Max(scale - delta, 0); + } + else if (precision - scale < 32) + { + scale = Min(scale, 38 - (precision-scale)); } /* From fb921cf2bf16df4021858c1c1b56ad08c9b41c15 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 18 Dec 2024 09:29:27 +0000 Subject: [PATCH 09/21] Testing the changes along with tsql changes --- .../babelfishpg_tds/src/backend/tds/tds_srv.c | 1 + .../src/backend/tds/tdsresponse.c | 70 ++++-- .../src/include/tds_response.h | 1 + contrib/babelfishpg_tsql/src/pltsql.h | 1 + contrib/babelfishpg_tsql/src/pltsql_coerce.c | 54 ++-- test/JDBC/expected/BABEL-4424.out | 2 +- test/JDBC/expected/babel_numeric.out | 16 +- test/JDBC/input/babel-5454.sql | 231 ++++++++++++++++++ test/dotnet/ExpectedOutput/TestNumeric.out | 4 +- 9 files changed, 327 insertions(+), 53 deletions(-) create mode 100644 test/JDBC/input/babel-5454.sql diff --git a/contrib/babelfishpg_tds/src/backend/tds/tds_srv.c b/contrib/babelfishpg_tds/src/backend/tds/tds_srv.c index d11c249676..5bd87ad4b7 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tds_srv.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tds_srv.c @@ -205,6 +205,7 @@ pe_tds_init(void) pltsql_plugin_handler_ptr->get_datum_from_date_time_struct = &TdsDateTimeTypeToDatum; pltsql_plugin_handler_ptr->set_reset_tds_connection_flag = &SetResetTDSConnectionFlag; pltsql_plugin_handler_ptr->get_reset_tds_connection_flag = &GetResetTDSConnectionFlag; + pltsql_plugin_handler_ptr->get_numeric_typmod_from_exp = &resolve_numeric_typmod_from_exp; invalidate_stat_table_hook = invalidate_stat_table; guc_newval_hook = TdsSetGucStatVariable; diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index 4f9d3cb444..07070addbe 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -138,7 +138,6 @@ static void FillTabNameWithoutNumParts(StringInfo buf, uint8 numParts, TdsRelati static void SetTdsEstateErrorData(void); static void ResetTdsEstateErrorData(void); static void SetAttributesForColmetada(TdsColumnMetaData *col); -static int32 resolve_numeric_typmod_from_exp(Plan *plan, Node *expr); static int32 resolve_numeric_typmod_outer_var(Plan *plan, AttrNumber attno); static bool is_this_a_vector_datatype(Oid oid); @@ -446,7 +445,6 @@ resolve_numeric_typmod_from_append_or_mergeappend(Plan *plan, AttrNumber attno) // outerplan = ((SubqueryScan *)outerplan)->subplan; // this is inner query. first part of union. tle = get_tle_by_resno(outerplan->targetlist, attno); // here? - if (IsA(tle->expr, Var)) { Var *var = (Var *)tle->expr; @@ -537,7 +535,7 @@ is_numeric_datatype(Oid typid) } /* look for a typmod to return from a numeric expression */ -static int32 +int32 resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) { if (expr == NULL) @@ -578,7 +576,7 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) Var *var = (Var *) expr; /* If this var referes to tuple returned by its outer plan then find the original tle from it */ - if (var->varno == OUTER_VAR) + if (plan && var->varno == OUTER_VAR) { Assert(plan); return (resolve_numeric_typmod_outer_var(plan, var->varattno)); @@ -746,26 +744,26 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) precision = TDS_MAX_NUM_PRECISION; scale = 6; } - // else if (precision - scale <= TDS_MAX_NUM_PRECISION) - // { - // /* - // * scale adjustment by delta is only applicable for - // * division and (multiplcation having no aggregate - // * operand) - // */ - // int delta = precision - TDS_MAX_NUM_PRECISION; - - // precision = TDS_MAX_NUM_PRECISION; - // scale = Max(scale - delta, 0); - // } - else if (precision - scale > 32 && scale < 6) + else if (precision - scale <= TDS_MAX_NUM_PRECISION) { + /* + * scale adjustment by delta is only applicable for + * division and (multiplcation having no aggregate + * operand) + */ + int delta = precision - TDS_MAX_NUM_PRECISION; + precision = TDS_MAX_NUM_PRECISION; + scale = Max(scale - delta, 0); } - else if (precision - scale < 32) - { - scale = Min(scale, 38 - (precision-scale)); - } + // else if (precision - scale > 32 && scale < 6) + // { + // precision = TDS_MAX_NUM_PRECISION; + // } + // else if (precision - scale < 32) + // { + // scale = Min(scale, 38 - (precision-scale)); + // } /* * Control reaching here for only arithmetic overflow @@ -966,6 +964,36 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) else return resolve_numeric_typmod_from_exp(plan, (Node *) rlt->arg); } + case T_CoerceToDomain: + { + CoerceToDomain *rlt = (CoerceToDomain *) expr; + + if (rlt->resulttypmod != -1) + return rlt->resulttypmod; + else + return resolve_numeric_typmod_from_exp(plan, (Node *) rlt->arg); + } + case T_SubLink: + { + const SubLink *sublink = (const SubLink *) expr; + + if (sublink->subLinkType == EXPR_SUBLINK || + sublink->subLinkType == ARRAY_SUBLINK) + { + /* get the typmod of the subselect's first target column */ + Query *qtree = (Query *) sublink->subselect; + TargetEntry *tent; + + if (!qtree || !IsA(qtree, Query)) + elog(ERROR, "cannot get type for untransformed sublink"); + tent = linitial_node(TargetEntry, qtree->targetList); + Assert(!tent->resjunk); + return resolve_numeric_typmod_from_exp(plan, (Node *) tent->expr); + /* note we don't need to care if it's an array */ + } + /* otherwise, result is RECORD or BOOLEAN, typmod is -1 */ + return -1; + } /* TODO handle more Expr types if needed */ default: return -1; diff --git a/contrib/babelfishpg_tds/src/include/tds_response.h b/contrib/babelfishpg_tds/src/include/tds_response.h index 698b52fa20..876e84b4ad 100644 --- a/contrib/babelfishpg_tds/src/include/tds_response.h +++ b/contrib/babelfishpg_tds/src/include/tds_response.h @@ -98,5 +98,6 @@ extern void TDSStatementExceptionCallback(PLtsql_execstate *estate, PLtsql_stmt bool terminate_batch); extern void SendColumnMetadata(TupleDesc typeinfo, List *targetlist, int16 *formats); extern bool GetTdsEstateErrorData(int *number, int *severity, int *state); +extern int32 resolve_numeric_typmod_from_exp(Plan *plan, Node *expr); #endif /* TDS_H */ diff --git a/contrib/babelfishpg_tsql/src/pltsql.h b/contrib/babelfishpg_tsql/src/pltsql.h index d27a24c945..f493ed9096 100644 --- a/contrib/babelfishpg_tsql/src/pltsql.h +++ b/contrib/babelfishpg_tsql/src/pltsql.h @@ -1800,6 +1800,7 @@ typedef struct PLtsql_protocol_plugin void (*set_reset_tds_connection_flag) (); bool (*get_reset_tds_connection_flag) (); + int32 (*get_numeric_typmod_from_exp) (Plan *plan, Node *expr); /* Session level GUCs */ bool quoted_identifier; diff --git a/contrib/babelfishpg_tsql/src/pltsql_coerce.c b/contrib/babelfishpg_tsql/src/pltsql_coerce.c index 27b60ced11..13b131c524 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_coerce.c +++ b/contrib/babelfishpg_tsql/src/pltsql_coerce.c @@ -2113,27 +2113,27 @@ select_common_type_for_coalesce_function(ParseState *pstate, List *exprs) static int32 tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) { - int32 max_typmods=0, - max_precision = 0, - max_scale = 0, - precision = 0, - scale = 0, - integralDigitCount = 0, - result_typmod = -1; - ListCell *lc; - common_utility_plugin *utilptr = common_utility_plugin_ptr; - - if (sql_dialect != SQL_DIALECT_TSQL) - return -1; - - if (!is_tsql_char_type_with_len(common_type, false) && - !utilptr->is_tsql_binary_datatype(common_type) && - !utilptr->is_tsql_sys_binary_datatype(common_type) && - !utilptr->is_tsql_varbinary_datatype(common_type) && - !utilptr->is_tsql_sys_varbinary_datatype(common_type) && - !utilptr->is_tsql_decimal_datatype(common_type) && - !((common_type == NUMERICOID))) - return -1; + int32 max_typmods=0, + max_precision = 0, + max_scale = 0, + precision = 0, + scale = 0, + integralDigitCount = 0, + result_typmod = -1; + ListCell *lc; + common_utility_plugin *utilptr = common_utility_plugin_ptr; + + if (sql_dialect != SQL_DIALECT_TSQL) + return -1; + + if (!is_tsql_char_type_with_len(common_type, false) && + !utilptr->is_tsql_binary_datatype(common_type) && + !utilptr->is_tsql_sys_binary_datatype(common_type) && + !utilptr->is_tsql_varbinary_datatype(common_type) && + !utilptr->is_tsql_sys_varbinary_datatype(common_type) && + !utilptr->is_tsql_decimal_datatype(common_type) && + !((common_type == NUMERICOID))) + return -1; /* If resulting type is a length, need to be max of length types, * If the type is numeric or decimal then we calculate scale as @@ -2151,6 +2151,18 @@ tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) if (common_type == NUMERICOID || getBaseType(common_type) == NUMERICOID) { + /* If Udt then calculate typmod.*/ + if (OidIsValid(immediate_base_type)) + { + type = getBaseTypeAndTypmod(type, &typmod); + } + + if (typmod == -1 && (*pltsql_protocol_plugin_ptr)) + { + Plan* temp = NULL; + typmod = (*pltsql_protocol_plugin_ptr)->get_numeric_typmod_from_exp(temp, expr); + } + if(typmod == -1) continue; diff --git a/test/JDBC/expected/BABEL-4424.out b/test/JDBC/expected/BABEL-4424.out index ce1388f540..3094cb026c 100644 --- a/test/JDBC/expected/BABEL-4424.out +++ b/test/JDBC/expected/BABEL-4424.out @@ -305,7 +305,7 @@ go ~~START~~ numeric 11 -99 +100 2222222222222222222222222222222222222 19999999999999999999999999999999999998 ~~END~~ diff --git a/test/JDBC/expected/babel_numeric.out b/test/JDBC/expected/babel_numeric.out index 8d3bb92a09..6ac12a90e1 100644 --- a/test/JDBC/expected/babel_numeric.out +++ b/test/JDBC/expected/babel_numeric.out @@ -255,10 +255,10 @@ go numeric -1.23000000 -1.23000000 -99999.99000000 -9999999999999999.99000000 +1.23 +1.23 +99999.99 +9999999999999999.99 ~~END~~ @@ -403,10 +403,10 @@ go numeric -1.23000000 -1.23000000 -99999.99000000 -9999999999999999.99000000 +1.23 +1.23 +99999.99 +9999999999999999.99 ~~END~~ diff --git a/test/JDBC/input/babel-5454.sql b/test/JDBC/input/babel-5454.sql new file mode 100644 index 0000000000..81ed919f2e --- /dev/null +++ b/test/JDBC/input/babel-5454.sql @@ -0,0 +1,231 @@ +-- Create simplified tables +CREATE TABLE Currency (Code nvarchar(3), Name nvarchar(2), Num decimal(2,1)); +CREATE TABLE Exchange (Code nvarchar(3), Rate decimal(5,2), Value decimal(9,8)); +GO + +-- Insert minimal test data +INSERT INTO Currency VALUES ('USD', 'US', 2.1), ('EUR', 'EU', 1.1); +INSERT INTO Exchange VALUES ('USD', 1.00, 5.12345678), ('EUR', 0.12, 1.12345678); +GO + +-- The query that demonstrates the issue, works without my chnage +SELECT e.Name AS description, e.Rate + e.Value AS sum_num +FROM +( + SELECT Currency.Code, Currency.Name, Exchange.Rate, Exchange.Value + FROM Currency + JOIN Exchange ON Currency.Code = Exchange.Code + UNION ALL + SELECT Code, Name, 1 AS Rate, Num AS Value + FROM Currency +) AS e; +GO + + +CREATE TABLE Currency2(CurrencyCode nvarchar(3) NOT NULL, CurrencyName nvarchar(2) NULL, curr_num decimal (2,1)); +GO + +CREATE TABLE ExchangeRate2(ToCurrencyCode nvarchar(3) NOT NULL, ExchangeRate decimal(5, 2) NOT NULL, Hello decimal(9,8)); +GO + +INSERT INTO Currency2 (CurrencyCode, CurrencyName,curr_num) VALUES ('USD', 'US',2.1), ('EUR', 'Eu',1.1), ('GBP', 'Br',3.1), ('JPY', 'Ja',4.1), ('CAD', 'Ca',5.1); +GO + +INSERT INTO ExchangeRate2 (ToCurrencyCode, ExchangeRate, Hello) VALUES ('EUR', 0.12, 1.12345678), ('GBP', 23.87, 2.12345678), ('JPY', 110.50, 3.12345678), ('CAD', 1.25, 4.12345678), ('USD', 1.00 , 5.12345678); +GO + +-- should notb work withoit my changes +-- SELECT cr1 description, ex + Hello sum_num FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a; +-- GO + +-- 1.1 THIS QUERY DOES WORK when union with decimal, so not an issue of position? - 5,2 and 9,8 , went to NUMERIC_SUB_OID, final 12,8 +SELECT cr1 description, ex + Hello ex1 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT curr_num AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a; +GO + +SELECT 1,cr1 description, ex + Hello ex1 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT curr_num AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a; +GO + +-- inner query -> works without my change +SELECT ExchangeRate + hello ex,CurrencyName cr1, CurrencyName FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT curr_num AS aw,CurrencyName as cr, CurrencyName FROM currency2 ; + +-- inner query -> works without my change +SELECT ExchangeRate + hello ex,CurrencyName cr1, CurrencyName FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName FROM currency2 ; + + +-- works oder of hello and ex - doing this +SELECT cr1 description, ex+ Hello sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2); +-- SELECT cr1 description, ex+ Hello sum_num FROM (SELECT Hello,CurrencyName cr1 (this is var why?), CurrencyName (this is const why??) ,ExchangeRate ex FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a; +GO + +-- works +SELECT cr1 description, ex+ Hello sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a where cr1 = 'US'; +go + +SELECT cr1 description, ex+ Hello sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2); +go +-- from second union +SELECT cr1 description, curr_num+ curr_num sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2); +go + + +-- 2 works without my fix, correct answer also, 5,2 and 9.8 -> final 12,8 +SELECT cr1 description, ex + Hello sum_numeric FROM (SELECT CurrencyName cr1,ExchangeRate ex, Hello,CurrencyName FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT CurrencyName as cr,1 AS aw,curr_num as aw1, CurrencyName FROM currency2) a; +go +-- 3 works without my fix, correct answer also ,so not an issue of position -- for this we got 5,2 and 9,8 , went to NUMERIC_SUB_OID, final 12,8 as expected by tsql also +-- but here also we have numeric and decimal in union result +-- T_RelabelType and T_Var +SELECT cr1 description, ex + Hello sum_numeric FROM (SELECT Hello,CurrencyName cr1,CurrencyName,CurrencyName cr2,ExchangeRate ex FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,CurrencyName cr3,curr_num as aw1 FROM currency2) a; +go + +-- 5 alias issue ??? -- SEEEE THISSS , does not work before my fix, numeric and decimal -- works after fix +-- in union select 1 +SELECT description d1, ex2+h2 test1 from (SELECT CurrencyName description, ex ex2, h1 h2 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello h1 FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a) +go + +-- 6 this works - union decimal and decimal +SELECT description d1, ex2+h2 test1 from (SELECT CurrencyName description, ex ex2, h1 h2 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello h1 FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT curr_num AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a) +go +-- does not work, in union select 1 and 1, after my fix works +SELECT description d1, ex2+h2 test1 from (SELECT CurrencyName description, ex ex2, h1 h2 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello h1 FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,1 as aw1 FROM currency2) a) +go + + +-- from second union, we choose colname based on first query only in union all. so our approach will work in all cases. +SELECT cr1 description, curr_num+ curr_num sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex,curr_num FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1, curr_num FROM currency2); +go +SELECT cr1 description, curr_num+ 5.2 sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex,curr_num FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1, curr_num FROM currency2); +go +-- works +select description, sum_num + sum_num from (SELECT cr1 description, curr_num+ curr_num sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex,curr_num FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1, curr_num FROM currency2)) +go +-- works +select sum_num+sum_num from (SELECT cr1 description, ex + Hello sum_num FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a) +go + + +Select result+result as sum_result from (select case 1 when 1 then cast(1.12343 as decimal(5,2)) end as result Union all select Hello from ExchangeRate2) as derived_table +go + +-- multiple union all +select ex5 + ex5 ex_result from (select ToCurrencyCode, exchangerate ex5 from ExchangeRate2 union all (SELECT cr1 description, ex + Hello ex1 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT curr_num AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a)) +go + + +-- Setup: Create a UDT and additional test tables +CREATE TYPE TestUDT FROM decimal(10,4); +GO + +CREATE TABLE TestTypes ( + IntCol int, + FloatCol float, + SmallIntCol smallint, + NumericCol numeric(10,5), + UDTCol TestUDT +); +GO + +INSERT INTO TestTypes VALUES +(100, 100.5, 10, 100.12345, 100.1234), +(200, 200.5, 20, 200.12345, 200.1234); +GO + +-- Test Case 1: Multiple UNION ALLs with different combinations +SELECT + CASE WHEN IntCol > 150 THEN FloatCol ELSE SmallIntCol END AS result, + NumericCol + UDTCol AS sum_result +FROM TestTypes +UNION ALL +SELECT + CAST(NumericCol AS float) AS result, + IntCol + FloatCol AS sum_result +FROM TestTypes +UNION ALL +SELECT + COALESCE(SmallIntCol, 0) AS result, + CAST(UDTCol AS numeric(12,6)) + NumericCol AS sum_result +FROM TestTypes; +GO +-- Test Case 2: Nested queries with decimal and numeric operations +SELECT outer_result + inner_result AS final_result +FROM ( + SELECT + (SELECT AVG(NumericCol) FROM TestTypes) AS outer_result, + ( + SELECT TOP 1 UDTCol + FloatCol + FROM TestTypes + ORDER BY IntCol DESC + ) AS inner_result +) AS nested_query; +GO +-- Test Case 3: Decimal + Numeric with different scales and precisions +SELECT + CAST(12345.6789 AS decimal(10,4)) + NumericCol AS dec_num_sum, + CAST(12345.6789 AS decimal(10,4)) * NumericCol AS dec_num_product +FROM TestTypes +UNION ALL +SELECT + CAST(9876.54321 AS numeric(12,8)) + UDTCol, + CAST(9876.54321 AS numeric(12,8)) * UDTCol +FROM TestTypes; +GO +-- Test Case 4: UDT operations +SELECT + UDTCol + IntCol AS udt_int_sum, + UDTCol * FloatCol AS udt_float_product, + UDTCol / NULLIF(SmallIntCol, 0) AS udt_smallint_div +FROM TestTypes; +GO +-- Test Case 5: Mixed type operations with CAST +SELECT + CAST(IntCol AS decimal(10,2)) + FloatCol AS int_float_sum, + CAST(SmallIntCol AS numeric(8,4)) * NumericCol AS smallint_numeric_product, + CAST(UDTCol AS float) / NULLIF(IntCol, 0) AS udt_int_div +FROM TestTypes +UNION ALL +SELECT + CAST(12.34 AS decimal(5,2)) + CAST(56.78 AS numeric(6,3)), + CAST(100 AS smallint) * CAST(2.5 AS float), + CAST(1000 AS numeric(10,4)) / NULLIF(CAST(3 AS int), 0) +FROM TestTypes; +GO +-- Test Case 6: All possible operations +SELECT + IntCol + FloatCol AS addition, + NumericCol - UDTCol AS subtraction, + SmallIntCol * FloatCol AS multiplication, + CAST(NumericCol AS float) / NULLIF(IntCol, 0) AS division, + POWER(FloatCol, 2) AS exponentiation, + IntCol % 3 AS modulo +FROM TestTypes; +GO +-- Test Case 7: UNION with different scales and precisions +SELECT CAST(IntCol AS decimal(10,2)) AS result +FROM TestTypes +UNION +SELECT CAST(FloatCol AS decimal(12,4)) +FROM TestTypes +UNION +SELECT NumericCol +FROM TestTypes +UNION +SELECT UDTCol +FROM TestTypes; +GO +-- Test Case 8: Complex nested query with multiple operations +SELECT + outer_sum + (SELECT AVG(inner_product) FROM inner_query) +FROM ( + SELECT + SUM(CASE + WHEN IntCol > 150 THEN FloatCol + ELSE CAST(SmallIntCol AS float) + END) AS outer_sum + FROM TestTypes +) AS outer_query +CROSS APPLY ( + SELECT + (UDTCol * NumericCol) + (IntCol / NULLIF(CAST(SmallIntCol AS float), 0)) AS inner_product + FROM TestTypes + WHERE IntCol = outer_query.outer_sum +) AS inner_query; +GO \ No newline at end of file diff --git a/test/dotnet/ExpectedOutput/TestNumeric.out b/test/dotnet/ExpectedOutput/TestNumeric.out index b4f0f66297..ef79db08b7 100644 --- a/test/dotnet/ExpectedOutput/TestNumeric.out +++ b/test/dotnet/ExpectedOutput/TestNumeric.out @@ -196,13 +196,13 @@ #Q#DROP TABLE numeric_table; #Q#SELECT CASE WHEN 1=1 THEN 0 ELSE cast(98.7627 AS numeric(24,6)) + coalesce(cast(91128.7627 AS numeric(24,6)),0) END #D#decimal -0 +0.000000 #Q#SELECT CAST(0 AS NUMERIC) #D#decimal 0 #Q#SELECT CASE WHEN 1=1 THEN 5 ELSE cast(98.7627 AS numeric(24,6)) + coalesce(cast(91128.7627 AS numeric(24,6)),0) END #D#decimal -5 +5.000000 #Q#SELECT CAST(5 AS NUMERIC) #D#decimal 5 From 8f0b219327b48ee34ab7f56c86abd2d540883895 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 18 Dec 2024 09:34:20 +0000 Subject: [PATCH 10/21] rerun test From a7f180e1d1de0bc1e762d3d507881bd1ea688d03 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 18 Dec 2024 09:46:04 +0000 Subject: [PATCH 11/21] Adding test case Signed-off-by: Tanya Gupta --- test/JDBC/expected/babel-5454.out | 534 ++++++++++++++++++++++++++++++ test/JDBC/input/babel-5454.sql | 33 +- 2 files changed, 548 insertions(+), 19 deletions(-) create mode 100644 test/JDBC/expected/babel-5454.out diff --git a/test/JDBC/expected/babel-5454.out b/test/JDBC/expected/babel-5454.out new file mode 100644 index 0000000000..50e788d149 --- /dev/null +++ b/test/JDBC/expected/babel-5454.out @@ -0,0 +1,534 @@ +-- Create simplified tables +CREATE TABLE Currency (Code nvarchar(3), Name nvarchar(2), Num decimal(2,1)); +CREATE TABLE Exchange (Code nvarchar(3), Rate decimal(5,2), Value decimal(9,8)); +GO + +-- Insert minimal test data +INSERT INTO Currency VALUES ('USD', 'US', 2.1), ('EUR', 'EU', 1.1); +INSERT INTO Exchange VALUES ('USD', 1.00, 5.12345678), ('EUR', 0.12, 1.12345678); +GO +~~ROW COUNT: 2~~ + +~~ROW COUNT: 2~~ + + +-- The query that demonstrates the issue, works without my chnage +SELECT e.Name AS description, e.Rate + e.Value AS sum_num +FROM +( + SELECT Currency.Code, Currency.Name, Exchange.Rate, Exchange.Value + FROM Currency + JOIN Exchange ON Currency.Code = Exchange.Code + UNION ALL + SELECT Code, Name, 1 AS Rate, Num AS Value + FROM Currency +) AS e; +GO +~~START~~ +nvarchar#!#numeric +US#!#6.12345678 +EU#!#1.24345678 +US#!#3.10000000 +EU#!#2.10000000 +~~END~~ + + + +CREATE TABLE Currency2(CurrencyCode nvarchar(3) NOT NULL, CurrencyName nvarchar(2) NULL, curr_num decimal (2,1)); +GO + +CREATE TABLE ExchangeRate2(ToCurrencyCode nvarchar(3) NOT NULL, ExchangeRate decimal(5, 2) NOT NULL, Hello decimal(9,8)); +GO + +INSERT INTO Currency2 (CurrencyCode, CurrencyName,curr_num) VALUES ('USD', 'US',2.1), ('EUR', 'Eu',1.1), ('GBP', 'Br',3.1), ('JPY', 'Ja',4.1), ('CAD', 'Ca',5.1); +GO +~~ROW COUNT: 5~~ + + +INSERT INTO ExchangeRate2 (ToCurrencyCode, ExchangeRate, Hello) VALUES ('EUR', 0.12, 1.12345678), ('GBP', 23.87, 2.12345678), ('JPY', 110.50, 3.12345678), ('CAD', 1.25, 4.12345678), ('USD', 1.00 , 5.12345678); +GO +~~ROW COUNT: 5~~ + + + +-- should notb work withoit my changes +-- SELECT cr1 description, ex + Hello sum_num FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a; +-- GO +-- 1.1 THIS QUERY DOES WORK when union with decimal, so not an issue of position? - 5,2 and 9,8 , went to NUMERIC_SUB_OID, final 12,8 +SELECT cr1 description, ex + Hello ex1 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT curr_num AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a; +GO +~~START~~ +nvarchar#!#numeric +US#!#6.12345678 +Eu#!#1.24345678 +Br#!#25.99345678 +Ja#!#113.62345678 +Ca#!#5.37345678 +US#!#4.20000000 +Eu#!#2.20000000 +Br#!#6.20000000 +Ja#!#8.20000000 +Ca#!#10.20000000 +~~END~~ + + +SELECT 1,cr1 description, ex + Hello ex1 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT curr_num AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a; +GO +~~START~~ +int#!#nvarchar#!#numeric +1#!#US#!#6.12345678 +1#!#Eu#!#1.24345678 +1#!#Br#!#25.99345678 +1#!#Ja#!#113.62345678 +1#!#Ca#!#5.37345678 +1#!#US#!#4.20000000 +1#!#Eu#!#2.20000000 +1#!#Br#!#6.20000000 +1#!#Ja#!#8.20000000 +1#!#Ca#!#10.20000000 +~~END~~ + + + + + +-- inner query -> works without my change +SELECT ExchangeRate + hello ex,CurrencyName cr1, CurrencyName FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT curr_num AS aw,CurrencyName as cr, CurrencyName FROM currency2 ; +-- inner query -> works without my change +SELECT ExchangeRate + hello ex,CurrencyName cr1, CurrencyName FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName FROM currency2 ; +-- works oder of hello and ex - doing this +SELECT cr1 description, ex+ Hello sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2); +-- SELECT cr1 description, ex+ Hello sum_num FROM (SELECT Hello,CurrencyName cr1 (this is var why?), CurrencyName (this is const why??) ,ExchangeRate ex FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a; +GO +~~START~~ +numeric#!#nvarchar#!#nvarchar +6.12345678#!#US#!#US +1.24345678#!#Eu#!#Eu +25.99345678#!#Br#!#Br +113.62345678#!#Ja#!#Ja +5.37345678#!#Ca#!#Ca +2.10000000#!#US#!#US +1.10000000#!#Eu#!#Eu +3.10000000#!#Br#!#Br +4.10000000#!#Ja#!#Ja +5.10000000#!#Ca#!#Ca +~~END~~ + +~~START~~ +numeric#!#nvarchar#!#nvarchar +6.12345678#!#US#!#US +1.24345678#!#Eu#!#Eu +25.99345678#!#Br#!#Br +113.62345678#!#Ja#!#Ja +5.37345678#!#Ca#!#Ca +1.00000000#!#US#!#US +1.00000000#!#Eu#!#Eu +1.00000000#!#Br#!#Br +1.00000000#!#Ja#!#Ja +1.00000000#!#Ca#!#Ca +~~END~~ + +~~START~~ +nvarchar#!#numeric +US#!#6.12345678 +Eu#!#1.24345678 +Br#!#25.99345678 +Ja#!#113.62345678 +Ca#!#5.37345678 +US#!#3.10000000 +Eu#!#2.10000000 +Br#!#4.10000000 +Ja#!#5.10000000 +Ca#!#6.10000000 +~~END~~ + + +-- works +SELECT cr1 description, ex+ Hello sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a where cr1 = 'US'; +go +~~START~~ +nvarchar#!#numeric +US#!#6.12345678 +US#!#3.10000000 +~~END~~ + + +SELECT cr1 description, ex+ Hello sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2); +go +~~START~~ +nvarchar#!#numeric +US#!#6.12345678 +Eu#!#1.24345678 +Br#!#25.99345678 +Ja#!#113.62345678 +Ca#!#5.37345678 +US#!#3.10000000 +Eu#!#2.10000000 +Br#!#4.10000000 +Ja#!#5.10000000 +Ca#!#6.10000000 +~~END~~ + +-- from second union +SELECT cr1 description, curr_num+ curr_num sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2); +go +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: column "curr_num" does not exist)~~ + + + +-- 2 works without my fix, correct answer also, 5,2 and 9.8 -> final 12,8 +SELECT cr1 description, ex + Hello sum_numeric FROM (SELECT CurrencyName cr1,ExchangeRate ex, Hello,CurrencyName FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT CurrencyName as cr,1 AS aw,curr_num as aw1, CurrencyName FROM currency2) a; +go +~~START~~ +nvarchar#!#numeric +US#!#6.12345678 +Eu#!#1.24345678 +Br#!#25.99345678 +Ja#!#113.62345678 +Ca#!#5.37345678 +US#!#3.10000000 +Eu#!#2.10000000 +Br#!#4.10000000 +Ja#!#5.10000000 +Ca#!#6.10000000 +~~END~~ + +-- 3 works without my fix, correct answer also ,so not an issue of position -- for this we got 5,2 and 9,8 , went to NUMERIC_SUB_OID, final 12,8 as expected by tsql also +-- but here also we have numeric and decimal in union result +-- T_RelabelType and T_Var +SELECT cr1 description, ex + Hello sum_numeric FROM (SELECT Hello,CurrencyName cr1,CurrencyName,CurrencyName cr2,ExchangeRate ex FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,CurrencyName cr3,curr_num as aw1 FROM currency2) a; +go +~~START~~ +nvarchar#!#numeric +US#!#6.12345678 +Eu#!#1.24345678 +Br#!#25.99345678 +Ja#!#113.62345678 +Ca#!#5.37345678 +US#!#3.10000000 +Eu#!#2.10000000 +Br#!#4.10000000 +Ja#!#5.10000000 +Ca#!#6.10000000 +~~END~~ + + +-- 5 alias issue ??? -- SEEEE THISSS , does not work before my fix, numeric and decimal -- works after fix +-- in union select 1 +SELECT description d1, ex2+h2 test1 from (SELECT CurrencyName description, ex ex2, h1 h2 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello h1 FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a) +go +~~START~~ +nvarchar#!#numeric +US#!#6.12345678 +Eu#!#1.24345678 +Br#!#25.99345678 +Ja#!#113.62345678 +Ca#!#5.37345678 +US#!#3.10000000 +Eu#!#2.10000000 +Br#!#4.10000000 +Ja#!#5.10000000 +Ca#!#6.10000000 +~~END~~ + + +-- 6 this works - union decimal and decimal +SELECT description d1, ex2+h2 test1 from (SELECT CurrencyName description, ex ex2, h1 h2 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello h1 FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT curr_num AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a) +go +~~START~~ +nvarchar#!#numeric +US#!#6.12345678 +Eu#!#1.24345678 +Br#!#25.99345678 +Ja#!#113.62345678 +Ca#!#5.37345678 +US#!#4.20000000 +Eu#!#2.20000000 +Br#!#6.20000000 +Ja#!#8.20000000 +Ca#!#10.20000000 +~~END~~ + + + +-- does not work, in union select 1 and 1, after my fix works +-- SELECT description d1, ex2+h2 test1 from (SELECT CurrencyName description, ex ex2, h1 h2 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello h1 FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,1 as aw1 FROM currency2) a) +-- go +-- from second union, we choose colname based on first query only in union all. so our approach will work in all cases. +SELECT cr1 description, curr_num+ curr_num sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex,curr_num FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1, curr_num FROM currency2); +go +~~START~~ +nvarchar#!#numeric +US#!#4.2 +Eu#!#2.2 +Br#!#6.2 +Ja#!#8.2 +Ca#!#10.2 +US#!#4.2 +Eu#!#2.2 +Br#!#6.2 +Ja#!#8.2 +Ca#!#10.2 +~~END~~ + +SELECT cr1 description, curr_num+ 5.2 sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex,curr_num FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1, curr_num FROM currency2); +go +~~START~~ +nvarchar#!#numeric +US#!#7.3 +Eu#!#6.3 +Br#!#8.3 +Ja#!#9.3 +Ca#!#10.3 +US#!#7.3 +Eu#!#6.3 +Br#!#8.3 +Ja#!#9.3 +Ca#!#10.3 +~~END~~ + +-- works +select description, sum_num + sum_num from (SELECT cr1 description, curr_num+ curr_num sum_num FROM (SELECT Hello,CurrencyName cr1, CurrencyName ,ExchangeRate ex,curr_num FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1, curr_num FROM currency2)) +go +~~START~~ +nvarchar#!#numeric +US#!#8.4 +Eu#!#4.4 +Br#!#12.4 +Ja#!#16.4 +Ca#!#20.4 +US#!#8.4 +Eu#!#4.4 +Br#!#12.4 +Ja#!#16.4 +Ca#!#20.4 +~~END~~ + +-- works +select sum_num+sum_num from (SELECT cr1 description, ex + Hello sum_num FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a) +go +~~START~~ +numeric +12.24691356 +2.48691356 +51.98691356 +227.24691356 +10.74691356 +6.20000000 +4.20000000 +8.20000000 +10.20000000 +12.20000000 +~~END~~ + + + +Select result+result as sum_result from (select case 1 when 1 then cast(1.12343 as decimal(5,2)) end as result Union all select Hello from ExchangeRate2) as derived_table +go +~~START~~ +numeric +2.24000000 +2.24691356 +4.24691356 +6.24691356 +8.24691356 +10.24691356 +~~END~~ + + +-- multiple union all +select ex5 + ex5 ex_result from (select ToCurrencyCode, exchangerate ex5 from ExchangeRate2 union all (SELECT cr1 description, ex + Hello ex1 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT curr_num AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a)) +go +~~START~~ +numeric +0.24000000 +47.74000000 +221.00000000 +2.50000000 +2.00000000 +12.24691356 +2.48691356 +51.98691356 +227.24691356 +10.74691356 +8.40000000 +4.40000000 +12.40000000 +16.40000000 +20.40000000 +~~END~~ + + + +-- Setup: Create a UDT and additional test tables +CREATE TYPE TestUDT FROM decimal(10,4); +GO + +CREATE TABLE TestTypes ( + IntCol int, + FloatCol float, + SmallIntCol smallint, + NumericCol numeric(10,5), + UDTCol TestUDT +); +GO + +INSERT INTO TestTypes VALUES +(100, 100.5, 10, 100.12345, 100.1234), +(200, 200.5, 20, 200.12345, 200.1234); +GO +~~ROW COUNT: 2~~ + + +-- Test Case 1: Multiple UNION ALLs with different combinations +SELECT + CASE WHEN IntCol > 150 THEN FloatCol ELSE SmallIntCol END AS result, + NumericCol + UDTCol AS sum_result +FROM TestTypes +UNION ALL +SELECT + CAST(NumericCol AS float) AS result, + IntCol + FloatCol AS sum_result +FROM TestTypes +UNION ALL +SELECT + COALESCE(SmallIntCol, 0) AS result, + CAST(UDTCol AS numeric(12,6)) + NumericCol AS sum_result +FROM TestTypes; +GO +~~START~~ +float#!#float +10.0#!#200.24685 +200.5#!#400.24685 +100.12345#!#200.5 +200.12345#!#400.5 +10.0#!#200.24685 +20.0#!#400.24685 +~~END~~ + +-- Test Case 2: Nested queries with decimal and numeric operations +SELECT outer_result + inner_result AS final_result +FROM ( + SELECT + (SELECT AVG(NumericCol) FROM TestTypes) AS outer_result, + ( + SELECT TOP 1 UDTCol + FloatCol + FROM TestTypes + ORDER BY IntCol DESC + ) AS inner_result +) AS nested_query; +GO +~~START~~ +float +550.74685 +~~END~~ + +-- Test Case 3: Decimal + Numeric with different scales and precisions +SELECT + CAST(12345.6789 AS decimal(10,4)) + NumericCol AS dec_num_sum, + CAST(12345.6789 AS decimal(10,4)) * NumericCol AS dec_num_product +FROM TestTypes +UNION ALL +SELECT + CAST(9876.54321 AS numeric(12,8)) + UDTCol, + CAST(9876.54321 AS numeric(12,8)) * UDTCol +FROM TestTypes; +GO +~~START~~ +numeric#!#numeric +12445.80235000#!#1236091.9640602050000000 +12545.80235000#!#2470659.8540602050000000 +9976.66661000#!#988873.0864321140000000 +10076.66661000#!#1976527.4074321140000000 +~~END~~ + +-- Test Case 4: UDT operations +SELECT + UDTCol + IntCol AS udt_int_sum, + UDTCol * FloatCol AS udt_float_product, + UDTCol / NULLIF(SmallIntCol, 0) AS udt_smallint_div +FROM TestTypes; +GO +~~START~~ +numeric#!#float#!#numeric +200.12340000#!#10062.4017#!#10.01234000 +400.12340000#!#40124.7417#!#10.00617000 +~~END~~ + +-- Test Case 5: Mixed type operations with CAST +SELECT + CAST(IntCol AS decimal(10,2)) + FloatCol AS int_float_sum, + CAST(SmallIntCol AS numeric(8,4)) * NumericCol AS smallint_numeric_product, + CAST(UDTCol AS float) / NULLIF(IntCol, 0) AS udt_int_div +FROM TestTypes +UNION ALL +SELECT + CAST(12.34 AS decimal(5,2)) + CAST(56.78 AS numeric(6,3)), + CAST(100 AS smallint) * CAST(2.5 AS float), + CAST(1000 AS numeric(10,4)) / NULLIF(CAST(3 AS int), 0) +FROM TestTypes; +GO +~~START~~ +float#!#float#!#float +200.5#!#1001.2345#!#1.001234 +400.5#!#4002.469#!#1.000617 +69.12#!#250.0#!#333.3333333333333 +69.12#!#250.0#!#333.3333333333333 +~~END~~ + +-- Test Case 6: All possible operations +SELECT + IntCol + FloatCol AS addition, + NumericCol - UDTCol AS subtraction, + SmallIntCol * FloatCol AS multiplication, + CAST(NumericCol AS float) / NULLIF(IntCol, 0) AS division, + POWER(FloatCol, 2) AS exponentiation, + IntCol % 3 AS modulo +FROM TestTypes; +GO +~~START~~ +float#!#numeric#!#float#!#float#!#float#!#int +200.5#!#0.00005#!#1005.0#!#1.0012345#!#10100.25#!#1 +400.5#!#0.00005#!#4010.0#!#1.00061725#!#40200.25#!#2 +~~END~~ + +-- Test Case 7: UNION with different scales and precisions +SELECT CAST(IntCol AS decimal(10,2)) AS result +FROM TestTypes +UNION +SELECT CAST(FloatCol AS decimal(12,4)) +FROM TestTypes +UNION +SELECT NumericCol +FROM TestTypes +UNION +SELECT UDTCol +FROM TestTypes; +GO +~~START~~ +numeric +200.50000 +100.12340 +200.00000 +200.12340 +200.12345 +100.00000 +100.50000 +100.12345 +~~END~~ + + +DROP TABLE TestTypes; +GO +DROP TABLE Currency2; +GO +DROP TABLE ExchangeRate2; +GO +DROP TABLE Currency; +GO +DROP TABLE Exchange; +GO +DROP TYPE TestUDT; +GO diff --git a/test/JDBC/input/babel-5454.sql b/test/JDBC/input/babel-5454.sql index 81ed919f2e..d61b9ffa83 100644 --- a/test/JDBC/input/babel-5454.sql +++ b/test/JDBC/input/babel-5454.sql @@ -86,8 +86,8 @@ go SELECT description d1, ex2+h2 test1 from (SELECT CurrencyName description, ex ex2, h1 h2 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello h1 FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT curr_num AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a) go -- does not work, in union select 1 and 1, after my fix works -SELECT description d1, ex2+h2 test1 from (SELECT CurrencyName description, ex ex2, h1 h2 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello h1 FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,1 as aw1 FROM currency2) a) -go +-- SELECT description d1, ex2+h2 test1 from (SELECT CurrencyName description, ex ex2, h1 h2 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello h1 FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,1 as aw1 FROM currency2) a) +-- go -- from second union, we choose colname based on first query only in union all. so our approach will work in all cases. @@ -211,21 +211,16 @@ UNION SELECT UDTCol FROM TestTypes; GO --- Test Case 8: Complex nested query with multiple operations -SELECT - outer_sum + (SELECT AVG(inner_product) FROM inner_query) -FROM ( - SELECT - SUM(CASE - WHEN IntCol > 150 THEN FloatCol - ELSE CAST(SmallIntCol AS float) - END) AS outer_sum - FROM TestTypes -) AS outer_query -CROSS APPLY ( - SELECT - (UDTCol * NumericCol) + (IntCol / NULLIF(CAST(SmallIntCol AS float), 0)) AS inner_product - FROM TestTypes - WHERE IntCol = outer_query.outer_sum -) AS inner_query; + +DROP TABLE TestTypes; +GO +DROP TABLE Currency2; +GO +DROP TABLE ExchangeRate2; +GO +DROP TABLE Currency; +GO +DROP TABLE Exchange; +GO +DROP TYPE TestUDT; GO \ No newline at end of file From 59bc91e1964dad8b334e11b4eadea38c1ad488f0 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 18 Dec 2024 12:56:21 +0000 Subject: [PATCH 12/21] updating test files --- .../src/backend/tds/tdsresponse.c | 29 +- ...SE_EXPR-before-16_5-or-15_9-vu-cleanup.out | 5 +- ...SE_EXPR-before-16_5-or-15_9-vu-prepare.out | 16 + ...ASE_EXPR-before-16_5-or-15_9-vu-verify.out | 592 +- ...BABEL-CASE_EXPR-before-16_6-vu-cleanup.out | 39 + ...BABEL-CASE_EXPR-before-16_6-vu-prepare.out | 173 + .../BABEL-CASE_EXPR-before-16_6-vu-verify.out | 14534 ++++++++++++++++ .../expected/BABEL-CASE_EXPR-vu-cleanup.out | 3 + .../expected/BABEL-CASE_EXPR-vu-prepare.out | 16 + .../expected/BABEL-CASE_EXPR-vu-verify.out | 594 +- ...ASE_EXPR-before-16_5-or-15_9-vu-verify.out | 592 +- .../BABEL-CASE_EXPR-before-16_6-vu-verify.out | 14534 ++++++++++++++++ .../BABEL-CASE_EXPR-vu-verify.out | 594 +- ...ASE_EXPR-before-16_5-or-15_9-vu-verify.out | 592 +- .../BABEL-CASE_EXPR-before-16_6-vu-verify.out | 14534 ++++++++++++++++ .../BABEL-CASE_EXPR-vu-verify.out | 594 +- ...SE_EXPR-before-16_5-or-15_9-vu-cleanup.sql | 3 + ...SE_EXPR-before-16_5-or-15_9-vu-prepare.sql | 15 + ...ASE_EXPR-before-16_5-or-15_9-vu-verify.sql | 326 +- ...BABEL-CASE_EXPR-before-16_6-vu-cleanup.sql | 39 + ...BABEL-CASE_EXPR-before-16_6-vu-prepare.sql | 156 + .../BABEL-CASE_EXPR-before-16_6-vu-verify.sql | 8301 +++++++++ .../JDBC/input/BABEL-CASE_EXPR-vu-cleanup.sql | 3 + .../JDBC/input/BABEL-CASE_EXPR-vu-prepare.sql | 15 + test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql | 326 +- test/JDBC/jdbc_schedule | 3 + test/JDBC/upgrade/15_10/schedule | 2 +- test/JDBC/upgrade/15_11/schedule | 2 +- test/JDBC/upgrade/16_6/schedule | 2 +- 29 files changed, 56448 insertions(+), 186 deletions(-) create mode 100644 test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-cleanup.out create mode 100644 test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-prepare.out create mode 100644 test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out create mode 100644 test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out create mode 100644 test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out create mode 100644 test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-cleanup.sql create mode 100644 test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-prepare.sql create mode 100644 test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-verify.sql diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index 61a8de391e..ea16b7bbf2 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -438,16 +438,16 @@ resolve_numeric_typmod_from_append_or_mergeappend(Plan *plan, AttrNumber attno) foreach(lc, planlist) { TargetEntry *tle; - Plan *outerplan = (Plan *) lfirst(lc); // this is first part of union , in nect loop second part of union. here SUBQUERYSCAN correct order of elements and subplan that has left tree and right tree and hashcluase (join on condition). second time maybe its not SubqueryScan and thats why we dont enter that inside ??? -- second time only SEQSCAN tahts why + Plan *outerplan = (Plan *) lfirst(lc); - /* if outerplan is SubqueryScan then use actual subplan */// here if we sty out then we are picking correct and its vatatno is 1 which is correct column actually inside the subquery + /* if outerplan is SubqueryScan then use actual subplan */ // if (IsA(outerplan, SubqueryScan)) - // outerplan = ((SubqueryScan *)outerplan)->subplan; // this is inner query. first part of union. + // outerplan = ((SubqueryScan *)outerplan)->subplan; - tle = get_tle_by_resno(outerplan->targetlist, attno); // here? + tle = get_tle_by_resno(outerplan->targetlist, attno); if (IsA(tle->expr, Var)) { - Var *var = (Var *)tle->expr; + Var *var = (Var *)tle->expr; if (var->varno == OUTER_VAR) { typmod = resolve_numeric_typmod_outer_var(outerplan, var->varattno); @@ -463,7 +463,7 @@ resolve_numeric_typmod_from_append_or_mergeappend(Plan *plan, AttrNumber attno) } if (typmod == -1) continue; - scale = (typmod - VARHDRSZ) & 0xffff; // scale 2 + scale = (typmod - VARHDRSZ) & 0xffff; precision = ((typmod - VARHDRSZ) >> 16) & 0xffff; integralDigitCount = Max(precision - scale, max_precision - max_scale); max_scale = Max(max_scale, scale); @@ -510,7 +510,7 @@ resolve_numeric_typmod_outer_var(Plan *plan, AttrNumber attno) Var *var = (Var *)tle->expr; if (var->varno == OUTER_VAR) { - return resolve_numeric_typmod_outer_var(outerplan, var->varattno); // left tree has appoend thats why in nect call we see append + return resolve_numeric_typmod_outer_var(outerplan, var->varattno); } } return resolve_numeric_typmod_from_exp(outerplan, (Node *)tle->expr); @@ -611,8 +611,8 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) { arg1 = linitial(op->args); arg2 = lsecond(op->args); - typmod1 = resolve_numeric_typmod_from_exp(plan, arg1); // 3,2 - typmod2 = resolve_numeric_typmod_from_exp(plan, arg2); // send varattnosyn from here ? // 9,8 + typmod1 = resolve_numeric_typmod_from_exp(plan, arg1); + typmod2 = resolve_numeric_typmod_from_exp(plan, arg2); scale1 = (typmod1 - VARHDRSZ) & 0xffff; precision1 = ((typmod1 - VARHDRSZ) >> 16) & 0xffff; scale2 = (typmod2 - VARHDRSZ) & 0xffff; @@ -756,15 +756,6 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) precision = TDS_MAX_NUM_PRECISION; scale = Max(scale - delta, 0); } - // else if (precision - scale > 32 && scale < 6) - // { - // precision = TDS_MAX_NUM_PRECISION; - // } - // else if (precision - scale < 32) - // { - // scale = Min(scale, 38 - (precision-scale)); - // } - /* * Control reaching here for only arithmetic overflow * cases @@ -1806,8 +1797,6 @@ PrepareRowDescription(TupleDesc typeinfo, PlannedStmt *plannedstmt, List *target /* * Get the IO function info from our type cache */ - if (atttypmod == TSQLMaxTypmod) - atttypmod = -1; finfo = TdsLookupTypeFunctionsByOid(atttypid, &atttypmod); /* atttypid = getBaseTypeAndTypmod(atttypid, &atttypmod); */ #if 0 diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out index 1765f5a25e..a45aea03c9 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out @@ -1,10 +1,8 @@ DROP VIEW BABEL_5103_V1; GO - DROP TABLE BABEL_5103_T1; GO - DROP VIEW BABEL_5103_V2; GO @@ -34,3 +32,6 @@ GO DROP FUNCTION BABEL_5341_F1; GO + +DROP TABLE BABEL_5341_T2; +GO \ No newline at end of file diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out index 901221c721..7e1779c1cf 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out @@ -155,3 +155,19 @@ BEGIN ); END; GO + +CREATE TABLE BABEL_5341_T2 +( + [integer_one] INT, + [integer_two] INT +); +GO +INSERT INTO BABEL_5341_T2 +( + [integer_one], + [integer_two] +) +VALUES +(1, 3); +GO +~~ROW COUNT: 1~~ diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index 8c3181a4b1..2330fe2193 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -13730,21 +13730,6 @@ smalldatetime ~~END~~ -SELECT CASE 2 - WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) - WHEN 2 THEN CAST(GETDATE() AS DATE) - WHEN 3 THEN CAST(GETDATE() AS TIME) - WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) - WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) - WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) -END AS Result -GO -~~START~~ -smalldatetime -2024-12-06 00:00:00.0 -~~END~~ - - -- Test Case 42: NUMERIC and TINYINT SELECT CASE 1 WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) @@ -13805,7 +13790,7 @@ END AS RESULT GO ~~START~~ numeric -99.99 +99.9900000000 ~~END~~ @@ -13835,7 +13820,7 @@ END AS RESULT GO ~~START~~ numeric -49382.7161 +49382.7161000000 ~~END~~ @@ -13850,7 +13835,7 @@ END AS RESULT GO ~~START~~ numeric -12345.68 +12345.6800000000 ~~END~~ @@ -13865,7 +13850,7 @@ END AS RESULT GO ~~START~~ numeric -99.9900 +99.9900000000 ~~END~~ @@ -13896,7 +13881,7 @@ FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) GO ~~START~~ numeric -600.0000 +600.0000000000 ~~END~~ @@ -13911,7 +13896,7 @@ END AS RESULT GO ~~START~~ numeric -1000 +1000.0000000000 ~~END~~ @@ -13941,7 +13926,7 @@ END AS RESULT GO ~~START~~ numeric -9876.54 +9876.5400 ~~END~~ @@ -13971,7 +13956,7 @@ END AS RESULT GO ~~START~~ numeric -1234568.8901000000 +1234568.9 ~~END~~ @@ -13986,3 +13971,564 @@ GO DROP TYPE SmallDecimalType_BABEL_5341; GO + +-- test cases +-- Test Case 57: Basic DECIMAL and NUMERIC mix +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1))), + (CAST(2.2 AS NUMERIC(3,1))), + (CAST(3.3 AS DECIMAL(3,1))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +2.2 +3.3 +~~END~~ + + +-- Test Case 58: Different precisions and scales +SELECT * FROM (VALUES + (CAST(1.23456 AS DECIMAL(6,5))), + (CAST(23.4567 AS NUMERIC(6,4))), + (CAST(345.678 AS DECIMAL(6,3))), + (CAST(4567.89 AS NUMERIC(6,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23456 +23.45670 +345.67800 +4567.89000 +~~END~~ + + +-- Test Case 59: Large precisions +SELECT * FROM (VALUES + (CAST(1234567890123456789.1234567890 AS DECIMAL(38,10))), + (CAST(9876543210987654321.0987654321 AS NUMERIC(38,10))), + (CAST(1111111111111111111.1111111111 AS DECIMAL(38,10))) +) AS "VALUES"; +GO +~~START~~ +numeric +1234567890123456789.1234567890 +9876543210987654321.0987654321 +1111111111111111111.1111111111 +~~END~~ + + +-- Test Case 60: Small scales +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(38,1))), + (CAST(22.22 AS NUMERIC(38,2))), + (CAST(333.333 AS DECIMAL(38,3))), + (CAST(4444.4444 AS NUMERIC(38,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +22.2 +333.3 +4444.4 +~~END~~ + + +-- Test Case 61: Mix of positive and negative numbers +SELECT * FROM (VALUES + (CAST(-1.23 AS DECIMAL(5,2))), + (CAST(4.56 AS NUMERIC(5,2))), + (CAST(-7.89 AS DECIMAL(5,2))), + (CAST(0.12 AS NUMERIC(5,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +-1.23 +4.56 +-7.89 +0.12 +~~END~~ + + +-- Test Case 62: Very small numbers +SELECT * FROM (VALUES + (CAST(0.000000000123 AS DECIMAL(15,12))), + (CAST(0.000000000456 AS NUMERIC(15,12))), + (CAST(0.000000000789 AS DECIMAL(15,12))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23E-10 +4.56E-10 +7.89E-10 +~~END~~ + + +-- Test Case 63: Very large numbers +SELECT * FROM (VALUES + (CAST(123456789012345678901234567890.12 AS DECIMAL(38,2))), + (CAST(987654321098765432109876543210.98 AS NUMERIC(38,2))), + (CAST(111111111111111111111111111111.11 AS DECIMAL(38,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +123456789012345678901234567890.12 +987654321098765432109876543210.98 +111111111111111111111111111111.11 +~~END~~ + + +-- Test Case 64: Mix of integer and fractional parts +SELECT * FROM (VALUES + (CAST(1 AS DECIMAL(38,0))), + (CAST(2.2 AS NUMERIC(38,1))), + (CAST(3.33 AS DECIMAL(38,2))), + (CAST(4.444 AS NUMERIC(38,3))) +) AS "VALUES"; +GO +~~START~~ +numeric +1 +2 +3 +4 +~~END~~ + + +-- Test Case 65: Edge cases +SELECT * FROM (VALUES + (CAST(0.9999999999999999999999999999999999999 AS DECIMAL(38,37))), + (CAST(9.999999999999999999999999999999999999 AS NUMERIC(38,36))), + (CAST(0.0000000000000000000000000000000000001 AS DECIMAL(38,37))) +) AS "VALUES"; +GO +~~START~~ +numeric +0.999999999999999999999999999999999999 +9.999999999999999999999999999999999999 +0E-36 +~~END~~ + + +-- Test Case 66: Mix of DECIMAL and NUMERIC with different precisions +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(5,1))), + (CAST(2.22 AS NUMERIC(10,2))), + (CAST(3.333 AS DECIMAL(15,3))), + (CAST(4.4444 AS NUMERIC(20,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1000 +2.2200 +3.3330 +4.4444 +~~END~~ + + +-- Test Case 67: Mix of numeric, decimal, integer, and varchar +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), 10, 'ABC'), + (CAST(2.2 AS NUMERIC(3,1)), 20, 'DEF'), + (CAST(3.3 AS DECIMAL(3,1)), 30, 'GHI') +) AS "VALUES" (dec_num, int_num, str_val); +GO +~~START~~ +numeric#!#int#!#varchar +1.1#!#10#!#ABC +2.2#!#20#!#DEF +3.3#!#30#!#GHI +~~END~~ + + +-- Test Case 68: Mix with date, time, and boolean +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(4,2)), CAST('2023-01-01' AS DATE), CAST('10:30:00' AS TIME), TRUE), + (CAST(4.56 AS NUMERIC(4,2)), CAST('2023-02-15' AS DATE), CAST('14:45:00' AS TIME), FALSE), + (CAST(7.89 AS DECIMAL(4,2)), CAST('2023-03-30' AS DATE), CAST('20:15:00' AS TIME), TRUE) +) AS "VALUES" (num_val, date_val, time_val, bool_val); +GO +~~START~~ +numeric#!#date#!#time#!#bit +1.23#!#2023-01-01#!#10:30:00.0000000#!#1 +4.56#!#2023-02-15#!#14:45:00.0000000#!#0 +7.89#!#2023-03-30#!#20:15:00.0000000#!#1 +~~END~~ + + +-- Test Case 69: Mix with timestamp and interval +SELECT * FROM (VALUES + (CAST(123.45 AS DECIMAL(5,2)), CAST('2023-01-01 12:00:00' AS TIMESTAMP), CAST('1 day' AS INTERVAL)), + (CAST(678.90 AS NUMERIC(5,2)), CAST('2023-06-15 18:30:00' AS TIMESTAMP), CAST('2 hours' AS INTERVAL)), + (CAST(246.80 AS DECIMAL(5,2)), CAST('2023-12-31 23:59:59' AS TIMESTAMP), CAST('30 minutes' AS INTERVAL)) +) AS "VALUES" (num_val, ts_val, interval_val); +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: To use the TIMESTAMP datatype, set 'babelfishpg_tsql.escape_hatch_rowversion' to 'ignore')~~ + + +-- Test Case 70: Mix with char, varchar, and text +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), CAST('A' AS CHAR(1)), CAST('ABC' AS VARCHAR(10)), 'This is a text'), + (CAST(2.2 AS NUMERIC(3,1)), CAST('B' AS CHAR(1)), CAST('DEF' AS VARCHAR(10)), 'Another text'), + (CAST(3.3 AS DECIMAL(3,1)), CAST('C' AS CHAR(1)), CAST('GHI' AS VARCHAR(10)), 'Yet another text') +) AS "VALUES" (num_val, char_val, varchar_val, text_val); +GO +~~START~~ +numeric#!#char#!#varchar#!#varchar +1.1#!#A#!#ABC#!#This is a text +2.2#!#B#!#DEF#!#Another text +3.3#!#C#!#GHI#!#Yet another text +~~END~~ + + +-- Test Case 71: Mix with money and bit +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(3,2)), CAST(100.00 AS MONEY), CAST('1' AS BIT)), + (CAST(4.56 AS NUMERIC(3,2)), CAST(200.50 AS MONEY), CAST('0' AS BIT)), + (CAST(7.89 AS DECIMAL(3,2)), CAST(350.75 AS MONEY), CAST('1' AS BIT)) +) AS "VALUES" (num_val, money_val, bit_val); +GO +~~START~~ +numeric#!#money#!#bit +1.23#!#100.0000#!#1 +4.56#!#200.5000#!#0 +7.89#!#350.7500#!#1 +~~END~~ + + +-- Test Case 72: UNION with DECIMAL and INTEGER +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT 456 +ORDER BY value; +GO +~~START~~ +numeric +1.23 +456.00 +~~END~~ + + +-- Test Case 73: UNION with NUMERIC, DECIMAL, and FLOAT +SELECT CAST(1.23456 AS NUMERIC(10,5)) AS value +UNION ALL +SELECT CAST(2.34567 AS DECIMAL(10,5)) +UNION ALL +SELECT CAST(3.45678 AS FLOAT) +ORDER BY value; +GO +~~START~~ +float +1.23456 +2.34567 +3.45678 +~~END~~ + + +-- Test Case 74: UNION with different precisions and scales +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(2.3456 AS NUMERIC(10,4)) +UNION ALL +SELECT CAST(3.456789 AS DECIMAL(15,6)) +ORDER BY value; +GO +~~START~~ +numeric +1.230000 +2.345600 +3.456789 +~~END~~ + + +-- Test Case 75: UNION with negative numbers and zero +SELECT CAST(-1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(0 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(1.23 AS DECIMAL(5,2)) +ORDER BY value; +GO +~~START~~ +numeric +-1.23 +0.00 +1.23 +~~END~~ + + +-- Test Case 75: UNION with large numbers +SELECT CAST(1234567890.12345 AS DECIMAL(20,5)) AS value +UNION ALL +SELECT CAST(9876543210.98765 AS NUMERIC(20,5)) +UNION ALL +SELECT CAST(1111111111.11111 AS DECIMAL(20,5)) +ORDER BY value; +GO +~~START~~ +numeric +1111111111.11111 +1234567890.12345 +9876543210.98765 +~~END~~ + + +-- Test Case 76: UNION with small numbers +SELECT CAST(0.00000123 AS DECIMAL(10,8)) AS value +UNION ALL +SELECT CAST(0.00000456 AS NUMERIC(10,8)) +UNION ALL +SELECT CAST(0.00000789 AS DECIMAL(10,8)) +ORDER BY value; +GO +~~START~~ +numeric +0.00000123 +0.00000456 +0.00000789 +~~END~~ + + +-- Test Case 77: UNION with DECIMAL, NUMERIC, and VARCHAR +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST('7.89' AS VARCHAR(10)) +ORDER BY value; +GO +~~START~~ +numeric +1.2300000000 +4.5600000000 +7.8900000000 +~~END~~ + + +-- Test Case 78: UNION with different integer parts +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(123.45 AS NUMERIC(10,2)) +UNION ALL +SELECT CAST(12345.67 AS DECIMAL(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +123.45 +12345.67 +~~END~~ + + +-- Test Case 79: UNION with extreme values +SELECT CAST(9999999999.99999999 AS DECIMAL(18,8)) AS value +UNION ALL +SELECT CAST(0.00000001 AS NUMERIC(18,8)) +UNION ALL +SELECT CAST(5555555555.55555555 AS DECIMAL(18,8)) +ORDER BY value; +GO +~~START~~ +numeric +1E-8 +5555555555.55555555 +9999999999.99999999 +~~END~~ + + +-- Test Case 80: UNION with NULL values +SELECT CAST(NULL AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(1.23 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(NULL AS DECIMAL(5,2)) +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +1.23 +4.56 +~~END~~ + + +-- Test Case 81: UNION with MONEY type +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(4.56 AS MONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 82: UNION with SMALLMONEY type +SELECT CAST(1.23 AS DECIMAL(6,2)) AS value +UNION ALL +SELECT CAST(4.56 AS SMALLMONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(6,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 83: DECIMAL(38,1) - 37 digits before decimal, 1 after +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(1000000000000000000000000000000000000.0 AS DECIMAL(38,1)) +ORDER BY value; +GO +~~START~~ +numeric +1000000000000000000000000000000000000.0 +1234567890123456789012345678901234567.8 +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 84: DECIMAL(38,2) - 36 digits before decimal, 2 after +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) AS value +UNION ALL +SELECT CAST(999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(100000000000000000000000000000000000.00 AS DECIMAL(38,2)) +ORDER BY value; +GO +~~START~~ +numeric +100000000000000000000000000000000000.00 +123456789012345678901234567890123456.78 +999999999999999999999999999999999999.99 +~~END~~ + + +-- Test Case 85: DECIMAL(38,5) - 33 digits before decimal, 5 after +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) AS value +UNION ALL +SELECT CAST(99999999999999999999999999999999.99999 AS DECIMAL(38,5)) +UNION ALL +SELECT CAST(10000000000000000000000000000000.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +10000000000000000000000000000000.00001 +12345678901234567890123456789012.34567 +99999999999999999999999999999999.99999 +~~END~~ + + +-- Test Case 86: Mixing different scales with precision 38 +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.7 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 88: Very small fractional part with precision 38 +SELECT CAST(9999999999999999999999999999999999999.1 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.01 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 89: Overflow scenarios with precision 38 +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(10000000000000000000000000000000000000.0 AS DECIMAL(38,1)) -- This will cause an overflow +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 90: Mixing DECIMAL and NUMERIC with precision 38 and small scales +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS NUMERIC(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.8 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 91: NULL values with precision 38 and small scales +SELECT CAST(NULL AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(NULL AS NUMERIC(38,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 92: customer query +DECLARE @test_int int = 1; +SELECT a.integer_one, a.integer_two, +ratio = a.integer_one / CONVERT(DECIMAL, a.integer_two), +ratio_case_one = CASE WHEN a.integer_two = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_two = CASE WHEN 1 = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_three = CASE WHEN @test_int = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END +FROM BABEL_5341_T2 a; +GO +~~START~~ +int#!#int#!#numeric#!#numeric#!#numeric#!#numeric +1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 +~~END~~ diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-cleanup.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-cleanup.out new file mode 100644 index 0000000000..debf59e513 --- /dev/null +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-cleanup.out @@ -0,0 +1,39 @@ + +DROP VIEW BABEL_5103_V1; +GO + +DROP TABLE BABEL_5103_T1; +GO + +DROP VIEW BABEL_5103_V2; +GO + +DROP FUNCTION BABEL_5103_F1; +GO + +DROP TABLE BABEL_5341_T1; +GO + +DROP VIEW BABEL_5341_V1; +GO + +DROP VIEW BABEL_5341_V2; +GO + +DROP VIEW BABEL_5341_V3; +GO + +DROP VIEW BABEL_5341_V4; +GO + +DROP VIEW BABEL_5341_V5; +GO + +DROP VIEW BABEL_5341_V6; +GO + +DROP FUNCTION BABEL_5341_F1; +GO + +DROP TABLE BABEL_5341_T2; +GO \ No newline at end of file diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-prepare.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-prepare.out new file mode 100644 index 0000000000..7e1779c1cf --- /dev/null +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-prepare.out @@ -0,0 +1,173 @@ +CREATE TABLE BABEL_5103_T1( + COL1 VARCHAR(2000) NOT NULL, + COL2 AS CAST(COL1 AS NCHAR(2001)), + COL3 AS CAST(COL1 AS VARCHAR(MAX)), + COL4 AS CAST(COL1 AS NVARCHAR(2001)), + COL5 AS CAST(COL1 AS TEXT), + COL6 AS CAST(COL1 AS NTEXT) +) +GO + +INSERT INTO BABEL_5103_T1 (COL1) +VALUES (N'Registration Card - Standard'); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5103_T1 (COL1) +VALUES (N'بطاقة التسجيل - قياسية'); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5103_T1 (COL1) +VALUES (N'登録カード–標準'); +GO +~~ROW COUNT: 1~~ + + +CREATE VIEW BABEL_5103_V1 AS +SELECT COL1, COL2, COL3, COL4, COL5, COL6 +FROM BABEL_5103_T1; +GO + +CREATE VIEW BABEL_5103_V2 AS +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(10)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(10)) +END AS RESULT +GO + +CREATE FUNCTION BABEL_5103_F1(@ARG NVARCHAR(1001)) +RETURNS NVARCHAR(1001) +AS +BEGIN + RETURN ( + CASE + WHEN @ARG = 'REGULAR' THEN 'REGULAR' + WHEN @ARG = N'登録カード–標準' THEN N'登録カード–標準' + WHEN @ARG = N'بطاقة التسجيل - قياسية'THEN N'بطاقة التسجيل - قياسية' + END + ); +END; +GO + +CREATE TABLE BABEL_5341_T1 ( + COL1 NUMERIC(20,2), + COL2 DECIMAL(20,2), + COL3 NUMERIC(38,0), + COL4 DECIMAL(38,0), + COL5 NUMERIC(2,0), + COL6 DECIMAL(2,0) +); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (12345.67, 54321.98, 1234567890123456789, 9876543210987654321, 42, 99); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (98765.43, 12345.67, 9876543210987654321, 1234567890123456789, 10, 50); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (11111.11, 22222.22, 1111111111111111111, 2222222222222222222, 11, 22); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (33333.33, 44444.44, 3333333333333333333, 4444444444444444444, 33, 44); +GO +~~ROW COUNT: 1~~ + + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (55555.55, 66666.66, 5555555555555555555, 6666666666666666666, 55, 66); +GO +~~ROW COUNT: 1~~ + + +CREATE VIEW BABEL_5341_V1 AS +SELECT CASE 3 + WHEN 1 THEN CAST(123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(678.90 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(1234.56 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V2 AS +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(6789 AS NUMERIC(10,0)) + WHEN 3 THEN CAST(12.3456 AS NUMERIC(10,4)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V3 AS +SELECT CASE 1 + WHEN 1 THEN CAST(1234567890123456 AS NUMERIC(20,0)) + WHEN 2 THEN CAST(9876543210987654 AS NUMERIC(20,0)) + WHEN 3 THEN CAST(1111222233334444 AS NUMERIC(20,0)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V4 AS +SELECT CASE 3 + WHEN 1 THEN CAST(0.0001 AS NUMERIC(10,4)) + WHEN 2 THEN CAST(0.0002 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(0.0003 AS NUMERIC(10,4)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V5 AS +SELECT CASE 2 + WHEN 1 THEN CAST(-123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(678.90 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(-1234.56 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V6 AS +SELECT CASE 3 + WHEN 1 THEN CAST(100 + 23.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(1000 - 321.10 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(500 * 2.5 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE FUNCTION BABEL_5341_F1(@ARG NUMERIC(20,2)) +RETURNS NUMERIC(20,4) +AS +BEGIN + RETURN ( + CASE + WHEN @ARG = 100.00 THEN CAST(123.45 AS NUMERIC(20,2)) + WHEN @ARG = 200.00 THEN CAST(6789 AS NUMERIC(20,0)) + WHEN @ARG = 300.00 THEN CAST(12.3456 AS NUMERIC(20,4)) + ELSE @ARG + END + ); +END; +GO + +CREATE TABLE BABEL_5341_T2 +( + [integer_one] INT, + [integer_two] INT +); +GO +INSERT INTO BABEL_5341_T2 +( + [integer_one], + [integer_two] +) +VALUES +(1, 3); +GO +~~ROW COUNT: 1~~ diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out new file mode 100644 index 0000000000..72a1a40f32 --- /dev/null +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out @@ -0,0 +1,14534 @@ +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +-- Function call +SELECT BABEL_5103_F1('REGULAR'); +GO +~~START~~ +nvarchar +REGULAR +~~END~~ + + +SELECT BABEL_5103_F1(N'登録カード–標準'); +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT BABEL_5103_F1(N'بطاقة التسجيل - قياسية'); +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +-- selecting from view +SELECT * FROM BABEL_5103_V2 +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +-- single branch +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + +-- single branch with multibyte character +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being CHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS Char(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS Char(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being TEXT +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS TEXT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS TEXT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch with one being string literal +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +?????–?? +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +?????–?? +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +?????–?? +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branches one being NULL +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- NULL tests +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +-- other datatypes then string +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO +~~START~~ +numeric +123.00 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123.456 AS FLOAT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO +~~START~~ +float +123.456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO +~~START~~ +bigint +123 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO +~~START~~ +numeric +123.00 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123.456 AS BIGINT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO +~~START~~ +numeric +123.000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO +~~START~~ +bigint +123 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('2024-01-01' AS DATE) + WHEN 2 THEN CAST('2024-09-27 12:34:56' AS DATETIME) +END AS RESULT +GO +~~START~~ +datetime +2024-01-01 00:00:00.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('12:34:56' AS TIME) + WHEN 2 THEN CAST('2024-09-27 12:34:56.1234567' AS DATETIME2(7)) +END AS RESULT +GO +~~START~~ +datetime2 +1900-01-01 12:34:56.0000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1 AS BIT) + WHEN 2 THEN CAST(0 AS BIT) +END AS RESULT +GO +~~START~~ +bit +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BINARY(3)) + WHEN 2 THEN CAST(0xABCDEF AS VARBINARY(6)) +END AS RESULT +GO +~~START~~ +varbinary +123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1000.00 AS MONEY) + WHEN 2 THEN CAST(100.00 AS SMALLMONEY) +END AS RESULT +GO +~~START~~ +money +1000.0000 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO +~~START~~ +numeric +456.00 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123.456 AS FLOAT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO +~~START~~ +float +789.123 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO +~~START~~ +bigint +456789123 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO +~~START~~ +numeric +456.00 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123.456 AS BIGINT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO +~~START~~ +numeric +789.123 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO +~~START~~ +bigint +456789123 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('2024-01-01' AS DATE) + WHEN 2 THEN CAST('2024-09-27 12:34:56' AS DATETIME) +END AS RESULT +GO +~~START~~ +datetime +2024-09-27 12:34:56.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('12:34:56' AS TIME) + WHEN 2 THEN CAST('2024-09-27 12:34:56.1234567' AS DATETIME2(7)) +END AS RESULT +GO +~~START~~ +datetime2 +2024-09-27 12:34:56.1234570 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1 AS BIT) + WHEN 2 THEN CAST(0 AS BIT) +END AS RESULT +GO +~~START~~ +bit +0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BINARY(3)) + WHEN 2 THEN CAST(0xABCDEF AS VARBINARY(6)) +END AS RESULT +GO +~~START~~ +varbinary +ABCDEF +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1000.00 AS MONEY) + WHEN 2 THEN CAST(100.00 AS SMALLMONEY) +END AS RESULT +GO +~~START~~ +money +100.0000 +~~END~~ + + + +-- Collation tests +-- FIX ME: Following test cases shows behaviour mismatch, +-- When we compare N' 比尔·拉莫斯 ' COLLATE japanese_ci_as +-- with N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS for CASE expression, +-- Gives 'true' (as used in PG), whereas it should give 'false' (as in TSQL). +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS +END AS RESULT +GO +~~START~~ +varchar +abcd +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE japanese_ci_as + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as +END AS RESULT +GO +~~START~~ +varchar + abc?defghi?? +~~END~~ + + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE japanese_ci_as + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE ARABIC_CI_AS + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS +END AS RESULT +GO +~~START~~ +varchar + abc?defghi?? +~~END~~ + + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS +END AS RESULT +GO +~~START~~ +varchar +abcd +~~END~~ + + +--- SYSNAME tests +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +--- UDT testing +create type BABEL_CASE_EXPR_TEST_UDT from NVARCHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from sysname; +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + + +create type BABEL_CASE_EXPR_TEST_UDT from VARCHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from CHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +char +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +char +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +char +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from NCHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from TEXT; +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from NTEXT; +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- multiple branch one being Binary +create type BABEL_CASE_EXPR_TEST_UDT from BINARY(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 0x123456 +END AS RESULT +GO +~~START~~ +varbinary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 0x123456 +END AS RESULT +GO +~~START~~ +varbinary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 0x123456 + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varbinary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- multiple branch one being VARBINARY +create type BABEL_CASE_EXPR_TEST_UDT from VARBINARY(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varbinary +123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varbinary +123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varbinary +123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +?????–?? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- multiple UDT branches +create type BABEL_CASE_EXPR_TEST_UDT0 from NVARCHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT1 from NCHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT2 from CHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT3 from VARCHAR(100); +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nchar +?????–?? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT0; +go + +drop type BABEL_CASE_EXPR_TEST_UDT1; +go + +drop type BABEL_CASE_EXPR_TEST_UDT2; +go + +drop type BABEL_CASE_EXPR_TEST_UDT3; +go + +-- Numeric datatypes +create type BABEL_CASE_EXPR_TEST_UDT0 from INT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT1 from DECIMAL; +GO + +create type BABEL_CASE_EXPR_TEST_UDT2 from FLOAT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT3 from BIT; +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(2.300 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +2.3 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +int +0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(12.3 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(1 AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +int +1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(1.345 AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(1321 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +bit +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST(1.234 AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +numeric +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(1235 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.345 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(234.234 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(346 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(04545 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(12.4 AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +numeric +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(1 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST(234.234 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type babel_case_expr_test_udt3 to double precision)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type babel_case_expr_test_udt2 to "bit")~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(123.3 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(546 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +numeric +123 +~~END~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(54 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.123 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +54.0 +~~END~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(23 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(6356 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +numeric +23 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(3456.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 3 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type babel_case_expr_test_udt3 to double precision)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(23.12 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(2354 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +float +23.0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT0; +go + +drop type BABEL_CASE_EXPR_TEST_UDT1; +go + +drop type BABEL_CASE_EXPR_TEST_UDT2; +go + +drop type BABEL_CASE_EXPR_TEST_UDT3; +go + +-- Mixture of numeric and string types +create type BABEL_CASE_EXPR_TEST_UDT0 from INT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT1 from NCHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT2 from FLOAT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT3 from VARCHAR(100); +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(2.300 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +2.3 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "登録カード–標準")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "登録カード–標準")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "登録カード–標準 ")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(1321 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +int +1321 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(1235 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.345 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(346 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(04545 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST(234.234 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(546 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(54 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.123 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(6356 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(3456.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +float +3456.34 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(2354 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "char0 ")~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT0; +go + +drop type BABEL_CASE_EXPR_TEST_UDT1; +go + +drop type BABEL_CASE_EXPR_TEST_UDT2; +go + +drop type BABEL_CASE_EXPR_TEST_UDT3; +go + +-- Mixture of datatypes and numeric without UDT +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(2.300 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +2.3 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS INT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "登録カード–標準")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS INT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "登録カード–標準")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS FLOAT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "登録カード–標準 ")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(1321 AS INT) +END AS RESULT +GO +~~START~~ +int +1321 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(1235 AS INT) + WHEN 3 THEN CAST(0.345 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(346 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(04545 AS INT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(234.234 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(546 AS INT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(54 AS INT) + WHEN 3 THEN CAST(0.123 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(6356 AS INT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS INT) + WHEN 2 THEN CAST(3456.34 AS FLOAT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +float +3456.34 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS FLOAT) + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(2354 AS INT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "char0 ")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(2.300 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +2.3 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS INT) + WHEN 2 THEN CAST(0 AS BIT) +END AS RESULT +GO +~~START~~ +int +0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(12.3 AS DECIMAL) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS INT) + WHEN 2 THEN CAST(1 AS BIT) +END AS RESULT +GO +~~START~~ +int +1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS FLOAT) + WHEN 2 THEN CAST(1.345 AS DECIMAL) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1 AS BIT) + WHEN 2 THEN CAST(1321 AS INT) +END AS RESULT +GO +~~START~~ +bit +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(0 AS BIT) + WHEN 3 THEN CAST(1.234 AS DECIMAL) +END AS RESULT +GO +~~START~~ +numeric +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(1235 AS INT) + WHEN 3 THEN CAST(0.345 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(234.234 AS DECIMAL) + WHEN 3 THEN CAST(346 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(04545 AS INT) + WHEN 3 THEN CAST(12.4 AS DECIMAL) +END AS RESULT +GO +~~START~~ +numeric +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(1 AS BIT) + WHEN 3 THEN CAST(234.234 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "bit" to double precision)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0 AS BIT) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type double precision to "bit")~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(123.3 AS DECIMAL) + WHEN 3 THEN CAST(546 AS INT) +END AS RESULT +GO +~~START~~ +numeric +123 +~~END~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(54 AS INT) + WHEN 3 THEN CAST(0.123 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +54.0 +~~END~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(23 AS DECIMAL) + WHEN 3 THEN CAST(6356 AS INT) +END AS RESULT +GO +~~START~~ +numeric +23 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS INT) + WHEN 2 THEN CAST(3456.34 AS FLOAT) + WHEN 3 THEN CAST(0 AS BIT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "bit" to double precision)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS FLOAT) + WHEN 2 THEN CAST(23.12 AS DECIMAL) + WHEN 3 THEN CAST(2354 AS INT) +END AS RESULT +GO +~~START~~ +float +23.0 +~~END~~ + + +-- UDT on varchar(max) +create type BABEL_CASE_EXPR_TEST_UDT from varchar(max); +go + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +varchar +a +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +varchar +a +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- UDT on nvarchar(max) +create type BABEL_CASE_EXPR_TEST_UDT from nvarchar(max); +go + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +nvarchar +a +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +nvarchar +a +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- With max typmod +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS VARCHAR(MAX)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nchar +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nchar +N +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +N +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +N +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +N +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO +~~START~~ +text +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +NCHAR +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO +~~START~~ +text +NCHAR +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO +~~START~~ +text +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +NCHAR +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO +~~START~~ +text +NCHAR +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (4000) for 'nchar' datatype.)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (4000) for 'nchar' datatype.)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (4000) for 'nchar' datatype.)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (4000) for 'nchar' datatype.)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + + +-- Testing for numeric and decimal +-- Test Case 1: Basic CASE with 6 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 0 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 2: CASE with 5 columns and ELSE +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +99 +50 +22 +44 +66 +~~END~~ + + +-- Test Case 3: CASE with 4 columns and ELSE +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + ELSE COL5 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +42 +10 +11 +33 +55 +~~END~~ + + +-- Test Case 4: CASE with 3 columns and ELSE +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + ELSE COL4 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 5: CASE with 2 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + ELSE COL3 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 6: CASE with 1 column and ELSE +SELECT CASE 2 + WHEN 1 THEN COL1 + ELSE COL2 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +54321.98 +12345.67 +22222.22 +44444.44 +66666.66 +~~END~~ + + +-- Test Case 7: CASE with all columns returning a constant value +SELECT CASE 7 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 999.99 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1000 +1000 +1000 +1000 +1000 +~~END~~ + + +-- Test Case 8: CASE with mixed constant and column values +SELECT CASE 4 + WHEN 1 THEN 100 + WHEN 2 THEN COL2 + WHEN 3 THEN 300 + WHEN 4 THEN COL4 + WHEN 5 THEN 500 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 9: CASE with views +SELECT * FROM BABEL_5341_V1; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +SELECT * FROM BABEL_5341_V2; +GO +~~START~~ +numeric +6789 +~~END~~ + + +SELECT * FROM BABEL_5341_V3; +GO +~~START~~ +numeric +1234567890123456 +~~END~~ + + +SELECT * FROM BABEL_5341_V4; +GO +~~START~~ +numeric +0.0003 +~~END~~ + + +SELECT * FROM BABEL_5341_V5; +GO +~~START~~ +numeric +678.90 +~~END~~ + + +SELECT * FROM BABEL_5341_V6; +GO +~~START~~ +numeric +1250.00 +~~END~~ + + +-- Test Case 10: Using the function +SELECT BABEL_5341_F1(100.00); +GO +~~START~~ +numeric +123.4500 +~~END~~ + + +SELECT BABEL_5341_F1(200.00); +GO +~~START~~ +numeric +6789.0000 +~~END~~ + + +SELECT BABEL_5341_F1(300.00); +GO +~~START~~ +numeric +12.3456 +~~END~~ + + +SELECT BABEL_5341_F1(400.00); +GO +~~START~~ +numeric +400.0000 +~~END~~ + + +-- Test Case 11: Basic DECIMAL and NUMERIC usage +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +1234567.89000000 +~~END~~ + + +-- Test Case 12: Different scales within the same precision +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.43 AS DECIMAL(10,2)) + WHEN 3 THEN CAST(123456.7 AS DECIMAL(10,1)) + WHEN 4 THEN CAST(1234567 AS DECIMAL(10,0)) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS RESULT +GO +~~START~~ +numeric +98765.4300 +~~END~~ + + +-- Test Case 13: Mixing DECIMAL and NUMERIC with different precisions +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(12,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(15,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +9.87654321 +~~END~~ + + +-- Test Case 14: Large precisions and scales +SELECT CASE 2 + WHEN 1 THEN CAST(12345678901234567890.1234567890 AS DECIMAL(30,10)) + WHEN 2 THEN CAST(98765432109876543210.9876543210 AS NUMERIC(30,10)) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS DECIMAL(25,10)) + WHEN 4 THEN CAST(9.8765432109876543210 AS NUMERIC(20,19)) + ELSE CAST(0 AS DECIMAL(30,10)) +END AS RESULT +GO +~~START~~ +numeric +98765432109876543210.987654321000000000 +~~END~~ + + +-- Test Case 15: Small fractional parts +SELECT CASE 3 + WHEN 1 THEN CAST(12345.000001 AS DECIMAL(12,6)) + WHEN 2 THEN CAST(98765.0000001 AS NUMERIC(14,7)) + WHEN 3 THEN CAST(1234567.0000000001 AS DECIMAL(18,10)) + WHEN 4 THEN CAST(9.000000000000001 AS NUMERIC(17,15)) + ELSE CAST(0.00000001 AS DECIMAL(10,8)) +END AS RESULT +GO +~~START~~ +numeric +1234567.000000000100000 +~~END~~ + + +-- Test Case 16: Negative numbers +SELECT CASE 2 + WHEN 1 THEN CAST(-12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(-98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(-1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(-9.87654321 AS NUMERIC(9,8)) + ELSE CAST(-0.01 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +-98765.43210000 +~~END~~ + + +-- Test Case 17: Potential overflow scenarios +SELECT CASE 3 + WHEN 1 THEN CAST(99999.9999 AS DECIMAL(9,4)) + WHEN 2 THEN CAST(999999.999 AS NUMERIC(9,3)) + WHEN 3 THEN CAST(9999999.99 AS DECIMAL(9,2)) + WHEN 4 THEN CAST(99999999.9 AS NUMERIC(9,1)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT +GO +~~START~~ +numeric +9999999.9900 +~~END~~ + + +-- Test Case 18: Mixing with other numeric types +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765 AS INT) + WHEN 3 THEN CAST(1234567.89 AS FLOAT) + WHEN 4 THEN CAST(9 AS BIGINT) + ELSE CAST(0 AS NUMERIC(5,2)) +END AS RESULT +GO +~~START~~ +float +9.0 +~~END~~ + + + +-- Test Case 19: NUMERIC, DATETIME, and SQL_VARIANT in different branches +DECLARE @var SQL_VARIANT +SET @var = CAST(12345.6789 AS NUMERIC(10,4)) +SELECT CASE + WHEN CAST('2023-05-15' AS DATETIME) > '2023-01-01' THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN @var > 10000 THEN CAST('2023-12-31' AS DATETIME) + WHEN YEAR(GETDATE()) = 2023 THEN @var + ELSE CAST(11111.1111 AS NUMERIC(10,4)) +END AS RESULT +GO +~~START~~ +sql_variant +98765.4321 +~~END~~ + + + +-- Test Case 20: NUMERIC with different precisions, DATETIME, and SQL_VARIANT +DECLARE @var SQL_VARIANT +SET @var = CAST(123456.789 AS NUMERIC(15,3)) +SELECT CASE + WHEN CAST(12345.6789 AS NUMERIC(10,4)) > 10000 THEN CAST(9876543.21 AS NUMERIC(15,2)) + WHEN CAST('2023-05-15' AS DATETIME) < GETDATE() THEN CAST(123.456789 AS NUMERIC(9,6)) + WHEN SQL_VARIANT_PROPERTY(@var, 'Scale') > 2 THEN CAST(GETDATE() AS DATETIME) + ELSE @var +END AS RESULT +GO +~~START~~ +sql_variant +9876543.21 +~~END~~ + + +-- Test Case 21: SQL_VARIANT from BIGINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9223372036854775807 AS BIGINT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 22: SQL_VARIANT from DECIMAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(123.456 AS DECIMAL(10,3)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 23: SQL_VARIANT from FLOAT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(3.14159265359 AS FLOAT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 24: SQL_VARIANT from CHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('A' AS CHAR(1)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 25: SQL_VARIANT from VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('Hello, World!' AS VARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 26: SQL_VARIANT from NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(N'こんにちは' AS NVARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 27: SQL_VARIANT from DATE +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15' AS DATE) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 28: SQL_VARIANT from TIME +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('14:30:00' AS TIME) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 29: SQL_VARIANT from DATETIME2 +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00.1234567' AS DATETIME2(7)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 30: SQL_VARIANT from DATETIMEOFFSET +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00 +01:00' AS DATETIMEOFFSET) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 31: SQL_VARIANT from BIT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1 AS BIT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 32: SQL_VARIANT from UNIQUEIDENTIFIER +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(NEWID() AS UNIQUEIDENTIFIER) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 33: SQL_VARIANT from VARBINARY +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0x1234567890 AS VARBINARY(10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 34: SQL_VARIANT from NUMERIC(10,2) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567.89 AS NUMERIC(10,2)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 35: SQL_VARIANT from NUMERIC(5,4) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.1234 AS NUMERIC(5,4)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 36: SQL_VARIANT from NUMERIC(20,10) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567890.1234567890 AS NUMERIC(20,10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 37: SQL_VARIANT from NUMERIC(38,0) (maximum precision, no decimal places) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(12345678901234567890123456789012345678 AS NUMERIC(38,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 38: SQL_VARIANT from NUMERIC(38,38) (maximum precision and scale) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.12345678901234567890123456789012345678 AS NUMERIC(38,38)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 39: SQL_VARIANT from NUMERIC(1,0) (minimum precision) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9 AS NUMERIC(1,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 40: SQL_VARIANT from negative NUMERIC +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(-9876.54321 AS NUMERIC(10,5)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 41: Numeric branch with time +select case 1 + when 1 then cast(1.23 as numeric(20,2)) + when 2 then cast(1900-01-01 as datetime) +END +go +~~START~~ +datetime +1900-01-02 05:31:12.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type date to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('12:34:56' AS TIME) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type time without time zone to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetime2 to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetimeoffset to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-02 05:31:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) + WHEN 3 THEN CAST('12:34:56' AS TIME) + WHEN 4 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) + WHEN 5 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) + WHEN 6 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-01 00:00:00.0 +~~END~~ + + +-- Test Case 42: NUMERIC and TINYINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(255 AS TINYINT) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Test Case 43: NUMERIC and REAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(3.14 AS REAL) +END AS Result +GO +~~START~~ +real +1.23 +~~END~~ + + +-- Test Case 44: NUMERIC and NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(N'A' AS NCHAR(1)) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Create UDTs +CREATE TYPE NumericType_BABEL_5341 FROM NUMERIC(20,2); +GO + +CREATE TYPE DecimalType_BABEL_5341 FROM DECIMAL(18,4); +GO + +CREATE TYPE BigNumericType_BABEL_5341 FROM NUMERIC(38,10); +GO + +CREATE TYPE SmallDecimalType_BABEL_5341 FROM DECIMAL(5,2); +GO + +-- Test Case 45: Basic CASE with all UDTs +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.9900000000 +~~END~~ + + +-- Test Case 46: CASE with UDTs and different precisions +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS DecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567890123456.7890123456 +~~END~~ + + +-- Test Case 47: CASE with UDTs and mathematical operations +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 * 2 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 / 2 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 + 1000 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 - 50 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +49382.7161000000 +~~END~~ + + +-- Test Case 48: CASE with UDTs and rounding +SELECT CASE 1 + WHEN 1 THEN CAST(ROUND(12345.6789, 2) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(ROUND(98765.4321, 4) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(ROUND(1234567.8901234567890, 10) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(ROUND(99.99, 1) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345.6800000000 +~~END~~ + + +-- Test Case 49: CASE with UDTs and type conversion +SELECT CASE 4 + WHEN 1 THEN CAST(CAST(12345.6789 AS NumericType_BABEL_5341) AS BigNumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(98765.4321 AS DecimalType_BABEL_5341) AS SmallDecimalType_BABEL_5341) + WHEN 3 THEN CAST(CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) AS NumericType_BABEL_5341) + WHEN 4 THEN CAST(CAST(99.99 AS SmallDecimalType_BABEL_5341) AS DecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.9900000000 +~~END~~ + + +-- Test Case 50: CASE with UDTs and potential overflow +SELECT CASE 3 + WHEN 1 THEN CAST(9999999999999999.99 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(99999999999999.9999 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(12345678901234567890.1234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(999.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345678901234567890.1234567890 +~~END~~ + + +-- Test Case 51: CASE with UDTs and aggregate functions +SELECT CASE 2 + WHEN 1 THEN CAST(AVG(CAST(COLUMN_VALUE AS NumericType_BABEL_5341)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(SUM(CAST(COLUMN_VALUE AS DecimalType_BABEL_5341)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(MAX(CAST(COLUMN_VALUE AS BigNumericType_BABEL_5341)) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(MIN(CAST(COLUMN_VALUE AS SmallDecimalType_BABEL_5341)) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) +GO +~~START~~ +numeric +600.0000000000 +~~END~~ + + +-- Test Case 52: UDTs with INT and BIGINT +SELECT CASE 3 + WHEN 1 THEN CAST(12345 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(9876543210 AS BigNumericType_BABEL_5341) + WHEN 3 THEN CAST(1000 AS INT) + WHEN 4 THEN CAST(9223372036854775807 AS BIGINT) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1000.0000000000 +~~END~~ + + +-- Test Case 53: UDTs with FLOAT and REAL +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS DecimalType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS FLOAT) + WHEN 3 THEN CAST(1234.56 AS REAL) + WHEN 4 THEN CAST(9.87654321 AS NumericType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +float +98765.4321 +~~END~~ + + +-- Test Case 54: UDTs with MONEY and SMALLMONEY +SELECT CASE 4 + WHEN 1 THEN CAST(12345.67 AS MONEY) + WHEN 2 THEN CAST(98.76 AS SMALLMONEY) + WHEN 3 THEN CAST(1234.5678 AS DecimalType_BABEL_5341) + WHEN 4 THEN CAST(9876.54 AS NumericType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +9876.5400 +~~END~~ + + +-- Test Case 55: UDTs with VARCHAR and NVARCHAR +SELECT CASE 3 + WHEN 1 THEN CAST(CAST('12345.67' AS VARCHAR(20)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(N'98765.4321' AS NVARCHAR(20)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST('1234567.8901' AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(N'99.99' AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567.8901000000 +~~END~~ + + +-- Test Case 56: UDTs with BIT and mathematical operations +SELECT CASE 3 + WHEN 1 THEN CAST(1 AS BIT) * CAST(12345.67 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(0 AS BIT) * CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1 AS BIT) + CAST(1234567.8901 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(1 AS BIT) - CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234568.9 +~~END~~ + + +DROP TYPE NumericType_BABEL_5341; +GO + +DROP TYPE DecimalType_BABEL_5341; +GO + +DROP TYPE BigNumericType_BABEL_5341; +GO + +DROP TYPE SmallDecimalType_BABEL_5341; +GO + +-- test cases +-- Test Case 57: Basic DECIMAL and NUMERIC mix +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1))), + (CAST(2.2 AS NUMERIC(3,1))), + (CAST(3.3 AS DECIMAL(3,1))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +2.2 +3.3 +~~END~~ + + +-- Test Case 58: Different precisions and scales +SELECT * FROM (VALUES + (CAST(1.23456 AS DECIMAL(6,5))), + (CAST(23.4567 AS NUMERIC(6,4))), + (CAST(345.678 AS DECIMAL(6,3))), + (CAST(4567.89 AS NUMERIC(6,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23456 +23.45670 +345.67800 +4567.89000 +~~END~~ + + +-- Test Case 59: Large precisions +SELECT * FROM (VALUES + (CAST(1234567890123456789.1234567890 AS DECIMAL(38,10))), + (CAST(9876543210987654321.0987654321 AS NUMERIC(38,10))), + (CAST(1111111111111111111.1111111111 AS DECIMAL(38,10))) +) AS "VALUES"; +GO +~~START~~ +numeric +1234567890123456789.1234567890 +9876543210987654321.0987654321 +1111111111111111111.1111111111 +~~END~~ + + +-- Test Case 60: Small scales +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(38,1))), + (CAST(22.22 AS NUMERIC(38,2))), + (CAST(333.333 AS DECIMAL(38,3))), + (CAST(4444.4444 AS NUMERIC(38,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +22.2 +333.3 +4444.4 +~~END~~ + + +-- Test Case 61: Mix of positive and negative numbers +SELECT * FROM (VALUES + (CAST(-1.23 AS DECIMAL(5,2))), + (CAST(4.56 AS NUMERIC(5,2))), + (CAST(-7.89 AS DECIMAL(5,2))), + (CAST(0.12 AS NUMERIC(5,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +-1.23 +4.56 +-7.89 +0.12 +~~END~~ + + +-- Test Case 62: Very small numbers +SELECT * FROM (VALUES + (CAST(0.000000000123 AS DECIMAL(15,12))), + (CAST(0.000000000456 AS NUMERIC(15,12))), + (CAST(0.000000000789 AS DECIMAL(15,12))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23E-10 +4.56E-10 +7.89E-10 +~~END~~ + + +-- Test Case 63: Very large numbers +SELECT * FROM (VALUES + (CAST(123456789012345678901234567890.12 AS DECIMAL(38,2))), + (CAST(987654321098765432109876543210.98 AS NUMERIC(38,2))), + (CAST(111111111111111111111111111111.11 AS DECIMAL(38,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +123456789012345678901234567890.12 +987654321098765432109876543210.98 +111111111111111111111111111111.11 +~~END~~ + + +-- Test Case 64: Mix of integer and fractional parts +SELECT * FROM (VALUES + (CAST(1 AS DECIMAL(38,0))), + (CAST(2.2 AS NUMERIC(38,1))), + (CAST(3.33 AS DECIMAL(38,2))), + (CAST(4.444 AS NUMERIC(38,3))) +) AS "VALUES"; +GO +~~START~~ +numeric +1 +2 +3 +4 +~~END~~ + + +-- Test Case 65: Edge cases +SELECT * FROM (VALUES + (CAST(0.9999999999999999999999999999999999999 AS DECIMAL(38,37))), + (CAST(9.999999999999999999999999999999999999 AS NUMERIC(38,36))), + (CAST(0.0000000000000000000000000000000000001 AS DECIMAL(38,37))) +) AS "VALUES"; +GO +~~START~~ +numeric +0.999999999999999999999999999999999999 +9.999999999999999999999999999999999999 +0E-36 +~~END~~ + + +-- Test Case 66: Mix of DECIMAL and NUMERIC with different precisions +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(5,1))), + (CAST(2.22 AS NUMERIC(10,2))), + (CAST(3.333 AS DECIMAL(15,3))), + (CAST(4.4444 AS NUMERIC(20,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1000 +2.2200 +3.3330 +4.4444 +~~END~~ + + +-- Test Case 67: Mix of numeric, decimal, integer, and varchar +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), 10, 'ABC'), + (CAST(2.2 AS NUMERIC(3,1)), 20, 'DEF'), + (CAST(3.3 AS DECIMAL(3,1)), 30, 'GHI') +) AS "VALUES" (dec_num, int_num, str_val); +GO +~~START~~ +numeric#!#int#!#varchar +1.1#!#10#!#ABC +2.2#!#20#!#DEF +3.3#!#30#!#GHI +~~END~~ + + +-- Test Case 68: Mix with date, time, and boolean +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(4,2)), CAST('2023-01-01' AS DATE), CAST('10:30:00' AS TIME), TRUE), + (CAST(4.56 AS NUMERIC(4,2)), CAST('2023-02-15' AS DATE), CAST('14:45:00' AS TIME), FALSE), + (CAST(7.89 AS DECIMAL(4,2)), CAST('2023-03-30' AS DATE), CAST('20:15:00' AS TIME), TRUE) +) AS "VALUES" (num_val, date_val, time_val, bool_val); +GO +~~START~~ +numeric#!#date#!#time#!#bit +1.23#!#2023-01-01#!#10:30:00.0000000#!#1 +4.56#!#2023-02-15#!#14:45:00.0000000#!#0 +7.89#!#2023-03-30#!#20:15:00.0000000#!#1 +~~END~~ + + +-- Test Case 69: Mix with timestamp and interval +SELECT * FROM (VALUES + (CAST(123.45 AS DECIMAL(5,2)), CAST('2023-01-01 12:00:00' AS TIMESTAMP), CAST('1 day' AS INTERVAL)), + (CAST(678.90 AS NUMERIC(5,2)), CAST('2023-06-15 18:30:00' AS TIMESTAMP), CAST('2 hours' AS INTERVAL)), + (CAST(246.80 AS DECIMAL(5,2)), CAST('2023-12-31 23:59:59' AS TIMESTAMP), CAST('30 minutes' AS INTERVAL)) +) AS "VALUES" (num_val, ts_val, interval_val); +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: To use the TIMESTAMP datatype, set 'babelfishpg_tsql.escape_hatch_rowversion' to 'ignore')~~ + + +-- Test Case 70: Mix with char, varchar, and text +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), CAST('A' AS CHAR(1)), CAST('ABC' AS VARCHAR(10)), 'This is a text'), + (CAST(2.2 AS NUMERIC(3,1)), CAST('B' AS CHAR(1)), CAST('DEF' AS VARCHAR(10)), 'Another text'), + (CAST(3.3 AS DECIMAL(3,1)), CAST('C' AS CHAR(1)), CAST('GHI' AS VARCHAR(10)), 'Yet another text') +) AS "VALUES" (num_val, char_val, varchar_val, text_val); +GO +~~START~~ +numeric#!#char#!#varchar#!#varchar +1.1#!#A#!#ABC#!#This is a text +2.2#!#B#!#DEF#!#Another text +3.3#!#C#!#GHI#!#Yet another text +~~END~~ + + +-- Test Case 71: Mix with money and bit +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(3,2)), CAST(100.00 AS MONEY), CAST('1' AS BIT)), + (CAST(4.56 AS NUMERIC(3,2)), CAST(200.50 AS MONEY), CAST('0' AS BIT)), + (CAST(7.89 AS DECIMAL(3,2)), CAST(350.75 AS MONEY), CAST('1' AS BIT)) +) AS "VALUES" (num_val, money_val, bit_val); +GO +~~START~~ +numeric#!#money#!#bit +1.23#!#100.0000#!#1 +4.56#!#200.5000#!#0 +7.89#!#350.7500#!#1 +~~END~~ + + +-- Test Case 72: UNION with DECIMAL and INTEGER +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT 456 +ORDER BY value; +GO +~~START~~ +numeric +1.23 +456.00 +~~END~~ + + +-- Test Case 73: UNION with NUMERIC, DECIMAL, and FLOAT +SELECT CAST(1.23456 AS NUMERIC(10,5)) AS value +UNION ALL +SELECT CAST(2.34567 AS DECIMAL(10,5)) +UNION ALL +SELECT CAST(3.45678 AS FLOAT) +ORDER BY value; +GO +~~START~~ +float +1.23456 +2.34567 +3.45678 +~~END~~ + + +-- Test Case 74: UNION with different precisions and scales +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(2.3456 AS NUMERIC(10,4)) +UNION ALL +SELECT CAST(3.456789 AS DECIMAL(15,6)) +ORDER BY value; +GO +~~START~~ +numeric +1.230000 +2.345600 +3.456789 +~~END~~ + + +-- Test Case 75: UNION with negative numbers and zero +SELECT CAST(-1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(0 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(1.23 AS DECIMAL(5,2)) +ORDER BY value; +GO +~~START~~ +numeric +-1.23 +0.00 +1.23 +~~END~~ + + +-- Test Case 75: UNION with large numbers +SELECT CAST(1234567890.12345 AS DECIMAL(20,5)) AS value +UNION ALL +SELECT CAST(9876543210.98765 AS NUMERIC(20,5)) +UNION ALL +SELECT CAST(1111111111.11111 AS DECIMAL(20,5)) +ORDER BY value; +GO +~~START~~ +numeric +1111111111.11111 +1234567890.12345 +9876543210.98765 +~~END~~ + + +-- Test Case 76: UNION with small numbers +SELECT CAST(0.00000123 AS DECIMAL(10,8)) AS value +UNION ALL +SELECT CAST(0.00000456 AS NUMERIC(10,8)) +UNION ALL +SELECT CAST(0.00000789 AS DECIMAL(10,8)) +ORDER BY value; +GO +~~START~~ +numeric +0.00000123 +0.00000456 +0.00000789 +~~END~~ + + +-- Test Case 77: UNION with DECIMAL, NUMERIC, and VARCHAR +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST('7.89' AS VARCHAR(10)) +ORDER BY value; +GO +~~START~~ +numeric +1.2300000000 +4.5600000000 +7.8900000000 +~~END~~ + + +-- Test Case 78: UNION with different integer parts +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(123.45 AS NUMERIC(10,2)) +UNION ALL +SELECT CAST(12345.67 AS DECIMAL(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +123.45 +12345.67 +~~END~~ + + +-- Test Case 79: UNION with extreme values +SELECT CAST(9999999999.99999999 AS DECIMAL(18,8)) AS value +UNION ALL +SELECT CAST(0.00000001 AS NUMERIC(18,8)) +UNION ALL +SELECT CAST(5555555555.55555555 AS DECIMAL(18,8)) +ORDER BY value; +GO +~~START~~ +numeric +1E-8 +5555555555.55555555 +9999999999.99999999 +~~END~~ + + +-- Test Case 80: UNION with NULL values +SELECT CAST(NULL AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(1.23 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(NULL AS DECIMAL(5,2)) +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +1.23 +4.56 +~~END~~ + + +-- Test Case 81: UNION with MONEY type +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(4.56 AS MONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 82: UNION with SMALLMONEY type +SELECT CAST(1.23 AS DECIMAL(6,2)) AS value +UNION ALL +SELECT CAST(4.56 AS SMALLMONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(6,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 83: DECIMAL(38,1) - 37 digits before decimal, 1 after +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(1000000000000000000000000000000000000.0 AS DECIMAL(38,1)) +ORDER BY value; +GO +~~START~~ +numeric +1000000000000000000000000000000000000.0 +1234567890123456789012345678901234567.8 +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 84: DECIMAL(38,2) - 36 digits before decimal, 2 after +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) AS value +UNION ALL +SELECT CAST(999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(100000000000000000000000000000000000.00 AS DECIMAL(38,2)) +ORDER BY value; +GO +~~START~~ +numeric +100000000000000000000000000000000000.00 +123456789012345678901234567890123456.78 +999999999999999999999999999999999999.99 +~~END~~ + + +-- Test Case 85: DECIMAL(38,5) - 33 digits before decimal, 5 after +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) AS value +UNION ALL +SELECT CAST(99999999999999999999999999999999.99999 AS DECIMAL(38,5)) +UNION ALL +SELECT CAST(10000000000000000000000000000000.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +10000000000000000000000000000000.00001 +12345678901234567890123456789012.34567 +99999999999999999999999999999999.99999 +~~END~~ + + +-- Test Case 86: Mixing different scales with precision 38 +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.7 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 88: Very small fractional part with precision 38 +SELECT CAST(9999999999999999999999999999999999999.1 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.01 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 89: Overflow scenarios with precision 38 +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(10000000000000000000000000000000000000.0 AS DECIMAL(38,1)) -- This will cause an overflow +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 90: Mixing DECIMAL and NUMERIC with precision 38 and small scales +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS NUMERIC(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.8 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 91: NULL values with precision 38 and small scales +SELECT CAST(NULL AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(NULL AS NUMERIC(38,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 92: customer query +DECLARE @test_int int = 1; +SELECT a.integer_one, a.integer_two, +ratio = a.integer_one / CONVERT(DECIMAL, a.integer_two), +ratio_case_one = CASE WHEN a.integer_two = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_two = CASE WHEN 1 = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_three = CASE WHEN @test_int = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END +FROM BABEL_5341_T2 a; +GO +~~START~~ +int#!#int#!#numeric#!#numeric#!#numeric#!#numeric +1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 +~~END~~ diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-cleanup.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-cleanup.out index 1765f5a25e..61c1332e78 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-cleanup.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-cleanup.out @@ -34,3 +34,6 @@ GO DROP FUNCTION BABEL_5341_F1; GO + +DROP TABLE BABEL_5341_T2; +GO diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out index 901221c721..7e1779c1cf 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out @@ -155,3 +155,19 @@ BEGIN ); END; GO + +CREATE TABLE BABEL_5341_T2 +( + [integer_one] INT, + [integer_two] INT +); +GO +INSERT INTO BABEL_5341_T2 +( + [integer_one], + [integer_two] +) +VALUES +(1, 3); +GO +~~ROW COUNT: 1~~ diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out index 5e5467f942..e058c032a6 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out @@ -13189,7 +13189,7 @@ SELECT * FROM BABEL_5341_V2; GO ~~START~~ numeric -6789 +6789.0000 ~~END~~ @@ -13730,21 +13730,6 @@ smalldatetime ~~END~~ -SELECT CASE 2 - WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) - WHEN 2 THEN CAST(GETDATE() AS DATE) - WHEN 3 THEN CAST(GETDATE() AS TIME) - WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) - WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) - WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) -END AS Result -GO -~~START~~ -smalldatetime -2024-12-06 00:00:00.0 -~~END~~ - - -- Test Case 42: NUMERIC and TINYINT SELECT CASE 1 WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) @@ -13805,7 +13790,7 @@ END AS RESULT GO ~~START~~ numeric -99.99 +99.9900000000 ~~END~~ @@ -13835,7 +13820,7 @@ END AS RESULT GO ~~START~~ numeric -49382.7161 +49382.7161000000 ~~END~~ @@ -13850,7 +13835,7 @@ END AS RESULT GO ~~START~~ numeric -12345.68 +12345.6800000000 ~~END~~ @@ -13865,7 +13850,7 @@ END AS RESULT GO ~~START~~ numeric -99.9900 +99.9900000000 ~~END~~ @@ -13896,7 +13881,7 @@ FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) GO ~~START~~ numeric -600.0000 +600.0000000000 ~~END~~ @@ -13911,7 +13896,7 @@ END AS RESULT GO ~~START~~ numeric -1000 +1000.0000000000 ~~END~~ @@ -13941,7 +13926,7 @@ END AS RESULT GO ~~START~~ numeric -9876.54 +9876.5400 ~~END~~ @@ -13971,7 +13956,7 @@ END AS RESULT GO ~~START~~ numeric -1234568.8901000000 +1234568.9 ~~END~~ @@ -13986,3 +13971,564 @@ GO DROP TYPE SmallDecimalType_BABEL_5341; GO + +-- test cases +-- Test Case 57: Basic DECIMAL and NUMERIC mix +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1))), + (CAST(2.2 AS NUMERIC(3,1))), + (CAST(3.3 AS DECIMAL(3,1))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +2.2 +3.3 +~~END~~ + + +-- Test Case 58: Different precisions and scales +SELECT * FROM (VALUES + (CAST(1.23456 AS DECIMAL(6,5))), + (CAST(23.4567 AS NUMERIC(6,4))), + (CAST(345.678 AS DECIMAL(6,3))), + (CAST(4567.89 AS NUMERIC(6,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23456 +23.45670 +345.67800 +4567.89000 +~~END~~ + + +-- Test Case 59: Large precisions +SELECT * FROM (VALUES + (CAST(1234567890123456789.1234567890 AS DECIMAL(38,10))), + (CAST(9876543210987654321.0987654321 AS NUMERIC(38,10))), + (CAST(1111111111111111111.1111111111 AS DECIMAL(38,10))) +) AS "VALUES"; +GO +~~START~~ +numeric +1234567890123456789.1234567890 +9876543210987654321.0987654321 +1111111111111111111.1111111111 +~~END~~ + + +-- Test Case 60: Small scales +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(38,1))), + (CAST(22.22 AS NUMERIC(38,2))), + (CAST(333.333 AS DECIMAL(38,3))), + (CAST(4444.4444 AS NUMERIC(38,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +22.2 +333.3 +4444.4 +~~END~~ + + +-- Test Case 61: Mix of positive and negative numbers +SELECT * FROM (VALUES + (CAST(-1.23 AS DECIMAL(5,2))), + (CAST(4.56 AS NUMERIC(5,2))), + (CAST(-7.89 AS DECIMAL(5,2))), + (CAST(0.12 AS NUMERIC(5,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +-1.23 +4.56 +-7.89 +0.12 +~~END~~ + + +-- Test Case 62: Very small numbers +SELECT * FROM (VALUES + (CAST(0.000000000123 AS DECIMAL(15,12))), + (CAST(0.000000000456 AS NUMERIC(15,12))), + (CAST(0.000000000789 AS DECIMAL(15,12))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23E-10 +4.56E-10 +7.89E-10 +~~END~~ + + +-- Test Case 63: Very large numbers +SELECT * FROM (VALUES + (CAST(123456789012345678901234567890.12 AS DECIMAL(38,2))), + (CAST(987654321098765432109876543210.98 AS NUMERIC(38,2))), + (CAST(111111111111111111111111111111.11 AS DECIMAL(38,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +123456789012345678901234567890.12 +987654321098765432109876543210.98 +111111111111111111111111111111.11 +~~END~~ + + +-- Test Case 64: Mix of integer and fractional parts +SELECT * FROM (VALUES + (CAST(1 AS DECIMAL(38,0))), + (CAST(2.2 AS NUMERIC(38,1))), + (CAST(3.33 AS DECIMAL(38,2))), + (CAST(4.444 AS NUMERIC(38,3))) +) AS "VALUES"; +GO +~~START~~ +numeric +1 +2 +3 +4 +~~END~~ + + +-- Test Case 65: Edge cases +SELECT * FROM (VALUES + (CAST(0.9999999999999999999999999999999999999 AS DECIMAL(38,37))), + (CAST(9.999999999999999999999999999999999999 AS NUMERIC(38,36))), + (CAST(0.0000000000000000000000000000000000001 AS DECIMAL(38,37))) +) AS "VALUES"; +GO +~~START~~ +numeric +0.999999999999999999999999999999999999 +9.999999999999999999999999999999999999 +0E-36 +~~END~~ + + +-- Test Case 66: Mix of DECIMAL and NUMERIC with different precisions +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(5,1))), + (CAST(2.22 AS NUMERIC(10,2))), + (CAST(3.333 AS DECIMAL(15,3))), + (CAST(4.4444 AS NUMERIC(20,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1000 +2.2200 +3.3330 +4.4444 +~~END~~ + + +-- Test Case 67: Mix of numeric, decimal, integer, and varchar +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), 10, 'ABC'), + (CAST(2.2 AS NUMERIC(3,1)), 20, 'DEF'), + (CAST(3.3 AS DECIMAL(3,1)), 30, 'GHI') +) AS "VALUES" (dec_num, int_num, str_val); +GO +~~START~~ +numeric#!#int#!#varchar +1.1#!#10#!#ABC +2.2#!#20#!#DEF +3.3#!#30#!#GHI +~~END~~ + + +-- Test Case 68: Mix with date, time, and boolean +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(4,2)), CAST('2023-01-01' AS DATE), CAST('10:30:00' AS TIME), TRUE), + (CAST(4.56 AS NUMERIC(4,2)), CAST('2023-02-15' AS DATE), CAST('14:45:00' AS TIME), FALSE), + (CAST(7.89 AS DECIMAL(4,2)), CAST('2023-03-30' AS DATE), CAST('20:15:00' AS TIME), TRUE) +) AS "VALUES" (num_val, date_val, time_val, bool_val); +GO +~~START~~ +numeric#!#date#!#time#!#bit +1.23#!#2023-01-01#!#10:30:00.0000000#!#1 +4.56#!#2023-02-15#!#14:45:00.0000000#!#0 +7.89#!#2023-03-30#!#20:15:00.0000000#!#1 +~~END~~ + + +-- Test Case 69: Mix with timestamp and interval +SELECT * FROM (VALUES + (CAST(123.45 AS DECIMAL(5,2)), CAST('2023-01-01 12:00:00' AS TIMESTAMP), CAST('1 day' AS INTERVAL)), + (CAST(678.90 AS NUMERIC(5,2)), CAST('2023-06-15 18:30:00' AS TIMESTAMP), CAST('2 hours' AS INTERVAL)), + (CAST(246.80 AS DECIMAL(5,2)), CAST('2023-12-31 23:59:59' AS TIMESTAMP), CAST('30 minutes' AS INTERVAL)) +) AS "VALUES" (num_val, ts_val, interval_val); +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: To use the TIMESTAMP datatype, set 'babelfishpg_tsql.escape_hatch_rowversion' to 'ignore')~~ + + +-- Test Case 70: Mix with char, varchar, and text +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), CAST('A' AS CHAR(1)), CAST('ABC' AS VARCHAR(10)), 'This is a text'), + (CAST(2.2 AS NUMERIC(3,1)), CAST('B' AS CHAR(1)), CAST('DEF' AS VARCHAR(10)), 'Another text'), + (CAST(3.3 AS DECIMAL(3,1)), CAST('C' AS CHAR(1)), CAST('GHI' AS VARCHAR(10)), 'Yet another text') +) AS "VALUES" (num_val, char_val, varchar_val, text_val); +GO +~~START~~ +numeric#!#char#!#varchar#!#varchar +1.1#!#A#!#ABC#!#This is a text +2.2#!#B#!#DEF#!#Another text +3.3#!#C#!#GHI#!#Yet another text +~~END~~ + + +-- Test Case 71: Mix with money and bit +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(3,2)), CAST(100.00 AS MONEY), CAST('1' AS BIT)), + (CAST(4.56 AS NUMERIC(3,2)), CAST(200.50 AS MONEY), CAST('0' AS BIT)), + (CAST(7.89 AS DECIMAL(3,2)), CAST(350.75 AS MONEY), CAST('1' AS BIT)) +) AS "VALUES" (num_val, money_val, bit_val); +GO +~~START~~ +numeric#!#money#!#bit +1.23#!#100.0000#!#1 +4.56#!#200.5000#!#0 +7.89#!#350.7500#!#1 +~~END~~ + + +-- Test Case 72: UNION with DECIMAL and INTEGER +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT 456 +ORDER BY value; +GO +~~START~~ +numeric +1.23 +456.00 +~~END~~ + + +-- Test Case 73: UNION with NUMERIC, DECIMAL, and FLOAT +SELECT CAST(1.23456 AS NUMERIC(10,5)) AS value +UNION ALL +SELECT CAST(2.34567 AS DECIMAL(10,5)) +UNION ALL +SELECT CAST(3.45678 AS FLOAT) +ORDER BY value; +GO +~~START~~ +float +1.23456 +2.34567 +3.45678 +~~END~~ + + +-- Test Case 74: UNION with different precisions and scales +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(2.3456 AS NUMERIC(10,4)) +UNION ALL +SELECT CAST(3.456789 AS DECIMAL(15,6)) +ORDER BY value; +GO +~~START~~ +numeric +1.230000 +2.345600 +3.456789 +~~END~~ + + +-- Test Case 75: UNION with negative numbers and zero +SELECT CAST(-1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(0 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(1.23 AS DECIMAL(5,2)) +ORDER BY value; +GO +~~START~~ +numeric +-1.23 +0.00 +1.23 +~~END~~ + + +-- Test Case 75: UNION with large numbers +SELECT CAST(1234567890.12345 AS DECIMAL(20,5)) AS value +UNION ALL +SELECT CAST(9876543210.98765 AS NUMERIC(20,5)) +UNION ALL +SELECT CAST(1111111111.11111 AS DECIMAL(20,5)) +ORDER BY value; +GO +~~START~~ +numeric +1111111111.11111 +1234567890.12345 +9876543210.98765 +~~END~~ + + +-- Test Case 76: UNION with small numbers +SELECT CAST(0.00000123 AS DECIMAL(10,8)) AS value +UNION ALL +SELECT CAST(0.00000456 AS NUMERIC(10,8)) +UNION ALL +SELECT CAST(0.00000789 AS DECIMAL(10,8)) +ORDER BY value; +GO +~~START~~ +numeric +0.00000123 +0.00000456 +0.00000789 +~~END~~ + + +-- Test Case 77: UNION with DECIMAL, NUMERIC, and VARCHAR +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST('7.89' AS VARCHAR(10)) +ORDER BY value; +GO +~~START~~ +numeric +1.2300000000 +4.5600000000 +7.8900000000 +~~END~~ + + +-- Test Case 78: UNION with different integer parts +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(123.45 AS NUMERIC(10,2)) +UNION ALL +SELECT CAST(12345.67 AS DECIMAL(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +123.45 +12345.67 +~~END~~ + + +-- Test Case 79: UNION with extreme values +SELECT CAST(9999999999.99999999 AS DECIMAL(18,8)) AS value +UNION ALL +SELECT CAST(0.00000001 AS NUMERIC(18,8)) +UNION ALL +SELECT CAST(5555555555.55555555 AS DECIMAL(18,8)) +ORDER BY value; +GO +~~START~~ +numeric +1E-8 +5555555555.55555555 +9999999999.99999999 +~~END~~ + + +-- Test Case 80: UNION with NULL values +SELECT CAST(NULL AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(1.23 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(NULL AS DECIMAL(5,2)) +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +1.23 +4.56 +~~END~~ + + +-- Test Case 81: UNION with MONEY type +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(4.56 AS MONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 82: UNION with SMALLMONEY type +SELECT CAST(1.23 AS DECIMAL(6,2)) AS value +UNION ALL +SELECT CAST(4.56 AS SMALLMONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(6,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 83: DECIMAL(38,1) - 37 digits before decimal, 1 after +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(1000000000000000000000000000000000000.0 AS DECIMAL(38,1)) +ORDER BY value; +GO +~~START~~ +numeric +1000000000000000000000000000000000000.0 +1234567890123456789012345678901234567.8 +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 84: DECIMAL(38,2) - 36 digits before decimal, 2 after +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) AS value +UNION ALL +SELECT CAST(999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(100000000000000000000000000000000000.00 AS DECIMAL(38,2)) +ORDER BY value; +GO +~~START~~ +numeric +100000000000000000000000000000000000.00 +123456789012345678901234567890123456.78 +999999999999999999999999999999999999.99 +~~END~~ + + +-- Test Case 85: DECIMAL(38,5) - 33 digits before decimal, 5 after +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) AS value +UNION ALL +SELECT CAST(99999999999999999999999999999999.99999 AS DECIMAL(38,5)) +UNION ALL +SELECT CAST(10000000000000000000000000000000.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +10000000000000000000000000000000.00001 +12345678901234567890123456789012.34567 +99999999999999999999999999999999.99999 +~~END~~ + + +-- Test Case 86: Mixing different scales with precision 38 +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.7 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 88: Very small fractional part with precision 38 +SELECT CAST(9999999999999999999999999999999999999.1 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.01 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 89: Overflow scenarios with precision 38 +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(10000000000000000000000000000000000000.0 AS DECIMAL(38,1)) -- This will cause an overflow +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 90: Mixing DECIMAL and NUMERIC with precision 38 and small scales +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS NUMERIC(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.8 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 91: NULL values with precision 38 and small scales +SELECT CAST(NULL AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(NULL AS NUMERIC(38,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 92: customer query +DECLARE @test_int int = 1; +SELECT a.integer_one, a.integer_two, +ratio = a.integer_one / CONVERT(DECIMAL, a.integer_two), +ratio_case_one = CASE WHEN a.integer_two = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_two = CASE WHEN 1 = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_three = CASE WHEN @test_int = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END +FROM BABEL_5341_T2 a; +GO +~~START~~ +int#!#int#!#numeric#!#numeric#!#numeric#!#numeric +1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 +~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index 7229a7cee0..130dcee418 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -13730,21 +13730,6 @@ smalldatetime ~~END~~ -SELECT CASE 2 - WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) - WHEN 2 THEN CAST(GETDATE() AS DATE) - WHEN 3 THEN CAST(GETDATE() AS TIME) - WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) - WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) - WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) -END AS Result -GO -~~START~~ -smalldatetime -2024-12-06 00:00:00.0 -~~END~~ - - -- Test Case 42: NUMERIC and TINYINT SELECT CASE 1 WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) @@ -13805,7 +13790,7 @@ END AS RESULT GO ~~START~~ numeric -99.99 +99.9900000000 ~~END~~ @@ -13835,7 +13820,7 @@ END AS RESULT GO ~~START~~ numeric -49382.7161 +49382.7161000000 ~~END~~ @@ -13850,7 +13835,7 @@ END AS RESULT GO ~~START~~ numeric -12345.68 +12345.6800000000 ~~END~~ @@ -13865,7 +13850,7 @@ END AS RESULT GO ~~START~~ numeric -99.9900 +99.9900000000 ~~END~~ @@ -13896,7 +13881,7 @@ FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) GO ~~START~~ numeric -600.0000 +600.0000000000 ~~END~~ @@ -13911,7 +13896,7 @@ END AS RESULT GO ~~START~~ numeric -1000 +1000.0000000000 ~~END~~ @@ -13941,7 +13926,7 @@ END AS RESULT GO ~~START~~ numeric -9876.54 +9876.5400 ~~END~~ @@ -13971,7 +13956,7 @@ END AS RESULT GO ~~START~~ numeric -1234568.8901000000 +1234568.9 ~~END~~ @@ -13986,3 +13971,564 @@ GO DROP TYPE SmallDecimalType_BABEL_5341; GO + +-- test cases +-- Test Case 57: Basic DECIMAL and NUMERIC mix +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1))), + (CAST(2.2 AS NUMERIC(3,1))), + (CAST(3.3 AS DECIMAL(3,1))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +2.2 +3.3 +~~END~~ + + +-- Test Case 58: Different precisions and scales +SELECT * FROM (VALUES + (CAST(1.23456 AS DECIMAL(6,5))), + (CAST(23.4567 AS NUMERIC(6,4))), + (CAST(345.678 AS DECIMAL(6,3))), + (CAST(4567.89 AS NUMERIC(6,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23456 +23.45670 +345.67800 +4567.89000 +~~END~~ + + +-- Test Case 59: Large precisions +SELECT * FROM (VALUES + (CAST(1234567890123456789.1234567890 AS DECIMAL(38,10))), + (CAST(9876543210987654321.0987654321 AS NUMERIC(38,10))), + (CAST(1111111111111111111.1111111111 AS DECIMAL(38,10))) +) AS "VALUES"; +GO +~~START~~ +numeric +1234567890123456789.1234567890 +9876543210987654321.0987654321 +1111111111111111111.1111111111 +~~END~~ + + +-- Test Case 60: Small scales +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(38,1))), + (CAST(22.22 AS NUMERIC(38,2))), + (CAST(333.333 AS DECIMAL(38,3))), + (CAST(4444.4444 AS NUMERIC(38,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +22.2 +333.3 +4444.4 +~~END~~ + + +-- Test Case 61: Mix of positive and negative numbers +SELECT * FROM (VALUES + (CAST(-1.23 AS DECIMAL(5,2))), + (CAST(4.56 AS NUMERIC(5,2))), + (CAST(-7.89 AS DECIMAL(5,2))), + (CAST(0.12 AS NUMERIC(5,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +-1.23 +4.56 +-7.89 +0.12 +~~END~~ + + +-- Test Case 62: Very small numbers +SELECT * FROM (VALUES + (CAST(0.000000000123 AS DECIMAL(15,12))), + (CAST(0.000000000456 AS NUMERIC(15,12))), + (CAST(0.000000000789 AS DECIMAL(15,12))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23E-10 +4.56E-10 +7.89E-10 +~~END~~ + + +-- Test Case 63: Very large numbers +SELECT * FROM (VALUES + (CAST(123456789012345678901234567890.12 AS DECIMAL(38,2))), + (CAST(987654321098765432109876543210.98 AS NUMERIC(38,2))), + (CAST(111111111111111111111111111111.11 AS DECIMAL(38,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +123456789012345678901234567890.12 +987654321098765432109876543210.98 +111111111111111111111111111111.11 +~~END~~ + + +-- Test Case 64: Mix of integer and fractional parts +SELECT * FROM (VALUES + (CAST(1 AS DECIMAL(38,0))), + (CAST(2.2 AS NUMERIC(38,1))), + (CAST(3.33 AS DECIMAL(38,2))), + (CAST(4.444 AS NUMERIC(38,3))) +) AS "VALUES"; +GO +~~START~~ +numeric +1 +2 +3 +4 +~~END~~ + + +-- Test Case 65: Edge cases +SELECT * FROM (VALUES + (CAST(0.9999999999999999999999999999999999999 AS DECIMAL(38,37))), + (CAST(9.999999999999999999999999999999999999 AS NUMERIC(38,36))), + (CAST(0.0000000000000000000000000000000000001 AS DECIMAL(38,37))) +) AS "VALUES"; +GO +~~START~~ +numeric +0.999999999999999999999999999999999999 +9.999999999999999999999999999999999999 +0E-36 +~~END~~ + + +-- Test Case 66: Mix of DECIMAL and NUMERIC with different precisions +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(5,1))), + (CAST(2.22 AS NUMERIC(10,2))), + (CAST(3.333 AS DECIMAL(15,3))), + (CAST(4.4444 AS NUMERIC(20,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1000 +2.2200 +3.3330 +4.4444 +~~END~~ + + +-- Test Case 67: Mix of numeric, decimal, integer, and varchar +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), 10, 'ABC'), + (CAST(2.2 AS NUMERIC(3,1)), 20, 'DEF'), + (CAST(3.3 AS DECIMAL(3,1)), 30, 'GHI') +) AS "VALUES" (dec_num, int_num, str_val); +GO +~~START~~ +numeric#!#int#!#varchar +1.1#!#10#!#ABC +2.2#!#20#!#DEF +3.3#!#30#!#GHI +~~END~~ + + +-- Test Case 68: Mix with date, time, and boolean +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(4,2)), CAST('2023-01-01' AS DATE), CAST('10:30:00' AS TIME), TRUE), + (CAST(4.56 AS NUMERIC(4,2)), CAST('2023-02-15' AS DATE), CAST('14:45:00' AS TIME), FALSE), + (CAST(7.89 AS DECIMAL(4,2)), CAST('2023-03-30' AS DATE), CAST('20:15:00' AS TIME), TRUE) +) AS "VALUES" (num_val, date_val, time_val, bool_val); +GO +~~START~~ +numeric#!#date#!#time#!#bit +1.23#!#2023-01-01#!#10:30:00.0000000#!#1 +4.56#!#2023-02-15#!#14:45:00.0000000#!#0 +7.89#!#2023-03-30#!#20:15:00.0000000#!#1 +~~END~~ + + +-- Test Case 69: Mix with timestamp and interval +SELECT * FROM (VALUES + (CAST(123.45 AS DECIMAL(5,2)), CAST('2023-01-01 12:00:00' AS TIMESTAMP), CAST('1 day' AS INTERVAL)), + (CAST(678.90 AS NUMERIC(5,2)), CAST('2023-06-15 18:30:00' AS TIMESTAMP), CAST('2 hours' AS INTERVAL)), + (CAST(246.80 AS DECIMAL(5,2)), CAST('2023-12-31 23:59:59' AS TIMESTAMP), CAST('30 minutes' AS INTERVAL)) +) AS "VALUES" (num_val, ts_val, interval_val); +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: To use the TIMESTAMP datatype, set 'babelfishpg_tsql.escape_hatch_rowversion' to 'ignore')~~ + + +-- Test Case 70: Mix with char, varchar, and text +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), CAST('A' AS CHAR(1)), CAST('ABC' AS VARCHAR(10)), 'This is a text'), + (CAST(2.2 AS NUMERIC(3,1)), CAST('B' AS CHAR(1)), CAST('DEF' AS VARCHAR(10)), 'Another text'), + (CAST(3.3 AS DECIMAL(3,1)), CAST('C' AS CHAR(1)), CAST('GHI' AS VARCHAR(10)), 'Yet another text') +) AS "VALUES" (num_val, char_val, varchar_val, text_val); +GO +~~START~~ +numeric#!#char#!#varchar#!#varchar +1.1#!#A#!#ABC#!#This is a text +2.2#!#B#!#DEF#!#Another text +3.3#!#C#!#GHI#!#Yet another text +~~END~~ + + +-- Test Case 71: Mix with money and bit +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(3,2)), CAST(100.00 AS MONEY), CAST('1' AS BIT)), + (CAST(4.56 AS NUMERIC(3,2)), CAST(200.50 AS MONEY), CAST('0' AS BIT)), + (CAST(7.89 AS DECIMAL(3,2)), CAST(350.75 AS MONEY), CAST('1' AS BIT)) +) AS "VALUES" (num_val, money_val, bit_val); +GO +~~START~~ +numeric#!#money#!#bit +1.23#!#100.0000#!#1 +4.56#!#200.5000#!#0 +7.89#!#350.7500#!#1 +~~END~~ + + +-- Test Case 72: UNION with DECIMAL and INTEGER +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT 456 +ORDER BY value; +GO +~~START~~ +numeric +1.23 +456.00 +~~END~~ + + +-- Test Case 73: UNION with NUMERIC, DECIMAL, and FLOAT +SELECT CAST(1.23456 AS NUMERIC(10,5)) AS value +UNION ALL +SELECT CAST(2.34567 AS DECIMAL(10,5)) +UNION ALL +SELECT CAST(3.45678 AS FLOAT) +ORDER BY value; +GO +~~START~~ +float +1.23456 +2.34567 +3.45678 +~~END~~ + + +-- Test Case 74: UNION with different precisions and scales +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(2.3456 AS NUMERIC(10,4)) +UNION ALL +SELECT CAST(3.456789 AS DECIMAL(15,6)) +ORDER BY value; +GO +~~START~~ +numeric +1.230000 +2.345600 +3.456789 +~~END~~ + + +-- Test Case 75: UNION with negative numbers and zero +SELECT CAST(-1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(0 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(1.23 AS DECIMAL(5,2)) +ORDER BY value; +GO +~~START~~ +numeric +-1.23 +0.00 +1.23 +~~END~~ + + +-- Test Case 75: UNION with large numbers +SELECT CAST(1234567890.12345 AS DECIMAL(20,5)) AS value +UNION ALL +SELECT CAST(9876543210.98765 AS NUMERIC(20,5)) +UNION ALL +SELECT CAST(1111111111.11111 AS DECIMAL(20,5)) +ORDER BY value; +GO +~~START~~ +numeric +1111111111.11111 +1234567890.12345 +9876543210.98765 +~~END~~ + + +-- Test Case 76: UNION with small numbers +SELECT CAST(0.00000123 AS DECIMAL(10,8)) AS value +UNION ALL +SELECT CAST(0.00000456 AS NUMERIC(10,8)) +UNION ALL +SELECT CAST(0.00000789 AS DECIMAL(10,8)) +ORDER BY value; +GO +~~START~~ +numeric +0.00000123 +0.00000456 +0.00000789 +~~END~~ + + +-- Test Case 77: UNION with DECIMAL, NUMERIC, and VARCHAR +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST('7.89' AS VARCHAR(10)) +ORDER BY value; +GO +~~START~~ +numeric +1.2300000000 +4.5600000000 +7.8900000000 +~~END~~ + + +-- Test Case 78: UNION with different integer parts +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(123.45 AS NUMERIC(10,2)) +UNION ALL +SELECT CAST(12345.67 AS DECIMAL(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +123.45 +12345.67 +~~END~~ + + +-- Test Case 79: UNION with extreme values +SELECT CAST(9999999999.99999999 AS DECIMAL(18,8)) AS value +UNION ALL +SELECT CAST(0.00000001 AS NUMERIC(18,8)) +UNION ALL +SELECT CAST(5555555555.55555555 AS DECIMAL(18,8)) +ORDER BY value; +GO +~~START~~ +numeric +1E-8 +5555555555.55555555 +9999999999.99999999 +~~END~~ + + +-- Test Case 80: UNION with NULL values +SELECT CAST(NULL AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(1.23 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(NULL AS DECIMAL(5,2)) +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +1.23 +4.56 +~~END~~ + + +-- Test Case 81: UNION with MONEY type +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(4.56 AS MONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 82: UNION with SMALLMONEY type +SELECT CAST(1.23 AS DECIMAL(6,2)) AS value +UNION ALL +SELECT CAST(4.56 AS SMALLMONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(6,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 83: DECIMAL(38,1) - 37 digits before decimal, 1 after +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(1000000000000000000000000000000000000.0 AS DECIMAL(38,1)) +ORDER BY value; +GO +~~START~~ +numeric +1000000000000000000000000000000000000.0 +1234567890123456789012345678901234567.8 +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 84: DECIMAL(38,2) - 36 digits before decimal, 2 after +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) AS value +UNION ALL +SELECT CAST(999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(100000000000000000000000000000000000.00 AS DECIMAL(38,2)) +ORDER BY value; +GO +~~START~~ +numeric +100000000000000000000000000000000000.00 +123456789012345678901234567890123456.78 +999999999999999999999999999999999999.99 +~~END~~ + + +-- Test Case 85: DECIMAL(38,5) - 33 digits before decimal, 5 after +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) AS value +UNION ALL +SELECT CAST(99999999999999999999999999999999.99999 AS DECIMAL(38,5)) +UNION ALL +SELECT CAST(10000000000000000000000000000000.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +10000000000000000000000000000000.00001 +12345678901234567890123456789012.34567 +99999999999999999999999999999999.99999 +~~END~~ + + +-- Test Case 86: Mixing different scales with precision 38 +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.7 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 88: Very small fractional part with precision 38 +SELECT CAST(9999999999999999999999999999999999999.1 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.01 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 89: Overflow scenarios with precision 38 +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(10000000000000000000000000000000000000.0 AS DECIMAL(38,1)) -- This will cause an overflow +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 90: Mixing DECIMAL and NUMERIC with precision 38 and small scales +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS NUMERIC(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.8 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 91: NULL values with precision 38 and small scales +SELECT CAST(NULL AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(NULL AS NUMERIC(38,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 92: customer query +DECLARE @test_int int = 1; +SELECT a.integer_one, a.integer_two, +ratio = a.integer_one / CONVERT(DECIMAL, a.integer_two), +ratio_case_one = CASE WHEN a.integer_two = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_two = CASE WHEN 1 = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_three = CASE WHEN @test_int = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END +FROM BABEL_5341_T2 a; +GO +~~START~~ +int#!#int#!#numeric#!#numeric#!#numeric#!#numeric +1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 +~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out new file mode 100644 index 0000000000..758f59983b --- /dev/null +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out @@ -0,0 +1,14534 @@ +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +-- Function call +SELECT BABEL_5103_F1('REGULAR'); +GO +~~START~~ +nvarchar +REGULAR +~~END~~ + + +SELECT BABEL_5103_F1(N'登録カード–標準'); +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT BABEL_5103_F1(N'بطاقة التسجيل - قياسية'); +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +-- selecting from view +SELECT * FROM BABEL_5103_V2 +GO +~~START~~ +nvarchar +登録カード +~~END~~ + + +-- single branch +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + +-- single branch with multibyte character +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being CHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS Char(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS Char(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being TEXT +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS TEXT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS TEXT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch with one being string literal +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branches one being NULL +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- NULL tests +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +-- other datatypes then string +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO +~~START~~ +numeric +123.00 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123.456 AS FLOAT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO +~~START~~ +float +123.456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO +~~START~~ +bigint +123 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO +~~START~~ +numeric +123.00 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123.456 AS BIGINT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO +~~START~~ +numeric +123.000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO +~~START~~ +bigint +123 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('2024-01-01' AS DATE) + WHEN 2 THEN CAST('2024-09-27 12:34:56' AS DATETIME) +END AS RESULT +GO +~~START~~ +datetime +2024-01-01 00:00:00.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('12:34:56' AS TIME) + WHEN 2 THEN CAST('2024-09-27 12:34:56.1234567' AS DATETIME2(7)) +END AS RESULT +GO +~~START~~ +datetime2 +1900-01-01 12:34:56.0000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1 AS BIT) + WHEN 2 THEN CAST(0 AS BIT) +END AS RESULT +GO +~~START~~ +bit +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BINARY(3)) + WHEN 2 THEN CAST(0xABCDEF AS VARBINARY(6)) +END AS RESULT +GO +~~START~~ +varbinary +123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1000.00 AS MONEY) + WHEN 2 THEN CAST(100.00 AS SMALLMONEY) +END AS RESULT +GO +~~START~~ +money +1000.0000 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO +~~START~~ +numeric +456.00 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123.456 AS FLOAT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO +~~START~~ +float +789.123 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO +~~START~~ +bigint +456789123 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO +~~START~~ +numeric +456.00 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123.456 AS BIGINT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO +~~START~~ +numeric +789.123 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO +~~START~~ +bigint +456789123 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('2024-01-01' AS DATE) + WHEN 2 THEN CAST('2024-09-27 12:34:56' AS DATETIME) +END AS RESULT +GO +~~START~~ +datetime +2024-09-27 12:34:56.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('12:34:56' AS TIME) + WHEN 2 THEN CAST('2024-09-27 12:34:56.1234567' AS DATETIME2(7)) +END AS RESULT +GO +~~START~~ +datetime2 +2024-09-27 12:34:56.1234570 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1 AS BIT) + WHEN 2 THEN CAST(0 AS BIT) +END AS RESULT +GO +~~START~~ +bit +0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BINARY(3)) + WHEN 2 THEN CAST(0xABCDEF AS VARBINARY(6)) +END AS RESULT +GO +~~START~~ +varbinary +ABCDEF +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1000.00 AS MONEY) + WHEN 2 THEN CAST(100.00 AS SMALLMONEY) +END AS RESULT +GO +~~START~~ +money +100.0000 +~~END~~ + + + +-- Collation tests +-- FIX ME: Following test cases shows behaviour mismatch, +-- When we compare N' 比尔·拉莫斯 ' COLLATE japanese_ci_as +-- with N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS for CASE expression, +-- Gives 'true' (as used in PG), whereas it should give 'false' (as in TSQL). +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS +END AS RESULT +GO +~~START~~ +varchar +abcd +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE japanese_ci_as + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as +END AS RESULT +GO +~~START~~ +varchar + abc?defghi?? +~~END~~ + + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE japanese_ci_as + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE ARABIC_CI_AS + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS +END AS RESULT +GO +~~START~~ +varchar + abc?defghi?? +~~END~~ + + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS +END AS RESULT +GO +~~START~~ +varchar +abcd +~~END~~ + + +--- SYSNAME tests +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +--- UDT testing +create type BABEL_CASE_EXPR_TEST_UDT from NVARCHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from sysname; +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + + +create type BABEL_CASE_EXPR_TEST_UDT from VARCHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from CHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +char +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +char +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +char +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from NCHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from TEXT; +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from NTEXT; +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- multiple branch one being Binary +create type BABEL_CASE_EXPR_TEST_UDT from BINARY(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 0x123456 +END AS RESULT +GO +~~START~~ +varbinary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 0x123456 +END AS RESULT +GO +~~START~~ +varbinary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 0x123456 + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varbinary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- multiple branch one being VARBINARY +create type BABEL_CASE_EXPR_TEST_UDT from VARBINARY(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varbinary +123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varbinary +123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varbinary +123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- multiple UDT branches +create type BABEL_CASE_EXPR_TEST_UDT0 from NVARCHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT1 from NCHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT2 from CHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT3 from VARCHAR(100); +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT0; +go + +drop type BABEL_CASE_EXPR_TEST_UDT1; +go + +drop type BABEL_CASE_EXPR_TEST_UDT2; +go + +drop type BABEL_CASE_EXPR_TEST_UDT3; +go + +-- Numeric datatypes +create type BABEL_CASE_EXPR_TEST_UDT0 from INT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT1 from DECIMAL; +GO + +create type BABEL_CASE_EXPR_TEST_UDT2 from FLOAT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT3 from BIT; +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(2.300 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +2.3 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +int +0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(12.3 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(1 AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +int +1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(1.345 AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(1321 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +bit +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST(1.234 AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +numeric +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(1235 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.345 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(234.234 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(346 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(04545 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(12.4 AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +numeric +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(1 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST(234.234 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type babel_case_expr_test_udt3 to double precision)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type babel_case_expr_test_udt2 to "bit")~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(123.3 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(546 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +numeric +123 +~~END~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(54 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.123 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +54.0 +~~END~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(23 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(6356 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +numeric +23 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(3456.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 3 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type babel_case_expr_test_udt3 to double precision)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(23.12 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(2354 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +float +23.0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT0; +go + +drop type BABEL_CASE_EXPR_TEST_UDT1; +go + +drop type BABEL_CASE_EXPR_TEST_UDT2; +go + +drop type BABEL_CASE_EXPR_TEST_UDT3; +go + +-- Mixture of numeric and string types +create type BABEL_CASE_EXPR_TEST_UDT0 from INT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT1 from NCHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT2 from FLOAT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT3 from VARCHAR(100); +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(2.300 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +2.3 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "登録カード–標準")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "登録カード–標準")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "登録カード–標準 ")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(1321 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +int +1321 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(1235 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.345 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(346 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(04545 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST(234.234 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(546 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(54 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.123 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(6356 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(3456.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +float +3456.34 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(2354 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "char0 ")~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT0; +go + +drop type BABEL_CASE_EXPR_TEST_UDT1; +go + +drop type BABEL_CASE_EXPR_TEST_UDT2; +go + +drop type BABEL_CASE_EXPR_TEST_UDT3; +go + +-- Mixture of datatypes and numeric without UDT +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(2.300 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +2.3 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS INT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "登録カード–標準")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS INT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "登録カード–標準")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS FLOAT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "登録カード–標準 ")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(1321 AS INT) +END AS RESULT +GO +~~START~~ +int +1321 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(1235 AS INT) + WHEN 3 THEN CAST(0.345 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(346 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(04545 AS INT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(234.234 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(546 AS INT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(54 AS INT) + WHEN 3 THEN CAST(0.123 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(6356 AS INT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS INT) + WHEN 2 THEN CAST(3456.34 AS FLOAT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +float +3456.34 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS FLOAT) + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(2354 AS INT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "char0 ")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(2.300 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +2.3 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS INT) + WHEN 2 THEN CAST(0 AS BIT) +END AS RESULT +GO +~~START~~ +int +0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(12.3 AS DECIMAL) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS INT) + WHEN 2 THEN CAST(1 AS BIT) +END AS RESULT +GO +~~START~~ +int +1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS FLOAT) + WHEN 2 THEN CAST(1.345 AS DECIMAL) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1 AS BIT) + WHEN 2 THEN CAST(1321 AS INT) +END AS RESULT +GO +~~START~~ +bit +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(0 AS BIT) + WHEN 3 THEN CAST(1.234 AS DECIMAL) +END AS RESULT +GO +~~START~~ +numeric +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(1235 AS INT) + WHEN 3 THEN CAST(0.345 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(234.234 AS DECIMAL) + WHEN 3 THEN CAST(346 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(04545 AS INT) + WHEN 3 THEN CAST(12.4 AS DECIMAL) +END AS RESULT +GO +~~START~~ +numeric +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(1 AS BIT) + WHEN 3 THEN CAST(234.234 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "bit" to double precision)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0 AS BIT) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type double precision to "bit")~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(123.3 AS DECIMAL) + WHEN 3 THEN CAST(546 AS INT) +END AS RESULT +GO +~~START~~ +numeric +123 +~~END~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(54 AS INT) + WHEN 3 THEN CAST(0.123 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +54.0 +~~END~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(23 AS DECIMAL) + WHEN 3 THEN CAST(6356 AS INT) +END AS RESULT +GO +~~START~~ +numeric +23 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS INT) + WHEN 2 THEN CAST(3456.34 AS FLOAT) + WHEN 3 THEN CAST(0 AS BIT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "bit" to double precision)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS FLOAT) + WHEN 2 THEN CAST(23.12 AS DECIMAL) + WHEN 3 THEN CAST(2354 AS INT) +END AS RESULT +GO +~~START~~ +float +23.0 +~~END~~ + + +-- UDT on varchar(max) +create type BABEL_CASE_EXPR_TEST_UDT from varchar(max); +go + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +varchar +a +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +varchar +a +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- UDT on nvarchar(max) +create type BABEL_CASE_EXPR_TEST_UDT from nvarchar(max); +go + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +nvarchar +a +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +nvarchar +a +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- With max typmod +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS VARCHAR(MAX)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nchar +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nchar +N +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +N +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +N +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +N +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO +~~START~~ +text +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +NCHAR +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO +~~START~~ +text +NCHAR +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO +~~START~~ +text +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +NCHAR +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO +~~START~~ +text +NCHAR +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (4000) for 'nchar' datatype.)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (4000) for 'nchar' datatype.)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (4000) for 'nchar' datatype.)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (4000) for 'nchar' datatype.)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + + +-- Testing for numeric and decimal +-- Test Case 1: Basic CASE with 6 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 0 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 2: CASE with 5 columns and ELSE +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +99 +50 +22 +44 +66 +~~END~~ + + +-- Test Case 3: CASE with 4 columns and ELSE +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + ELSE COL5 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +42 +10 +11 +33 +55 +~~END~~ + + +-- Test Case 4: CASE with 3 columns and ELSE +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + ELSE COL4 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 5: CASE with 2 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + ELSE COL3 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 6: CASE with 1 column and ELSE +SELECT CASE 2 + WHEN 1 THEN COL1 + ELSE COL2 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +54321.98 +12345.67 +22222.22 +44444.44 +66666.66 +~~END~~ + + +-- Test Case 7: CASE with all columns returning a constant value +SELECT CASE 7 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 999.99 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1000 +1000 +1000 +1000 +1000 +~~END~~ + + +-- Test Case 8: CASE with mixed constant and column values +SELECT CASE 4 + WHEN 1 THEN 100 + WHEN 2 THEN COL2 + WHEN 3 THEN 300 + WHEN 4 THEN COL4 + WHEN 5 THEN 500 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 9: CASE with views +SELECT * FROM BABEL_5341_V1; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +SELECT * FROM BABEL_5341_V2; +GO +~~START~~ +numeric +6789 +~~END~~ + + +SELECT * FROM BABEL_5341_V3; +GO +~~START~~ +numeric +1234567890123456 +~~END~~ + + +SELECT * FROM BABEL_5341_V4; +GO +~~START~~ +numeric +0.0003 +~~END~~ + + +SELECT * FROM BABEL_5341_V5; +GO +~~START~~ +numeric +678.90 +~~END~~ + + +SELECT * FROM BABEL_5341_V6; +GO +~~START~~ +numeric +1250.00 +~~END~~ + + +-- Test Case 10: Using the function +SELECT BABEL_5341_F1(100.00); +GO +~~START~~ +numeric +123.4500 +~~END~~ + + +SELECT BABEL_5341_F1(200.00); +GO +~~START~~ +numeric +6789.0000 +~~END~~ + + +SELECT BABEL_5341_F1(300.00); +GO +~~START~~ +numeric +12.3456 +~~END~~ + + +SELECT BABEL_5341_F1(400.00); +GO +~~START~~ +numeric +400.0000 +~~END~~ + + +-- Test Case 11: Basic DECIMAL and NUMERIC usage +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +1234567.89000000 +~~END~~ + + +-- Test Case 12: Different scales within the same precision +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.43 AS DECIMAL(10,2)) + WHEN 3 THEN CAST(123456.7 AS DECIMAL(10,1)) + WHEN 4 THEN CAST(1234567 AS DECIMAL(10,0)) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS RESULT +GO +~~START~~ +numeric +98765.4300 +~~END~~ + + +-- Test Case 13: Mixing DECIMAL and NUMERIC with different precisions +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(12,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(15,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +9.87654321 +~~END~~ + + +-- Test Case 14: Large precisions and scales +SELECT CASE 2 + WHEN 1 THEN CAST(12345678901234567890.1234567890 AS DECIMAL(30,10)) + WHEN 2 THEN CAST(98765432109876543210.9876543210 AS NUMERIC(30,10)) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS DECIMAL(25,10)) + WHEN 4 THEN CAST(9.8765432109876543210 AS NUMERIC(20,19)) + ELSE CAST(0 AS DECIMAL(30,10)) +END AS RESULT +GO +~~START~~ +numeric +98765432109876543210.987654321000000000 +~~END~~ + + +-- Test Case 15: Small fractional parts +SELECT CASE 3 + WHEN 1 THEN CAST(12345.000001 AS DECIMAL(12,6)) + WHEN 2 THEN CAST(98765.0000001 AS NUMERIC(14,7)) + WHEN 3 THEN CAST(1234567.0000000001 AS DECIMAL(18,10)) + WHEN 4 THEN CAST(9.000000000000001 AS NUMERIC(17,15)) + ELSE CAST(0.00000001 AS DECIMAL(10,8)) +END AS RESULT +GO +~~START~~ +numeric +1234567.000000000100000 +~~END~~ + + +-- Test Case 16: Negative numbers +SELECT CASE 2 + WHEN 1 THEN CAST(-12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(-98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(-1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(-9.87654321 AS NUMERIC(9,8)) + ELSE CAST(-0.01 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +-98765.43210000 +~~END~~ + + +-- Test Case 17: Potential overflow scenarios +SELECT CASE 3 + WHEN 1 THEN CAST(99999.9999 AS DECIMAL(9,4)) + WHEN 2 THEN CAST(999999.999 AS NUMERIC(9,3)) + WHEN 3 THEN CAST(9999999.99 AS DECIMAL(9,2)) + WHEN 4 THEN CAST(99999999.9 AS NUMERIC(9,1)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT +GO +~~START~~ +numeric +9999999.9900 +~~END~~ + + +-- Test Case 18: Mixing with other numeric types +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765 AS INT) + WHEN 3 THEN CAST(1234567.89 AS FLOAT) + WHEN 4 THEN CAST(9 AS BIGINT) + ELSE CAST(0 AS NUMERIC(5,2)) +END AS RESULT +GO +~~START~~ +float +9.0 +~~END~~ + + + +-- Test Case 19: NUMERIC, DATETIME, and SQL_VARIANT in different branches +DECLARE @var SQL_VARIANT +SET @var = CAST(12345.6789 AS NUMERIC(10,4)) +SELECT CASE + WHEN CAST('2023-05-15' AS DATETIME) > '2023-01-01' THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN @var > 10000 THEN CAST('2023-12-31' AS DATETIME) + WHEN YEAR(GETDATE()) = 2023 THEN @var + ELSE CAST(11111.1111 AS NUMERIC(10,4)) +END AS RESULT +GO +~~START~~ +sql_variant +98765.4321 +~~END~~ + + + +-- Test Case 20: NUMERIC with different precisions, DATETIME, and SQL_VARIANT +DECLARE @var SQL_VARIANT +SET @var = CAST(123456.789 AS NUMERIC(15,3)) +SELECT CASE + WHEN CAST(12345.6789 AS NUMERIC(10,4)) > 10000 THEN CAST(9876543.21 AS NUMERIC(15,2)) + WHEN CAST('2023-05-15' AS DATETIME) < GETDATE() THEN CAST(123.456789 AS NUMERIC(9,6)) + WHEN SQL_VARIANT_PROPERTY(@var, 'Scale') > 2 THEN CAST(GETDATE() AS DATETIME) + ELSE @var +END AS RESULT +GO +~~START~~ +sql_variant +9876543.21 +~~END~~ + + +-- Test Case 21: SQL_VARIANT from BIGINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9223372036854775807 AS BIGINT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 22: SQL_VARIANT from DECIMAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(123.456 AS DECIMAL(10,3)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 23: SQL_VARIANT from FLOAT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(3.14159265359 AS FLOAT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 24: SQL_VARIANT from CHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('A' AS CHAR(1)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 25: SQL_VARIANT from VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('Hello, World!' AS VARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 26: SQL_VARIANT from NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(N'こんにちは' AS NVARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 27: SQL_VARIANT from DATE +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15' AS DATE) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 28: SQL_VARIANT from TIME +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('14:30:00' AS TIME) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 29: SQL_VARIANT from DATETIME2 +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00.1234567' AS DATETIME2(7)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 30: SQL_VARIANT from DATETIMEOFFSET +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00 +01:00' AS DATETIMEOFFSET) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 31: SQL_VARIANT from BIT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1 AS BIT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 32: SQL_VARIANT from UNIQUEIDENTIFIER +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(NEWID() AS UNIQUEIDENTIFIER) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 33: SQL_VARIANT from VARBINARY +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0x1234567890 AS VARBINARY(10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 34: SQL_VARIANT from NUMERIC(10,2) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567.89 AS NUMERIC(10,2)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 35: SQL_VARIANT from NUMERIC(5,4) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.1234 AS NUMERIC(5,4)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 36: SQL_VARIANT from NUMERIC(20,10) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567890.1234567890 AS NUMERIC(20,10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 37: SQL_VARIANT from NUMERIC(38,0) (maximum precision, no decimal places) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(12345678901234567890123456789012345678 AS NUMERIC(38,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 38: SQL_VARIANT from NUMERIC(38,38) (maximum precision and scale) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.12345678901234567890123456789012345678 AS NUMERIC(38,38)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 39: SQL_VARIANT from NUMERIC(1,0) (minimum precision) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9 AS NUMERIC(1,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 40: SQL_VARIANT from negative NUMERIC +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(-9876.54321 AS NUMERIC(10,5)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 41: Numeric branch with time +select case 1 + when 1 then cast(1.23 as numeric(20,2)) + when 2 then cast(1900-01-01 as datetime) +END +go +~~START~~ +datetime +1900-01-02 05:31:12.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type date to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('12:34:56' AS TIME) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type time without time zone to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetime2 to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetimeoffset to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-02 05:31:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) + WHEN 3 THEN CAST('12:34:56' AS TIME) + WHEN 4 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) + WHEN 5 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) + WHEN 6 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-01 00:00:00.0 +~~END~~ + + +-- Test Case 42: NUMERIC and TINYINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(255 AS TINYINT) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Test Case 43: NUMERIC and REAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(3.14 AS REAL) +END AS Result +GO +~~START~~ +real +1.23 +~~END~~ + + +-- Test Case 44: NUMERIC and NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(N'A' AS NCHAR(1)) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Create UDTs +CREATE TYPE NumericType_BABEL_5341 FROM NUMERIC(20,2); +GO + +CREATE TYPE DecimalType_BABEL_5341 FROM DECIMAL(18,4); +GO + +CREATE TYPE BigNumericType_BABEL_5341 FROM NUMERIC(38,10); +GO + +CREATE TYPE SmallDecimalType_BABEL_5341 FROM DECIMAL(5,2); +GO + +-- Test Case 45: Basic CASE with all UDTs +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.9900000000 +~~END~~ + + +-- Test Case 46: CASE with UDTs and different precisions +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS DecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567890123456.7890123456 +~~END~~ + + +-- Test Case 47: CASE with UDTs and mathematical operations +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 * 2 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 / 2 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 + 1000 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 - 50 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +49382.7161000000 +~~END~~ + + +-- Test Case 48: CASE with UDTs and rounding +SELECT CASE 1 + WHEN 1 THEN CAST(ROUND(12345.6789, 2) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(ROUND(98765.4321, 4) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(ROUND(1234567.8901234567890, 10) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(ROUND(99.99, 1) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345.6800000000 +~~END~~ + + +-- Test Case 49: CASE with UDTs and type conversion +SELECT CASE 4 + WHEN 1 THEN CAST(CAST(12345.6789 AS NumericType_BABEL_5341) AS BigNumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(98765.4321 AS DecimalType_BABEL_5341) AS SmallDecimalType_BABEL_5341) + WHEN 3 THEN CAST(CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) AS NumericType_BABEL_5341) + WHEN 4 THEN CAST(CAST(99.99 AS SmallDecimalType_BABEL_5341) AS DecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.9900000000 +~~END~~ + + +-- Test Case 50: CASE with UDTs and potential overflow +SELECT CASE 3 + WHEN 1 THEN CAST(9999999999999999.99 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(99999999999999.9999 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(12345678901234567890.1234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(999.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345678901234567890.1234567890 +~~END~~ + + +-- Test Case 51: CASE with UDTs and aggregate functions +SELECT CASE 2 + WHEN 1 THEN CAST(AVG(CAST(COLUMN_VALUE AS NumericType_BABEL_5341)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(SUM(CAST(COLUMN_VALUE AS DecimalType_BABEL_5341)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(MAX(CAST(COLUMN_VALUE AS BigNumericType_BABEL_5341)) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(MIN(CAST(COLUMN_VALUE AS SmallDecimalType_BABEL_5341)) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) +GO +~~START~~ +numeric +600.0000000000 +~~END~~ + + +-- Test Case 52: UDTs with INT and BIGINT +SELECT CASE 3 + WHEN 1 THEN CAST(12345 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(9876543210 AS BigNumericType_BABEL_5341) + WHEN 3 THEN CAST(1000 AS INT) + WHEN 4 THEN CAST(9223372036854775807 AS BIGINT) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1000.0000000000 +~~END~~ + + +-- Test Case 53: UDTs with FLOAT and REAL +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS DecimalType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS FLOAT) + WHEN 3 THEN CAST(1234.56 AS REAL) + WHEN 4 THEN CAST(9.87654321 AS NumericType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +float +98765.4321 +~~END~~ + + +-- Test Case 54: UDTs with MONEY and SMALLMONEY +SELECT CASE 4 + WHEN 1 THEN CAST(12345.67 AS MONEY) + WHEN 2 THEN CAST(98.76 AS SMALLMONEY) + WHEN 3 THEN CAST(1234.5678 AS DecimalType_BABEL_5341) + WHEN 4 THEN CAST(9876.54 AS NumericType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +9876.5400 +~~END~~ + + +-- Test Case 55: UDTs with VARCHAR and NVARCHAR +SELECT CASE 3 + WHEN 1 THEN CAST(CAST('12345.67' AS VARCHAR(20)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(N'98765.4321' AS NVARCHAR(20)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST('1234567.8901' AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(N'99.99' AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567.8901000000 +~~END~~ + + +-- Test Case 56: UDTs with BIT and mathematical operations +SELECT CASE 3 + WHEN 1 THEN CAST(1 AS BIT) * CAST(12345.67 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(0 AS BIT) * CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1 AS BIT) + CAST(1234567.8901 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(1 AS BIT) - CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234568.9 +~~END~~ + + +DROP TYPE NumericType_BABEL_5341; +GO + +DROP TYPE DecimalType_BABEL_5341; +GO + +DROP TYPE BigNumericType_BABEL_5341; +GO + +DROP TYPE SmallDecimalType_BABEL_5341; +GO + +-- test cases +-- Test Case 57: Basic DECIMAL and NUMERIC mix +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1))), + (CAST(2.2 AS NUMERIC(3,1))), + (CAST(3.3 AS DECIMAL(3,1))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +2.2 +3.3 +~~END~~ + + +-- Test Case 58: Different precisions and scales +SELECT * FROM (VALUES + (CAST(1.23456 AS DECIMAL(6,5))), + (CAST(23.4567 AS NUMERIC(6,4))), + (CAST(345.678 AS DECIMAL(6,3))), + (CAST(4567.89 AS NUMERIC(6,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23456 +23.45670 +345.67800 +4567.89000 +~~END~~ + + +-- Test Case 59: Large precisions +SELECT * FROM (VALUES + (CAST(1234567890123456789.1234567890 AS DECIMAL(38,10))), + (CAST(9876543210987654321.0987654321 AS NUMERIC(38,10))), + (CAST(1111111111111111111.1111111111 AS DECIMAL(38,10))) +) AS "VALUES"; +GO +~~START~~ +numeric +1234567890123456789.1234567890 +9876543210987654321.0987654321 +1111111111111111111.1111111111 +~~END~~ + + +-- Test Case 60: Small scales +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(38,1))), + (CAST(22.22 AS NUMERIC(38,2))), + (CAST(333.333 AS DECIMAL(38,3))), + (CAST(4444.4444 AS NUMERIC(38,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +22.2 +333.3 +4444.4 +~~END~~ + + +-- Test Case 61: Mix of positive and negative numbers +SELECT * FROM (VALUES + (CAST(-1.23 AS DECIMAL(5,2))), + (CAST(4.56 AS NUMERIC(5,2))), + (CAST(-7.89 AS DECIMAL(5,2))), + (CAST(0.12 AS NUMERIC(5,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +-1.23 +4.56 +-7.89 +0.12 +~~END~~ + + +-- Test Case 62: Very small numbers +SELECT * FROM (VALUES + (CAST(0.000000000123 AS DECIMAL(15,12))), + (CAST(0.000000000456 AS NUMERIC(15,12))), + (CAST(0.000000000789 AS DECIMAL(15,12))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23E-10 +4.56E-10 +7.89E-10 +~~END~~ + + +-- Test Case 63: Very large numbers +SELECT * FROM (VALUES + (CAST(123456789012345678901234567890.12 AS DECIMAL(38,2))), + (CAST(987654321098765432109876543210.98 AS NUMERIC(38,2))), + (CAST(111111111111111111111111111111.11 AS DECIMAL(38,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +123456789012345678901234567890.12 +987654321098765432109876543210.98 +111111111111111111111111111111.11 +~~END~~ + + +-- Test Case 64: Mix of integer and fractional parts +SELECT * FROM (VALUES + (CAST(1 AS DECIMAL(38,0))), + (CAST(2.2 AS NUMERIC(38,1))), + (CAST(3.33 AS DECIMAL(38,2))), + (CAST(4.444 AS NUMERIC(38,3))) +) AS "VALUES"; +GO +~~START~~ +numeric +1 +2 +3 +4 +~~END~~ + + +-- Test Case 65: Edge cases +SELECT * FROM (VALUES + (CAST(0.9999999999999999999999999999999999999 AS DECIMAL(38,37))), + (CAST(9.999999999999999999999999999999999999 AS NUMERIC(38,36))), + (CAST(0.0000000000000000000000000000000000001 AS DECIMAL(38,37))) +) AS "VALUES"; +GO +~~START~~ +numeric +0.999999999999999999999999999999999999 +9.999999999999999999999999999999999999 +0E-36 +~~END~~ + + +-- Test Case 66: Mix of DECIMAL and NUMERIC with different precisions +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(5,1))), + (CAST(2.22 AS NUMERIC(10,2))), + (CAST(3.333 AS DECIMAL(15,3))), + (CAST(4.4444 AS NUMERIC(20,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1000 +2.2200 +3.3330 +4.4444 +~~END~~ + + +-- Test Case 67: Mix of numeric, decimal, integer, and varchar +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), 10, 'ABC'), + (CAST(2.2 AS NUMERIC(3,1)), 20, 'DEF'), + (CAST(3.3 AS DECIMAL(3,1)), 30, 'GHI') +) AS "VALUES" (dec_num, int_num, str_val); +GO +~~START~~ +numeric#!#int#!#varchar +1.1#!#10#!#ABC +2.2#!#20#!#DEF +3.3#!#30#!#GHI +~~END~~ + + +-- Test Case 68: Mix with date, time, and boolean +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(4,2)), CAST('2023-01-01' AS DATE), CAST('10:30:00' AS TIME), TRUE), + (CAST(4.56 AS NUMERIC(4,2)), CAST('2023-02-15' AS DATE), CAST('14:45:00' AS TIME), FALSE), + (CAST(7.89 AS DECIMAL(4,2)), CAST('2023-03-30' AS DATE), CAST('20:15:00' AS TIME), TRUE) +) AS "VALUES" (num_val, date_val, time_val, bool_val); +GO +~~START~~ +numeric#!#date#!#time#!#bit +1.23#!#2023-01-01#!#10:30:00.0000000#!#1 +4.56#!#2023-02-15#!#14:45:00.0000000#!#0 +7.89#!#2023-03-30#!#20:15:00.0000000#!#1 +~~END~~ + + +-- Test Case 69: Mix with timestamp and interval +SELECT * FROM (VALUES + (CAST(123.45 AS DECIMAL(5,2)), CAST('2023-01-01 12:00:00' AS TIMESTAMP), CAST('1 day' AS INTERVAL)), + (CAST(678.90 AS NUMERIC(5,2)), CAST('2023-06-15 18:30:00' AS TIMESTAMP), CAST('2 hours' AS INTERVAL)), + (CAST(246.80 AS DECIMAL(5,2)), CAST('2023-12-31 23:59:59' AS TIMESTAMP), CAST('30 minutes' AS INTERVAL)) +) AS "VALUES" (num_val, ts_val, interval_val); +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: To use the TIMESTAMP datatype, set 'babelfishpg_tsql.escape_hatch_rowversion' to 'ignore')~~ + + +-- Test Case 70: Mix with char, varchar, and text +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), CAST('A' AS CHAR(1)), CAST('ABC' AS VARCHAR(10)), 'This is a text'), + (CAST(2.2 AS NUMERIC(3,1)), CAST('B' AS CHAR(1)), CAST('DEF' AS VARCHAR(10)), 'Another text'), + (CAST(3.3 AS DECIMAL(3,1)), CAST('C' AS CHAR(1)), CAST('GHI' AS VARCHAR(10)), 'Yet another text') +) AS "VALUES" (num_val, char_val, varchar_val, text_val); +GO +~~START~~ +numeric#!#char#!#varchar#!#varchar +1.1#!#A#!#ABC#!#This is a text +2.2#!#B#!#DEF#!#Another text +3.3#!#C#!#GHI#!#Yet another text +~~END~~ + + +-- Test Case 71: Mix with money and bit +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(3,2)), CAST(100.00 AS MONEY), CAST('1' AS BIT)), + (CAST(4.56 AS NUMERIC(3,2)), CAST(200.50 AS MONEY), CAST('0' AS BIT)), + (CAST(7.89 AS DECIMAL(3,2)), CAST(350.75 AS MONEY), CAST('1' AS BIT)) +) AS "VALUES" (num_val, money_val, bit_val); +GO +~~START~~ +numeric#!#money#!#bit +1.23#!#100.0000#!#1 +4.56#!#200.5000#!#0 +7.89#!#350.7500#!#1 +~~END~~ + + +-- Test Case 72: UNION with DECIMAL and INTEGER +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT 456 +ORDER BY value; +GO +~~START~~ +numeric +1.23 +456.00 +~~END~~ + + +-- Test Case 73: UNION with NUMERIC, DECIMAL, and FLOAT +SELECT CAST(1.23456 AS NUMERIC(10,5)) AS value +UNION ALL +SELECT CAST(2.34567 AS DECIMAL(10,5)) +UNION ALL +SELECT CAST(3.45678 AS FLOAT) +ORDER BY value; +GO +~~START~~ +float +1.23456 +2.34567 +3.45678 +~~END~~ + + +-- Test Case 74: UNION with different precisions and scales +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(2.3456 AS NUMERIC(10,4)) +UNION ALL +SELECT CAST(3.456789 AS DECIMAL(15,6)) +ORDER BY value; +GO +~~START~~ +numeric +1.230000 +2.345600 +3.456789 +~~END~~ + + +-- Test Case 75: UNION with negative numbers and zero +SELECT CAST(-1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(0 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(1.23 AS DECIMAL(5,2)) +ORDER BY value; +GO +~~START~~ +numeric +-1.23 +0.00 +1.23 +~~END~~ + + +-- Test Case 75: UNION with large numbers +SELECT CAST(1234567890.12345 AS DECIMAL(20,5)) AS value +UNION ALL +SELECT CAST(9876543210.98765 AS NUMERIC(20,5)) +UNION ALL +SELECT CAST(1111111111.11111 AS DECIMAL(20,5)) +ORDER BY value; +GO +~~START~~ +numeric +1111111111.11111 +1234567890.12345 +9876543210.98765 +~~END~~ + + +-- Test Case 76: UNION with small numbers +SELECT CAST(0.00000123 AS DECIMAL(10,8)) AS value +UNION ALL +SELECT CAST(0.00000456 AS NUMERIC(10,8)) +UNION ALL +SELECT CAST(0.00000789 AS DECIMAL(10,8)) +ORDER BY value; +GO +~~START~~ +numeric +0.00000123 +0.00000456 +0.00000789 +~~END~~ + + +-- Test Case 77: UNION with DECIMAL, NUMERIC, and VARCHAR +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST('7.89' AS VARCHAR(10)) +ORDER BY value; +GO +~~START~~ +numeric +1.2300000000 +4.5600000000 +7.8900000000 +~~END~~ + + +-- Test Case 78: UNION with different integer parts +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(123.45 AS NUMERIC(10,2)) +UNION ALL +SELECT CAST(12345.67 AS DECIMAL(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +123.45 +12345.67 +~~END~~ + + +-- Test Case 79: UNION with extreme values +SELECT CAST(9999999999.99999999 AS DECIMAL(18,8)) AS value +UNION ALL +SELECT CAST(0.00000001 AS NUMERIC(18,8)) +UNION ALL +SELECT CAST(5555555555.55555555 AS DECIMAL(18,8)) +ORDER BY value; +GO +~~START~~ +numeric +1E-8 +5555555555.55555555 +9999999999.99999999 +~~END~~ + + +-- Test Case 80: UNION with NULL values +SELECT CAST(NULL AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(1.23 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(NULL AS DECIMAL(5,2)) +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +1.23 +4.56 +~~END~~ + + +-- Test Case 81: UNION with MONEY type +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(4.56 AS MONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 82: UNION with SMALLMONEY type +SELECT CAST(1.23 AS DECIMAL(6,2)) AS value +UNION ALL +SELECT CAST(4.56 AS SMALLMONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(6,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 83: DECIMAL(38,1) - 37 digits before decimal, 1 after +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(1000000000000000000000000000000000000.0 AS DECIMAL(38,1)) +ORDER BY value; +GO +~~START~~ +numeric +1000000000000000000000000000000000000.0 +1234567890123456789012345678901234567.8 +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 84: DECIMAL(38,2) - 36 digits before decimal, 2 after +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) AS value +UNION ALL +SELECT CAST(999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(100000000000000000000000000000000000.00 AS DECIMAL(38,2)) +ORDER BY value; +GO +~~START~~ +numeric +100000000000000000000000000000000000.00 +123456789012345678901234567890123456.78 +999999999999999999999999999999999999.99 +~~END~~ + + +-- Test Case 85: DECIMAL(38,5) - 33 digits before decimal, 5 after +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) AS value +UNION ALL +SELECT CAST(99999999999999999999999999999999.99999 AS DECIMAL(38,5)) +UNION ALL +SELECT CAST(10000000000000000000000000000000.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +10000000000000000000000000000000.00001 +12345678901234567890123456789012.34567 +99999999999999999999999999999999.99999 +~~END~~ + + +-- Test Case 86: Mixing different scales with precision 38 +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.7 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 88: Very small fractional part with precision 38 +SELECT CAST(9999999999999999999999999999999999999.1 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.01 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 89: Overflow scenarios with precision 38 +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(10000000000000000000000000000000000000.0 AS DECIMAL(38,1)) -- This will cause an overflow +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 90: Mixing DECIMAL and NUMERIC with precision 38 and small scales +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS NUMERIC(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.8 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 91: NULL values with precision 38 and small scales +SELECT CAST(NULL AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(NULL AS NUMERIC(38,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 92: customer query +DECLARE @test_int int = 1; +SELECT a.integer_one, a.integer_two, +ratio = a.integer_one / CONVERT(DECIMAL, a.integer_two), +ratio_case_one = CASE WHEN a.integer_two = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_two = CASE WHEN 1 = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_three = CASE WHEN @test_int = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END +FROM BABEL_5341_T2 a; +GO +~~START~~ +int#!#int#!#numeric#!#numeric#!#numeric#!#numeric +1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 +~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out index 47262b50ce..ce384f1886 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out @@ -13189,7 +13189,7 @@ SELECT * FROM BABEL_5341_V2; GO ~~START~~ numeric -6789 +6789.0000 ~~END~~ @@ -13730,21 +13730,6 @@ smalldatetime ~~END~~ -SELECT CASE 2 - WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) - WHEN 2 THEN CAST(GETDATE() AS DATE) - WHEN 3 THEN CAST(GETDATE() AS TIME) - WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) - WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) - WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) -END AS Result -GO -~~START~~ -smalldatetime -2024-12-06 00:00:00.0 -~~END~~ - - -- Test Case 42: NUMERIC and TINYINT SELECT CASE 1 WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) @@ -13805,7 +13790,7 @@ END AS RESULT GO ~~START~~ numeric -99.99 +99.9900000000 ~~END~~ @@ -13835,7 +13820,7 @@ END AS RESULT GO ~~START~~ numeric -49382.7161 +49382.7161000000 ~~END~~ @@ -13850,7 +13835,7 @@ END AS RESULT GO ~~START~~ numeric -12345.68 +12345.6800000000 ~~END~~ @@ -13865,7 +13850,7 @@ END AS RESULT GO ~~START~~ numeric -99.9900 +99.9900000000 ~~END~~ @@ -13896,7 +13881,7 @@ FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) GO ~~START~~ numeric -600.0000 +600.0000000000 ~~END~~ @@ -13911,7 +13896,7 @@ END AS RESULT GO ~~START~~ numeric -1000 +1000.0000000000 ~~END~~ @@ -13941,7 +13926,7 @@ END AS RESULT GO ~~START~~ numeric -9876.54 +9876.5400 ~~END~~ @@ -13971,7 +13956,7 @@ END AS RESULT GO ~~START~~ numeric -1234568.8901000000 +1234568.9 ~~END~~ @@ -13986,3 +13971,564 @@ GO DROP TYPE SmallDecimalType_BABEL_5341; GO + +-- test cases +-- Test Case 57: Basic DECIMAL and NUMERIC mix +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1))), + (CAST(2.2 AS NUMERIC(3,1))), + (CAST(3.3 AS DECIMAL(3,1))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +2.2 +3.3 +~~END~~ + + +-- Test Case 58: Different precisions and scales +SELECT * FROM (VALUES + (CAST(1.23456 AS DECIMAL(6,5))), + (CAST(23.4567 AS NUMERIC(6,4))), + (CAST(345.678 AS DECIMAL(6,3))), + (CAST(4567.89 AS NUMERIC(6,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23456 +23.45670 +345.67800 +4567.89000 +~~END~~ + + +-- Test Case 59: Large precisions +SELECT * FROM (VALUES + (CAST(1234567890123456789.1234567890 AS DECIMAL(38,10))), + (CAST(9876543210987654321.0987654321 AS NUMERIC(38,10))), + (CAST(1111111111111111111.1111111111 AS DECIMAL(38,10))) +) AS "VALUES"; +GO +~~START~~ +numeric +1234567890123456789.1234567890 +9876543210987654321.0987654321 +1111111111111111111.1111111111 +~~END~~ + + +-- Test Case 60: Small scales +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(38,1))), + (CAST(22.22 AS NUMERIC(38,2))), + (CAST(333.333 AS DECIMAL(38,3))), + (CAST(4444.4444 AS NUMERIC(38,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +22.2 +333.3 +4444.4 +~~END~~ + + +-- Test Case 61: Mix of positive and negative numbers +SELECT * FROM (VALUES + (CAST(-1.23 AS DECIMAL(5,2))), + (CAST(4.56 AS NUMERIC(5,2))), + (CAST(-7.89 AS DECIMAL(5,2))), + (CAST(0.12 AS NUMERIC(5,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +-1.23 +4.56 +-7.89 +0.12 +~~END~~ + + +-- Test Case 62: Very small numbers +SELECT * FROM (VALUES + (CAST(0.000000000123 AS DECIMAL(15,12))), + (CAST(0.000000000456 AS NUMERIC(15,12))), + (CAST(0.000000000789 AS DECIMAL(15,12))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23E-10 +4.56E-10 +7.89E-10 +~~END~~ + + +-- Test Case 63: Very large numbers +SELECT * FROM (VALUES + (CAST(123456789012345678901234567890.12 AS DECIMAL(38,2))), + (CAST(987654321098765432109876543210.98 AS NUMERIC(38,2))), + (CAST(111111111111111111111111111111.11 AS DECIMAL(38,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +123456789012345678901234567890.12 +987654321098765432109876543210.98 +111111111111111111111111111111.11 +~~END~~ + + +-- Test Case 64: Mix of integer and fractional parts +SELECT * FROM (VALUES + (CAST(1 AS DECIMAL(38,0))), + (CAST(2.2 AS NUMERIC(38,1))), + (CAST(3.33 AS DECIMAL(38,2))), + (CAST(4.444 AS NUMERIC(38,3))) +) AS "VALUES"; +GO +~~START~~ +numeric +1 +2 +3 +4 +~~END~~ + + +-- Test Case 65: Edge cases +SELECT * FROM (VALUES + (CAST(0.9999999999999999999999999999999999999 AS DECIMAL(38,37))), + (CAST(9.999999999999999999999999999999999999 AS NUMERIC(38,36))), + (CAST(0.0000000000000000000000000000000000001 AS DECIMAL(38,37))) +) AS "VALUES"; +GO +~~START~~ +numeric +0.999999999999999999999999999999999999 +9.999999999999999999999999999999999999 +0E-36 +~~END~~ + + +-- Test Case 66: Mix of DECIMAL and NUMERIC with different precisions +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(5,1))), + (CAST(2.22 AS NUMERIC(10,2))), + (CAST(3.333 AS DECIMAL(15,3))), + (CAST(4.4444 AS NUMERIC(20,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1000 +2.2200 +3.3330 +4.4444 +~~END~~ + + +-- Test Case 67: Mix of numeric, decimal, integer, and varchar +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), 10, 'ABC'), + (CAST(2.2 AS NUMERIC(3,1)), 20, 'DEF'), + (CAST(3.3 AS DECIMAL(3,1)), 30, 'GHI') +) AS "VALUES" (dec_num, int_num, str_val); +GO +~~START~~ +numeric#!#int#!#varchar +1.1#!#10#!#ABC +2.2#!#20#!#DEF +3.3#!#30#!#GHI +~~END~~ + + +-- Test Case 68: Mix with date, time, and boolean +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(4,2)), CAST('2023-01-01' AS DATE), CAST('10:30:00' AS TIME), TRUE), + (CAST(4.56 AS NUMERIC(4,2)), CAST('2023-02-15' AS DATE), CAST('14:45:00' AS TIME), FALSE), + (CAST(7.89 AS DECIMAL(4,2)), CAST('2023-03-30' AS DATE), CAST('20:15:00' AS TIME), TRUE) +) AS "VALUES" (num_val, date_val, time_val, bool_val); +GO +~~START~~ +numeric#!#date#!#time#!#bit +1.23#!#2023-01-01#!#10:30:00.0000000#!#1 +4.56#!#2023-02-15#!#14:45:00.0000000#!#0 +7.89#!#2023-03-30#!#20:15:00.0000000#!#1 +~~END~~ + + +-- Test Case 69: Mix with timestamp and interval +SELECT * FROM (VALUES + (CAST(123.45 AS DECIMAL(5,2)), CAST('2023-01-01 12:00:00' AS TIMESTAMP), CAST('1 day' AS INTERVAL)), + (CAST(678.90 AS NUMERIC(5,2)), CAST('2023-06-15 18:30:00' AS TIMESTAMP), CAST('2 hours' AS INTERVAL)), + (CAST(246.80 AS DECIMAL(5,2)), CAST('2023-12-31 23:59:59' AS TIMESTAMP), CAST('30 minutes' AS INTERVAL)) +) AS "VALUES" (num_val, ts_val, interval_val); +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: To use the TIMESTAMP datatype, set 'babelfishpg_tsql.escape_hatch_rowversion' to 'ignore')~~ + + +-- Test Case 70: Mix with char, varchar, and text +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), CAST('A' AS CHAR(1)), CAST('ABC' AS VARCHAR(10)), 'This is a text'), + (CAST(2.2 AS NUMERIC(3,1)), CAST('B' AS CHAR(1)), CAST('DEF' AS VARCHAR(10)), 'Another text'), + (CAST(3.3 AS DECIMAL(3,1)), CAST('C' AS CHAR(1)), CAST('GHI' AS VARCHAR(10)), 'Yet another text') +) AS "VALUES" (num_val, char_val, varchar_val, text_val); +GO +~~START~~ +numeric#!#char#!#varchar#!#varchar +1.1#!#A#!#ABC#!#This is a text +2.2#!#B#!#DEF#!#Another text +3.3#!#C#!#GHI#!#Yet another text +~~END~~ + + +-- Test Case 71: Mix with money and bit +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(3,2)), CAST(100.00 AS MONEY), CAST('1' AS BIT)), + (CAST(4.56 AS NUMERIC(3,2)), CAST(200.50 AS MONEY), CAST('0' AS BIT)), + (CAST(7.89 AS DECIMAL(3,2)), CAST(350.75 AS MONEY), CAST('1' AS BIT)) +) AS "VALUES" (num_val, money_val, bit_val); +GO +~~START~~ +numeric#!#money#!#bit +1.23#!#100.0000#!#1 +4.56#!#200.5000#!#0 +7.89#!#350.7500#!#1 +~~END~~ + + +-- Test Case 72: UNION with DECIMAL and INTEGER +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT 456 +ORDER BY value; +GO +~~START~~ +numeric +1.23 +456.00 +~~END~~ + + +-- Test Case 73: UNION with NUMERIC, DECIMAL, and FLOAT +SELECT CAST(1.23456 AS NUMERIC(10,5)) AS value +UNION ALL +SELECT CAST(2.34567 AS DECIMAL(10,5)) +UNION ALL +SELECT CAST(3.45678 AS FLOAT) +ORDER BY value; +GO +~~START~~ +float +1.23456 +2.34567 +3.45678 +~~END~~ + + +-- Test Case 74: UNION with different precisions and scales +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(2.3456 AS NUMERIC(10,4)) +UNION ALL +SELECT CAST(3.456789 AS DECIMAL(15,6)) +ORDER BY value; +GO +~~START~~ +numeric +1.230000 +2.345600 +3.456789 +~~END~~ + + +-- Test Case 75: UNION with negative numbers and zero +SELECT CAST(-1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(0 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(1.23 AS DECIMAL(5,2)) +ORDER BY value; +GO +~~START~~ +numeric +-1.23 +0.00 +1.23 +~~END~~ + + +-- Test Case 75: UNION with large numbers +SELECT CAST(1234567890.12345 AS DECIMAL(20,5)) AS value +UNION ALL +SELECT CAST(9876543210.98765 AS NUMERIC(20,5)) +UNION ALL +SELECT CAST(1111111111.11111 AS DECIMAL(20,5)) +ORDER BY value; +GO +~~START~~ +numeric +1111111111.11111 +1234567890.12345 +9876543210.98765 +~~END~~ + + +-- Test Case 76: UNION with small numbers +SELECT CAST(0.00000123 AS DECIMAL(10,8)) AS value +UNION ALL +SELECT CAST(0.00000456 AS NUMERIC(10,8)) +UNION ALL +SELECT CAST(0.00000789 AS DECIMAL(10,8)) +ORDER BY value; +GO +~~START~~ +numeric +0.00000123 +0.00000456 +0.00000789 +~~END~~ + + +-- Test Case 77: UNION with DECIMAL, NUMERIC, and VARCHAR +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST('7.89' AS VARCHAR(10)) +ORDER BY value; +GO +~~START~~ +numeric +1.2300000000 +4.5600000000 +7.8900000000 +~~END~~ + + +-- Test Case 78: UNION with different integer parts +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(123.45 AS NUMERIC(10,2)) +UNION ALL +SELECT CAST(12345.67 AS DECIMAL(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +123.45 +12345.67 +~~END~~ + + +-- Test Case 79: UNION with extreme values +SELECT CAST(9999999999.99999999 AS DECIMAL(18,8)) AS value +UNION ALL +SELECT CAST(0.00000001 AS NUMERIC(18,8)) +UNION ALL +SELECT CAST(5555555555.55555555 AS DECIMAL(18,8)) +ORDER BY value; +GO +~~START~~ +numeric +1E-8 +5555555555.55555555 +9999999999.99999999 +~~END~~ + + +-- Test Case 80: UNION with NULL values +SELECT CAST(NULL AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(1.23 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(NULL AS DECIMAL(5,2)) +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +1.23 +4.56 +~~END~~ + + +-- Test Case 81: UNION with MONEY type +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(4.56 AS MONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 82: UNION with SMALLMONEY type +SELECT CAST(1.23 AS DECIMAL(6,2)) AS value +UNION ALL +SELECT CAST(4.56 AS SMALLMONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(6,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 83: DECIMAL(38,1) - 37 digits before decimal, 1 after +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(1000000000000000000000000000000000000.0 AS DECIMAL(38,1)) +ORDER BY value; +GO +~~START~~ +numeric +1000000000000000000000000000000000000.0 +1234567890123456789012345678901234567.8 +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 84: DECIMAL(38,2) - 36 digits before decimal, 2 after +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) AS value +UNION ALL +SELECT CAST(999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(100000000000000000000000000000000000.00 AS DECIMAL(38,2)) +ORDER BY value; +GO +~~START~~ +numeric +100000000000000000000000000000000000.00 +123456789012345678901234567890123456.78 +999999999999999999999999999999999999.99 +~~END~~ + + +-- Test Case 85: DECIMAL(38,5) - 33 digits before decimal, 5 after +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) AS value +UNION ALL +SELECT CAST(99999999999999999999999999999999.99999 AS DECIMAL(38,5)) +UNION ALL +SELECT CAST(10000000000000000000000000000000.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +10000000000000000000000000000000.00001 +12345678901234567890123456789012.34567 +99999999999999999999999999999999.99999 +~~END~~ + + +-- Test Case 86: Mixing different scales with precision 38 +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.7 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 88: Very small fractional part with precision 38 +SELECT CAST(9999999999999999999999999999999999999.1 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.01 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 89: Overflow scenarios with precision 38 +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(10000000000000000000000000000000000000.0 AS DECIMAL(38,1)) -- This will cause an overflow +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 90: Mixing DECIMAL and NUMERIC with precision 38 and small scales +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS NUMERIC(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.8 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 91: NULL values with precision 38 and small scales +SELECT CAST(NULL AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(NULL AS NUMERIC(38,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 92: customer query +DECLARE @test_int int = 1; +SELECT a.integer_one, a.integer_two, +ratio = a.integer_one / CONVERT(DECIMAL, a.integer_two), +ratio_case_one = CASE WHEN a.integer_two = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_two = CASE WHEN 1 = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_three = CASE WHEN @test_int = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END +FROM BABEL_5341_T2 a; +GO +~~START~~ +int#!#int#!#numeric#!#numeric#!#numeric#!#numeric +1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 +~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index 492a77f4f9..1bd8b428fa 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -13730,21 +13730,6 @@ smalldatetime ~~END~~ -SELECT CASE 2 - WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) - WHEN 2 THEN CAST(GETDATE() AS DATE) - WHEN 3 THEN CAST(GETDATE() AS TIME) - WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) - WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) - WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) -END AS Result -GO -~~START~~ -smalldatetime -2024-12-06 00:00:00.0 -~~END~~ - - -- Test Case 42: NUMERIC and TINYINT SELECT CASE 1 WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) @@ -13805,7 +13790,7 @@ END AS RESULT GO ~~START~~ numeric -99.99 +99.9900000000 ~~END~~ @@ -13835,7 +13820,7 @@ END AS RESULT GO ~~START~~ numeric -49382.7161 +49382.7161000000 ~~END~~ @@ -13850,7 +13835,7 @@ END AS RESULT GO ~~START~~ numeric -12345.68 +12345.6800000000 ~~END~~ @@ -13865,7 +13850,7 @@ END AS RESULT GO ~~START~~ numeric -99.9900 +99.9900000000 ~~END~~ @@ -13896,7 +13881,7 @@ FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) GO ~~START~~ numeric -600.0000 +600.0000000000 ~~END~~ @@ -13911,7 +13896,7 @@ END AS RESULT GO ~~START~~ numeric -1000 +1000.0000000000 ~~END~~ @@ -13941,7 +13926,7 @@ END AS RESULT GO ~~START~~ numeric -9876.54 +9876.5400 ~~END~~ @@ -13971,7 +13956,7 @@ END AS RESULT GO ~~START~~ numeric -1234568.8901000000 +1234568.9 ~~END~~ @@ -13986,3 +13971,564 @@ GO DROP TYPE SmallDecimalType_BABEL_5341; GO + +-- test cases +-- Test Case 57: Basic DECIMAL and NUMERIC mix +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1))), + (CAST(2.2 AS NUMERIC(3,1))), + (CAST(3.3 AS DECIMAL(3,1))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +2.2 +3.3 +~~END~~ + + +-- Test Case 58: Different precisions and scales +SELECT * FROM (VALUES + (CAST(1.23456 AS DECIMAL(6,5))), + (CAST(23.4567 AS NUMERIC(6,4))), + (CAST(345.678 AS DECIMAL(6,3))), + (CAST(4567.89 AS NUMERIC(6,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23456 +23.45670 +345.67800 +4567.89000 +~~END~~ + + +-- Test Case 59: Large precisions +SELECT * FROM (VALUES + (CAST(1234567890123456789.1234567890 AS DECIMAL(38,10))), + (CAST(9876543210987654321.0987654321 AS NUMERIC(38,10))), + (CAST(1111111111111111111.1111111111 AS DECIMAL(38,10))) +) AS "VALUES"; +GO +~~START~~ +numeric +1234567890123456789.1234567890 +9876543210987654321.0987654321 +1111111111111111111.1111111111 +~~END~~ + + +-- Test Case 60: Small scales +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(38,1))), + (CAST(22.22 AS NUMERIC(38,2))), + (CAST(333.333 AS DECIMAL(38,3))), + (CAST(4444.4444 AS NUMERIC(38,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +22.2 +333.3 +4444.4 +~~END~~ + + +-- Test Case 61: Mix of positive and negative numbers +SELECT * FROM (VALUES + (CAST(-1.23 AS DECIMAL(5,2))), + (CAST(4.56 AS NUMERIC(5,2))), + (CAST(-7.89 AS DECIMAL(5,2))), + (CAST(0.12 AS NUMERIC(5,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +-1.23 +4.56 +-7.89 +0.12 +~~END~~ + + +-- Test Case 62: Very small numbers +SELECT * FROM (VALUES + (CAST(0.000000000123 AS DECIMAL(15,12))), + (CAST(0.000000000456 AS NUMERIC(15,12))), + (CAST(0.000000000789 AS DECIMAL(15,12))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23E-10 +4.56E-10 +7.89E-10 +~~END~~ + + +-- Test Case 63: Very large numbers +SELECT * FROM (VALUES + (CAST(123456789012345678901234567890.12 AS DECIMAL(38,2))), + (CAST(987654321098765432109876543210.98 AS NUMERIC(38,2))), + (CAST(111111111111111111111111111111.11 AS DECIMAL(38,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +123456789012345678901234567890.12 +987654321098765432109876543210.98 +111111111111111111111111111111.11 +~~END~~ + + +-- Test Case 64: Mix of integer and fractional parts +SELECT * FROM (VALUES + (CAST(1 AS DECIMAL(38,0))), + (CAST(2.2 AS NUMERIC(38,1))), + (CAST(3.33 AS DECIMAL(38,2))), + (CAST(4.444 AS NUMERIC(38,3))) +) AS "VALUES"; +GO +~~START~~ +numeric +1 +2 +3 +4 +~~END~~ + + +-- Test Case 65: Edge cases +SELECT * FROM (VALUES + (CAST(0.9999999999999999999999999999999999999 AS DECIMAL(38,37))), + (CAST(9.999999999999999999999999999999999999 AS NUMERIC(38,36))), + (CAST(0.0000000000000000000000000000000000001 AS DECIMAL(38,37))) +) AS "VALUES"; +GO +~~START~~ +numeric +0.999999999999999999999999999999999999 +9.999999999999999999999999999999999999 +0E-36 +~~END~~ + + +-- Test Case 66: Mix of DECIMAL and NUMERIC with different precisions +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(5,1))), + (CAST(2.22 AS NUMERIC(10,2))), + (CAST(3.333 AS DECIMAL(15,3))), + (CAST(4.4444 AS NUMERIC(20,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1000 +2.2200 +3.3330 +4.4444 +~~END~~ + + +-- Test Case 67: Mix of numeric, decimal, integer, and varchar +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), 10, 'ABC'), + (CAST(2.2 AS NUMERIC(3,1)), 20, 'DEF'), + (CAST(3.3 AS DECIMAL(3,1)), 30, 'GHI') +) AS "VALUES" (dec_num, int_num, str_val); +GO +~~START~~ +numeric#!#int#!#varchar +1.1#!#10#!#ABC +2.2#!#20#!#DEF +3.3#!#30#!#GHI +~~END~~ + + +-- Test Case 68: Mix with date, time, and boolean +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(4,2)), CAST('2023-01-01' AS DATE), CAST('10:30:00' AS TIME), TRUE), + (CAST(4.56 AS NUMERIC(4,2)), CAST('2023-02-15' AS DATE), CAST('14:45:00' AS TIME), FALSE), + (CAST(7.89 AS DECIMAL(4,2)), CAST('2023-03-30' AS DATE), CAST('20:15:00' AS TIME), TRUE) +) AS "VALUES" (num_val, date_val, time_val, bool_val); +GO +~~START~~ +numeric#!#date#!#time#!#bit +1.23#!#2023-01-01#!#10:30:00.0000000#!#1 +4.56#!#2023-02-15#!#14:45:00.0000000#!#0 +7.89#!#2023-03-30#!#20:15:00.0000000#!#1 +~~END~~ + + +-- Test Case 69: Mix with timestamp and interval +SELECT * FROM (VALUES + (CAST(123.45 AS DECIMAL(5,2)), CAST('2023-01-01 12:00:00' AS TIMESTAMP), CAST('1 day' AS INTERVAL)), + (CAST(678.90 AS NUMERIC(5,2)), CAST('2023-06-15 18:30:00' AS TIMESTAMP), CAST('2 hours' AS INTERVAL)), + (CAST(246.80 AS DECIMAL(5,2)), CAST('2023-12-31 23:59:59' AS TIMESTAMP), CAST('30 minutes' AS INTERVAL)) +) AS "VALUES" (num_val, ts_val, interval_val); +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: To use the TIMESTAMP datatype, set 'babelfishpg_tsql.escape_hatch_rowversion' to 'ignore')~~ + + +-- Test Case 70: Mix with char, varchar, and text +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), CAST('A' AS CHAR(1)), CAST('ABC' AS VARCHAR(10)), 'This is a text'), + (CAST(2.2 AS NUMERIC(3,1)), CAST('B' AS CHAR(1)), CAST('DEF' AS VARCHAR(10)), 'Another text'), + (CAST(3.3 AS DECIMAL(3,1)), CAST('C' AS CHAR(1)), CAST('GHI' AS VARCHAR(10)), 'Yet another text') +) AS "VALUES" (num_val, char_val, varchar_val, text_val); +GO +~~START~~ +numeric#!#char#!#varchar#!#varchar +1.1#!#A#!#ABC#!#This is a text +2.2#!#B#!#DEF#!#Another text +3.3#!#C#!#GHI#!#Yet another text +~~END~~ + + +-- Test Case 71: Mix with money and bit +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(3,2)), CAST(100.00 AS MONEY), CAST('1' AS BIT)), + (CAST(4.56 AS NUMERIC(3,2)), CAST(200.50 AS MONEY), CAST('0' AS BIT)), + (CAST(7.89 AS DECIMAL(3,2)), CAST(350.75 AS MONEY), CAST('1' AS BIT)) +) AS "VALUES" (num_val, money_val, bit_val); +GO +~~START~~ +numeric#!#money#!#bit +1.23#!#100.0000#!#1 +4.56#!#200.5000#!#0 +7.89#!#350.7500#!#1 +~~END~~ + + +-- Test Case 72: UNION with DECIMAL and INTEGER +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT 456 +ORDER BY value; +GO +~~START~~ +numeric +1.23 +456.00 +~~END~~ + + +-- Test Case 73: UNION with NUMERIC, DECIMAL, and FLOAT +SELECT CAST(1.23456 AS NUMERIC(10,5)) AS value +UNION ALL +SELECT CAST(2.34567 AS DECIMAL(10,5)) +UNION ALL +SELECT CAST(3.45678 AS FLOAT) +ORDER BY value; +GO +~~START~~ +float +1.23456 +2.34567 +3.45678 +~~END~~ + + +-- Test Case 74: UNION with different precisions and scales +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(2.3456 AS NUMERIC(10,4)) +UNION ALL +SELECT CAST(3.456789 AS DECIMAL(15,6)) +ORDER BY value; +GO +~~START~~ +numeric +1.230000 +2.345600 +3.456789 +~~END~~ + + +-- Test Case 75: UNION with negative numbers and zero +SELECT CAST(-1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(0 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(1.23 AS DECIMAL(5,2)) +ORDER BY value; +GO +~~START~~ +numeric +-1.23 +0.00 +1.23 +~~END~~ + + +-- Test Case 75: UNION with large numbers +SELECT CAST(1234567890.12345 AS DECIMAL(20,5)) AS value +UNION ALL +SELECT CAST(9876543210.98765 AS NUMERIC(20,5)) +UNION ALL +SELECT CAST(1111111111.11111 AS DECIMAL(20,5)) +ORDER BY value; +GO +~~START~~ +numeric +1111111111.11111 +1234567890.12345 +9876543210.98765 +~~END~~ + + +-- Test Case 76: UNION with small numbers +SELECT CAST(0.00000123 AS DECIMAL(10,8)) AS value +UNION ALL +SELECT CAST(0.00000456 AS NUMERIC(10,8)) +UNION ALL +SELECT CAST(0.00000789 AS DECIMAL(10,8)) +ORDER BY value; +GO +~~START~~ +numeric +0.00000123 +0.00000456 +0.00000789 +~~END~~ + + +-- Test Case 77: UNION with DECIMAL, NUMERIC, and VARCHAR +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST('7.89' AS VARCHAR(10)) +ORDER BY value; +GO +~~START~~ +numeric +1.2300000000 +4.5600000000 +7.8900000000 +~~END~~ + + +-- Test Case 78: UNION with different integer parts +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(123.45 AS NUMERIC(10,2)) +UNION ALL +SELECT CAST(12345.67 AS DECIMAL(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +123.45 +12345.67 +~~END~~ + + +-- Test Case 79: UNION with extreme values +SELECT CAST(9999999999.99999999 AS DECIMAL(18,8)) AS value +UNION ALL +SELECT CAST(0.00000001 AS NUMERIC(18,8)) +UNION ALL +SELECT CAST(5555555555.55555555 AS DECIMAL(18,8)) +ORDER BY value; +GO +~~START~~ +numeric +1E-8 +5555555555.55555555 +9999999999.99999999 +~~END~~ + + +-- Test Case 80: UNION with NULL values +SELECT CAST(NULL AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(1.23 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(NULL AS DECIMAL(5,2)) +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +1.23 +4.56 +~~END~~ + + +-- Test Case 81: UNION with MONEY type +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(4.56 AS MONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 82: UNION with SMALLMONEY type +SELECT CAST(1.23 AS DECIMAL(6,2)) AS value +UNION ALL +SELECT CAST(4.56 AS SMALLMONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(6,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 83: DECIMAL(38,1) - 37 digits before decimal, 1 after +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(1000000000000000000000000000000000000.0 AS DECIMAL(38,1)) +ORDER BY value; +GO +~~START~~ +numeric +1000000000000000000000000000000000000.0 +1234567890123456789012345678901234567.8 +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 84: DECIMAL(38,2) - 36 digits before decimal, 2 after +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) AS value +UNION ALL +SELECT CAST(999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(100000000000000000000000000000000000.00 AS DECIMAL(38,2)) +ORDER BY value; +GO +~~START~~ +numeric +100000000000000000000000000000000000.00 +123456789012345678901234567890123456.78 +999999999999999999999999999999999999.99 +~~END~~ + + +-- Test Case 85: DECIMAL(38,5) - 33 digits before decimal, 5 after +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) AS value +UNION ALL +SELECT CAST(99999999999999999999999999999999.99999 AS DECIMAL(38,5)) +UNION ALL +SELECT CAST(10000000000000000000000000000000.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +10000000000000000000000000000000.00001 +12345678901234567890123456789012.34567 +99999999999999999999999999999999.99999 +~~END~~ + + +-- Test Case 86: Mixing different scales with precision 38 +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.7 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 88: Very small fractional part with precision 38 +SELECT CAST(9999999999999999999999999999999999999.1 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.01 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 89: Overflow scenarios with precision 38 +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(10000000000000000000000000000000000000.0 AS DECIMAL(38,1)) -- This will cause an overflow +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 90: Mixing DECIMAL and NUMERIC with precision 38 and small scales +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS NUMERIC(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.8 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 91: NULL values with precision 38 and small scales +SELECT CAST(NULL AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(NULL AS NUMERIC(38,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 92: customer query +DECLARE @test_int int = 1; +SELECT a.integer_one, a.integer_two, +ratio = a.integer_one / CONVERT(DECIMAL, a.integer_two), +ratio_case_one = CASE WHEN a.integer_two = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_two = CASE WHEN 1 = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_three = CASE WHEN @test_int = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END +FROM BABEL_5341_T2 a; +GO +~~START~~ +int#!#int#!#numeric#!#numeric#!#numeric#!#numeric +1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 +~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out new file mode 100644 index 0000000000..96db09670e --- /dev/null +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out @@ -0,0 +1,14534 @@ +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +ntext +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nvarchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_T1 +GO +~~START~~ +nchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_V1 +GO +~~START~~ +nchar +Registration Card - Standard +بطاقة التسجيل - قياسية +登録カード–標準 +~~END~~ + + +-- Function call +SELECT BABEL_5103_F1('REGULAR'); +GO +~~START~~ +nvarchar +REGULAR +~~END~~ + + +SELECT BABEL_5103_F1(N'登録カード–標準'); +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT BABEL_5103_F1(N'بطاقة التسجيل - قياسية'); +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +-- selecting from view +SELECT * FROM BABEL_5103_V2 +GO +~~START~~ +nvarchar +登録カード +~~END~~ + + +-- single branch +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + +-- single branch with multibyte character +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being CHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS Char(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS Char(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch without NULL one being TEXT +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS TEXT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS TEXT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branch with one being string literal +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード?標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード?標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード?標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- multiple branches one being NULL +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +-- NULL tests +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext + +~~END~~ + + +-- other datatypes then string +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO +~~START~~ +numeric +123.00 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123.456 AS FLOAT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO +~~START~~ +float +123.456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO +~~START~~ +bigint +123 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO +~~START~~ +numeric +123.00 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123.456 AS BIGINT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO +~~START~~ +numeric +123.000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO +~~START~~ +bigint +123 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('2024-01-01' AS DATE) + WHEN 2 THEN CAST('2024-09-27 12:34:56' AS DATETIME) +END AS RESULT +GO +~~START~~ +datetime +2024-01-01 00:00:00.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('12:34:56' AS TIME) + WHEN 2 THEN CAST('2024-09-27 12:34:56.1234567' AS DATETIME2(7)) +END AS RESULT +GO +~~START~~ +datetime2 +1900-01-01 12:34:56.0000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1 AS BIT) + WHEN 2 THEN CAST(0 AS BIT) +END AS RESULT +GO +~~START~~ +bit +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BINARY(3)) + WHEN 2 THEN CAST(0xABCDEF AS VARBINARY(6)) +END AS RESULT +GO +~~START~~ +varbinary +123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1000.00 AS MONEY) + WHEN 2 THEN CAST(100.00 AS SMALLMONEY) +END AS RESULT +GO +~~START~~ +money +1000.0000 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO +~~START~~ +numeric +456.00 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123.456 AS FLOAT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO +~~START~~ +float +789.123 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO +~~START~~ +bigint +456789123 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO +~~START~~ +numeric +456.00 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123.456 AS BIGINT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO +~~START~~ +numeric +789.123 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO +~~START~~ +bigint +456789123 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('2024-01-01' AS DATE) + WHEN 2 THEN CAST('2024-09-27 12:34:56' AS DATETIME) +END AS RESULT +GO +~~START~~ +datetime +2024-09-27 12:34:56.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('12:34:56' AS TIME) + WHEN 2 THEN CAST('2024-09-27 12:34:56.1234567' AS DATETIME2(7)) +END AS RESULT +GO +~~START~~ +datetime2 +2024-09-27 12:34:56.1234570 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1 AS BIT) + WHEN 2 THEN CAST(0 AS BIT) +END AS RESULT +GO +~~START~~ +bit +0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BINARY(3)) + WHEN 2 THEN CAST(0xABCDEF AS VARBINARY(6)) +END AS RESULT +GO +~~START~~ +varbinary +ABCDEF +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1000.00 AS MONEY) + WHEN 2 THEN CAST(100.00 AS SMALLMONEY) +END AS RESULT +GO +~~START~~ +money +100.0000 +~~END~~ + + + +-- Collation tests +-- FIX ME: Following test cases shows behaviour mismatch, +-- When we compare N' 比尔·拉莫斯 ' COLLATE japanese_ci_as +-- with N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS for CASE expression, +-- Gives 'true' (as used in PG), whereas it should give 'false' (as in TSQL). +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar + 比尔·拉莫斯 +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar + abc🙂defghi🙂🙂 +~~END~~ + + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS +END AS RESULT +GO +~~START~~ +varchar +abcd +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE japanese_ci_as + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as +END AS RESULT +GO +~~START~~ +varchar + abc?defghi?? +~~END~~ + + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS +END AS RESULT +GO +~~START~~ +nvarchar +abcd +~~END~~ + + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE japanese_ci_as + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE ARABIC_CI_AS + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS +END AS RESULT +GO +~~START~~ +varchar + abc?defghi?? +~~END~~ + + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS +END AS RESULT +GO +~~START~~ +varchar +abcd +~~END~~ + + +--- SYSNAME tests +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS sysname) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +--- UDT testing +create type BABEL_CASE_EXPR_TEST_UDT from NVARCHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nvarchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from sysname; +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + + +create type BABEL_CASE_EXPR_TEST_UDT from VARCHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from CHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +char +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +char +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +char +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +char +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from NCHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +nchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from TEXT; +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +text +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from NTEXT; +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +بطاقة التسجيل - قياسية +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +ntext +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- multiple branch one being Binary +create type BABEL_CASE_EXPR_TEST_UDT from BINARY(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 0x123456 +END AS RESULT +GO +~~START~~ +varbinary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 0x123456 +END AS RESULT +GO +~~START~~ +varbinary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 0x123456 + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varbinary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +binary +12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_binary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to binary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- multiple branch one being VARBINARY +create type BABEL_CASE_EXPR_TEST_UDT from VARBINARY(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varbinary +123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varbinary +123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~START~~ +varbinary +123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type bpchar to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "nchar" to bbf_varbinary)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +登録カード?標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +4V +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot coerce string literal to varbinary datatype)~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +text +0x123456 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- multiple UDT branches +create type BABEL_CASE_EXPR_TEST_UDT0 from NVARCHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT1 from NCHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT2 from CHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT3 from VARCHAR(100); +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nvarchar +????? ??????? - ?????? +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nchar +登録カード?標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +nchar +登録カード–標準 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +nvarchar +登録カード–標準 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +varchar +char +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT0; +go + +drop type BABEL_CASE_EXPR_TEST_UDT1; +go + +drop type BABEL_CASE_EXPR_TEST_UDT2; +go + +drop type BABEL_CASE_EXPR_TEST_UDT3; +go + +-- Numeric datatypes +create type BABEL_CASE_EXPR_TEST_UDT0 from INT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT1 from DECIMAL; +GO + +create type BABEL_CASE_EXPR_TEST_UDT2 from FLOAT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT3 from BIT; +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(2.300 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +2.3 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +int +0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(12.3 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(1 AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +int +1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(1.345 AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(1321 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +bit +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST(1.234 AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +numeric +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(1235 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.345 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(234.234 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(346 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(04545 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(12.4 AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +numeric +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(1 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST(234.234 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type babel_case_expr_test_udt3 to double precision)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type babel_case_expr_test_udt2 to "bit")~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(123.3 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(546 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +numeric +123 +~~END~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(54 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.123 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +54.0 +~~END~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(23 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(6356 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +numeric +23 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(3456.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 3 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type babel_case_expr_test_udt3 to double precision)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(23.12 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(2354 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +float +23.0 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT0; +go + +drop type BABEL_CASE_EXPR_TEST_UDT1; +go + +drop type BABEL_CASE_EXPR_TEST_UDT2; +go + +drop type BABEL_CASE_EXPR_TEST_UDT3; +go + +-- Mixture of numeric and string types +create type BABEL_CASE_EXPR_TEST_UDT0 from INT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT1 from NCHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT2 from FLOAT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT3 from VARCHAR(100); +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(2.300 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +2.3 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "登録カード–標準")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "登録カード–標準")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "登録カード–標準 ")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(1321 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~START~~ +int +1321 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(1235 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.345 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(346 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(04545 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST(234.234 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(546 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(54 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.123 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(6356 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(3456.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO +~~START~~ +float +3456.34 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(2354 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "char0 ")~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT0; +go + +drop type BABEL_CASE_EXPR_TEST_UDT1; +go + +drop type BABEL_CASE_EXPR_TEST_UDT2; +go + +drop type BABEL_CASE_EXPR_TEST_UDT3; +go + +-- Mixture of datatypes and numeric without UDT +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(2.300 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +2.3 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS INT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "登録カード–標準")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS INT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "登録カード–標準")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS FLOAT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "登録カード–標準 ")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(1321 AS INT) +END AS RESULT +GO +~~START~~ +int +1321 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(1235 AS INT) + WHEN 3 THEN CAST(0.345 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(346 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(04545 AS INT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(234.234 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(546 AS INT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(54 AS INT) + WHEN 3 THEN CAST(0.123 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(6356 AS INT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type integer: "abc")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS INT) + WHEN 2 THEN CAST(3456.34 AS FLOAT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +float +3456.34 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS FLOAT) + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(2354 AS INT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type double precision: "char0 ")~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(2.300 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +2.3 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS INT) + WHEN 2 THEN CAST(0 AS BIT) +END AS RESULT +GO +~~START~~ +int +0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(12.3 AS DECIMAL) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +3.456 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS INT) + WHEN 2 THEN CAST(1 AS BIT) +END AS RESULT +GO +~~START~~ +int +1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS FLOAT) + WHEN 2 THEN CAST(1.345 AS DECIMAL) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1 AS BIT) + WHEN 2 THEN CAST(1321 AS INT) +END AS RESULT +GO +~~START~~ +bit +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(0 AS BIT) + WHEN 3 THEN CAST(1.234 AS DECIMAL) +END AS RESULT +GO +~~START~~ +numeric +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(1235 AS INT) + WHEN 3 THEN CAST(0.345 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(234.234 AS DECIMAL) + WHEN 3 THEN CAST(346 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +1.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(04545 AS INT) + WHEN 3 THEN CAST(12.4 AS DECIMAL) +END AS RESULT +GO +~~START~~ +numeric +1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(1 AS BIT) + WHEN 3 THEN CAST(234.234 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "bit" to double precision)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(0 AS BIT) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type double precision to "bit")~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(123.3 AS DECIMAL) + WHEN 3 THEN CAST(546 AS INT) +END AS RESULT +GO +~~START~~ +numeric +123 +~~END~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(54 AS INT) + WHEN 3 THEN CAST(0.123 AS FLOAT) +END AS RESULT +GO +~~START~~ +float +54.0 +~~END~~ + + +SELECT CASE 2 + WHEN 2 THEN CAST(23 AS DECIMAL) + WHEN 3 THEN CAST(6356 AS INT) +END AS RESULT +GO +~~START~~ +numeric +23 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS INT) + WHEN 2 THEN CAST(3456.34 AS FLOAT) + WHEN 3 THEN CAST(0 AS BIT) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type "bit" to double precision)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS FLOAT) + WHEN 2 THEN CAST(23.12 AS DECIMAL) + WHEN 3 THEN CAST(2354 AS INT) +END AS RESULT +GO +~~START~~ +float +23.0 +~~END~~ + + +-- UDT on varchar(max) +create type BABEL_CASE_EXPR_TEST_UDT from varchar(max); +go + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +varchar +a +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +varchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +varchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +varchar +a +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- UDT on nvarchar(max) +create type BABEL_CASE_EXPR_TEST_UDT from nvarchar(max); +go + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +nvarchar +a +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +nvarchar +abc +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO +~~START~~ +nvarchar +a +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +c +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char1 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char1 +~~END~~ + + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- With max typmod +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS VARCHAR(MAX)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO +~~START~~ +text +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nvarchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO +~~START~~ +nchar +char0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nchar +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nchar +N +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +varchar +N +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +N +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO +~~START~~ +nvarchar +N +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO +~~START~~ +text +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +NCHAR +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO +~~START~~ +text +NCHAR +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO +~~START~~ +text +ASDGASDKGJNASDLIUFAISDUFB +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +NCHAR +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO +~~START~~ +text +NCHAR +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (4000) for 'nchar' datatype.)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (4000) for 'nchar' datatype.)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (4000) for 'nchar' datatype.)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (4000) for 'nchar' datatype.)~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: The size '10000' exceeds the maximum allowed (8000) for 'bpchar' datatype.)~~ + + +-- Testing for numeric and decimal +-- Test Case 1: Basic CASE with 6 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 0 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 2: CASE with 5 columns and ELSE +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +99 +50 +22 +44 +66 +~~END~~ + + +-- Test Case 3: CASE with 4 columns and ELSE +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + ELSE COL5 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +42 +10 +11 +33 +55 +~~END~~ + + +-- Test Case 4: CASE with 3 columns and ELSE +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + ELSE COL4 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 5: CASE with 2 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + ELSE COL3 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1234567890123456789 +9876543210987654321 +1111111111111111111 +3333333333333333333 +5555555555555555555 +~~END~~ + + +-- Test Case 6: CASE with 1 column and ELSE +SELECT CASE 2 + WHEN 1 THEN COL1 + ELSE COL2 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +54321.98 +12345.67 +22222.22 +44444.44 +66666.66 +~~END~~ + + +-- Test Case 7: CASE with all columns returning a constant value +SELECT CASE 7 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 999.99 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +1000 +1000 +1000 +1000 +1000 +~~END~~ + + +-- Test Case 8: CASE with mixed constant and column values +SELECT CASE 4 + WHEN 1 THEN 100 + WHEN 2 THEN COL2 + WHEN 3 THEN 300 + WHEN 4 THEN COL4 + WHEN 5 THEN 500 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO +~~START~~ +numeric +9876543210987654321 +1234567890123456789 +2222222222222222222 +4444444444444444444 +6666666666666666666 +~~END~~ + + +-- Test Case 9: CASE with views +SELECT * FROM BABEL_5341_V1; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +SELECT * FROM BABEL_5341_V2; +GO +~~START~~ +numeric +6789 +~~END~~ + + +SELECT * FROM BABEL_5341_V3; +GO +~~START~~ +numeric +1234567890123456 +~~END~~ + + +SELECT * FROM BABEL_5341_V4; +GO +~~START~~ +numeric +0.0003 +~~END~~ + + +SELECT * FROM BABEL_5341_V5; +GO +~~START~~ +numeric +678.90 +~~END~~ + + +SELECT * FROM BABEL_5341_V6; +GO +~~START~~ +numeric +1250.00 +~~END~~ + + +-- Test Case 10: Using the function +SELECT BABEL_5341_F1(100.00); +GO +~~START~~ +numeric +123.4500 +~~END~~ + + +SELECT BABEL_5341_F1(200.00); +GO +~~START~~ +numeric +6789.0000 +~~END~~ + + +SELECT BABEL_5341_F1(300.00); +GO +~~START~~ +numeric +12.3456 +~~END~~ + + +SELECT BABEL_5341_F1(400.00); +GO +~~START~~ +numeric +400.0000 +~~END~~ + + +-- Test Case 11: Basic DECIMAL and NUMERIC usage +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +1234567.89000000 +~~END~~ + + +-- Test Case 12: Different scales within the same precision +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.43 AS DECIMAL(10,2)) + WHEN 3 THEN CAST(123456.7 AS DECIMAL(10,1)) + WHEN 4 THEN CAST(1234567 AS DECIMAL(10,0)) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS RESULT +GO +~~START~~ +numeric +98765.4300 +~~END~~ + + +-- Test Case 13: Mixing DECIMAL and NUMERIC with different precisions +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(12,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(15,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +9.87654321 +~~END~~ + + +-- Test Case 14: Large precisions and scales +SELECT CASE 2 + WHEN 1 THEN CAST(12345678901234567890.1234567890 AS DECIMAL(30,10)) + WHEN 2 THEN CAST(98765432109876543210.9876543210 AS NUMERIC(30,10)) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS DECIMAL(25,10)) + WHEN 4 THEN CAST(9.8765432109876543210 AS NUMERIC(20,19)) + ELSE CAST(0 AS DECIMAL(30,10)) +END AS RESULT +GO +~~START~~ +numeric +98765432109876543210.987654321000000000 +~~END~~ + + +-- Test Case 15: Small fractional parts +SELECT CASE 3 + WHEN 1 THEN CAST(12345.000001 AS DECIMAL(12,6)) + WHEN 2 THEN CAST(98765.0000001 AS NUMERIC(14,7)) + WHEN 3 THEN CAST(1234567.0000000001 AS DECIMAL(18,10)) + WHEN 4 THEN CAST(9.000000000000001 AS NUMERIC(17,15)) + ELSE CAST(0.00000001 AS DECIMAL(10,8)) +END AS RESULT +GO +~~START~~ +numeric +1234567.000000000100000 +~~END~~ + + +-- Test Case 16: Negative numbers +SELECT CASE 2 + WHEN 1 THEN CAST(-12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(-98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(-1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(-9.87654321 AS NUMERIC(9,8)) + ELSE CAST(-0.01 AS DECIMAL(5,2)) +END AS RESULT +GO +~~START~~ +numeric +-98765.43210000 +~~END~~ + + +-- Test Case 17: Potential overflow scenarios +SELECT CASE 3 + WHEN 1 THEN CAST(99999.9999 AS DECIMAL(9,4)) + WHEN 2 THEN CAST(999999.999 AS NUMERIC(9,3)) + WHEN 3 THEN CAST(9999999.99 AS DECIMAL(9,2)) + WHEN 4 THEN CAST(99999999.9 AS NUMERIC(9,1)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT +GO +~~START~~ +numeric +9999999.9900 +~~END~~ + + +-- Test Case 18: Mixing with other numeric types +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765 AS INT) + WHEN 3 THEN CAST(1234567.89 AS FLOAT) + WHEN 4 THEN CAST(9 AS BIGINT) + ELSE CAST(0 AS NUMERIC(5,2)) +END AS RESULT +GO +~~START~~ +float +9.0 +~~END~~ + + + +-- Test Case 19: NUMERIC, DATETIME, and SQL_VARIANT in different branches +DECLARE @var SQL_VARIANT +SET @var = CAST(12345.6789 AS NUMERIC(10,4)) +SELECT CASE + WHEN CAST('2023-05-15' AS DATETIME) > '2023-01-01' THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN @var > 10000 THEN CAST('2023-12-31' AS DATETIME) + WHEN YEAR(GETDATE()) = 2023 THEN @var + ELSE CAST(11111.1111 AS NUMERIC(10,4)) +END AS RESULT +GO +~~START~~ +sql_variant +98765.4321 +~~END~~ + + + +-- Test Case 20: NUMERIC with different precisions, DATETIME, and SQL_VARIANT +DECLARE @var SQL_VARIANT +SET @var = CAST(123456.789 AS NUMERIC(15,3)) +SELECT CASE + WHEN CAST(12345.6789 AS NUMERIC(10,4)) > 10000 THEN CAST(9876543.21 AS NUMERIC(15,2)) + WHEN CAST('2023-05-15' AS DATETIME) < GETDATE() THEN CAST(123.456789 AS NUMERIC(9,6)) + WHEN SQL_VARIANT_PROPERTY(@var, 'Scale') > 2 THEN CAST(GETDATE() AS DATETIME) + ELSE @var +END AS RESULT +GO +~~START~~ +sql_variant +9876543.21 +~~END~~ + + +-- Test Case 21: SQL_VARIANT from BIGINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9223372036854775807 AS BIGINT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 22: SQL_VARIANT from DECIMAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(123.456 AS DECIMAL(10,3)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 23: SQL_VARIANT from FLOAT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(3.14159265359 AS FLOAT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 24: SQL_VARIANT from CHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('A' AS CHAR(1)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 25: SQL_VARIANT from VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('Hello, World!' AS VARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 26: SQL_VARIANT from NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(N'こんにちは' AS NVARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 27: SQL_VARIANT from DATE +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15' AS DATE) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 28: SQL_VARIANT from TIME +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('14:30:00' AS TIME) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 29: SQL_VARIANT from DATETIME2 +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00.1234567' AS DATETIME2(7)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 30: SQL_VARIANT from DATETIMEOFFSET +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00 +01:00' AS DATETIMEOFFSET) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 31: SQL_VARIANT from BIT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1 AS BIT) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 32: SQL_VARIANT from UNIQUEIDENTIFIER +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(NEWID() AS UNIQUEIDENTIFIER) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 33: SQL_VARIANT from VARBINARY +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0x1234567890 AS VARBINARY(10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 34: SQL_VARIANT from NUMERIC(10,2) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567.89 AS NUMERIC(10,2)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 35: SQL_VARIANT from NUMERIC(5,4) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.1234 AS NUMERIC(5,4)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 36: SQL_VARIANT from NUMERIC(20,10) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567890.1234567890 AS NUMERIC(20,10)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 37: SQL_VARIANT from NUMERIC(38,0) (maximum precision, no decimal places) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(12345678901234567890123456789012345678 AS NUMERIC(38,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 38: SQL_VARIANT from NUMERIC(38,38) (maximum precision and scale) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.12345678901234567890123456789012345678 AS NUMERIC(38,38)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 39: SQL_VARIANT from NUMERIC(1,0) (minimum precision) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9 AS NUMERIC(1,0)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 40: SQL_VARIANT from negative NUMERIC +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(-9876.54321 AS NUMERIC(10,5)) AS SQL_VARIANT) +END AS Result +GO +~~START~~ +sql_variant +1.23 +~~END~~ + + +-- Test Case 41: Numeric branch with time +select case 1 + when 1 then cast(1.23 as numeric(20,2)) + when 2 then cast(1900-01-01 as datetime) +END +go +~~START~~ +datetime +1900-01-02 05:31:12.0 +~~END~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type date to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('12:34:56' AS TIME) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type time without time zone to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetime2 to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) +END AS Result +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: CASE/WHEN could not convert type datetimeoffset to numeric)~~ + + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-02 05:31:00.0 +~~END~~ + + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) + WHEN 3 THEN CAST('12:34:56' AS TIME) + WHEN 4 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) + WHEN 5 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) + WHEN 6 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO +~~START~~ +smalldatetime +1900-01-01 00:00:00.0 +~~END~~ + + +-- Test Case 42: NUMERIC and TINYINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(255 AS TINYINT) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Test Case 43: NUMERIC and REAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(3.14 AS REAL) +END AS Result +GO +~~START~~ +real +1.23 +~~END~~ + + +-- Test Case 44: NUMERIC and NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(N'A' AS NCHAR(1)) +END AS Result +GO +~~START~~ +numeric +1.23 +~~END~~ + + +-- Create UDTs +CREATE TYPE NumericType_BABEL_5341 FROM NUMERIC(20,2); +GO + +CREATE TYPE DecimalType_BABEL_5341 FROM DECIMAL(18,4); +GO + +CREATE TYPE BigNumericType_BABEL_5341 FROM NUMERIC(38,10); +GO + +CREATE TYPE SmallDecimalType_BABEL_5341 FROM DECIMAL(5,2); +GO + +-- Test Case 45: Basic CASE with all UDTs +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.9900000000 +~~END~~ + + +-- Test Case 46: CASE with UDTs and different precisions +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS DecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567890123456.7890123456 +~~END~~ + + +-- Test Case 47: CASE with UDTs and mathematical operations +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 * 2 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 / 2 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 + 1000 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 - 50 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +49382.7161000000 +~~END~~ + + +-- Test Case 48: CASE with UDTs and rounding +SELECT CASE 1 + WHEN 1 THEN CAST(ROUND(12345.6789, 2) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(ROUND(98765.4321, 4) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(ROUND(1234567.8901234567890, 10) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(ROUND(99.99, 1) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345.6800000000 +~~END~~ + + +-- Test Case 49: CASE with UDTs and type conversion +SELECT CASE 4 + WHEN 1 THEN CAST(CAST(12345.6789 AS NumericType_BABEL_5341) AS BigNumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(98765.4321 AS DecimalType_BABEL_5341) AS SmallDecimalType_BABEL_5341) + WHEN 3 THEN CAST(CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) AS NumericType_BABEL_5341) + WHEN 4 THEN CAST(CAST(99.99 AS SmallDecimalType_BABEL_5341) AS DecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +99.9900000000 +~~END~~ + + +-- Test Case 50: CASE with UDTs and potential overflow +SELECT CASE 3 + WHEN 1 THEN CAST(9999999999999999.99 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(99999999999999.9999 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(12345678901234567890.1234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(999.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +12345678901234567890.1234567890 +~~END~~ + + +-- Test Case 51: CASE with UDTs and aggregate functions +SELECT CASE 2 + WHEN 1 THEN CAST(AVG(CAST(COLUMN_VALUE AS NumericType_BABEL_5341)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(SUM(CAST(COLUMN_VALUE AS DecimalType_BABEL_5341)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(MAX(CAST(COLUMN_VALUE AS BigNumericType_BABEL_5341)) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(MIN(CAST(COLUMN_VALUE AS SmallDecimalType_BABEL_5341)) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) +GO +~~START~~ +numeric +600.0000000000 +~~END~~ + + +-- Test Case 52: UDTs with INT and BIGINT +SELECT CASE 3 + WHEN 1 THEN CAST(12345 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(9876543210 AS BigNumericType_BABEL_5341) + WHEN 3 THEN CAST(1000 AS INT) + WHEN 4 THEN CAST(9223372036854775807 AS BIGINT) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1000.0000000000 +~~END~~ + + +-- Test Case 53: UDTs with FLOAT and REAL +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS DecimalType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS FLOAT) + WHEN 3 THEN CAST(1234.56 AS REAL) + WHEN 4 THEN CAST(9.87654321 AS NumericType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +float +98765.4321 +~~END~~ + + +-- Test Case 54: UDTs with MONEY and SMALLMONEY +SELECT CASE 4 + WHEN 1 THEN CAST(12345.67 AS MONEY) + WHEN 2 THEN CAST(98.76 AS SMALLMONEY) + WHEN 3 THEN CAST(1234.5678 AS DecimalType_BABEL_5341) + WHEN 4 THEN CAST(9876.54 AS NumericType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +9876.5400 +~~END~~ + + +-- Test Case 55: UDTs with VARCHAR and NVARCHAR +SELECT CASE 3 + WHEN 1 THEN CAST(CAST('12345.67' AS VARCHAR(20)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(N'98765.4321' AS NVARCHAR(20)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST('1234567.8901' AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(N'99.99' AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234567.8901000000 +~~END~~ + + +-- Test Case 56: UDTs with BIT and mathematical operations +SELECT CASE 3 + WHEN 1 THEN CAST(1 AS BIT) * CAST(12345.67 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(0 AS BIT) * CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1 AS BIT) + CAST(1234567.8901 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(1 AS BIT) - CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO +~~START~~ +numeric +1234568.9 +~~END~~ + + +DROP TYPE NumericType_BABEL_5341; +GO + +DROP TYPE DecimalType_BABEL_5341; +GO + +DROP TYPE BigNumericType_BABEL_5341; +GO + +DROP TYPE SmallDecimalType_BABEL_5341; +GO + +-- test cases +-- Test Case 57: Basic DECIMAL and NUMERIC mix +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1))), + (CAST(2.2 AS NUMERIC(3,1))), + (CAST(3.3 AS DECIMAL(3,1))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +2.2 +3.3 +~~END~~ + + +-- Test Case 58: Different precisions and scales +SELECT * FROM (VALUES + (CAST(1.23456 AS DECIMAL(6,5))), + (CAST(23.4567 AS NUMERIC(6,4))), + (CAST(345.678 AS DECIMAL(6,3))), + (CAST(4567.89 AS NUMERIC(6,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23456 +23.45670 +345.67800 +4567.89000 +~~END~~ + + +-- Test Case 59: Large precisions +SELECT * FROM (VALUES + (CAST(1234567890123456789.1234567890 AS DECIMAL(38,10))), + (CAST(9876543210987654321.0987654321 AS NUMERIC(38,10))), + (CAST(1111111111111111111.1111111111 AS DECIMAL(38,10))) +) AS "VALUES"; +GO +~~START~~ +numeric +1234567890123456789.1234567890 +9876543210987654321.0987654321 +1111111111111111111.1111111111 +~~END~~ + + +-- Test Case 60: Small scales +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(38,1))), + (CAST(22.22 AS NUMERIC(38,2))), + (CAST(333.333 AS DECIMAL(38,3))), + (CAST(4444.4444 AS NUMERIC(38,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +22.2 +333.3 +4444.4 +~~END~~ + + +-- Test Case 61: Mix of positive and negative numbers +SELECT * FROM (VALUES + (CAST(-1.23 AS DECIMAL(5,2))), + (CAST(4.56 AS NUMERIC(5,2))), + (CAST(-7.89 AS DECIMAL(5,2))), + (CAST(0.12 AS NUMERIC(5,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +-1.23 +4.56 +-7.89 +0.12 +~~END~~ + + +-- Test Case 62: Very small numbers +SELECT * FROM (VALUES + (CAST(0.000000000123 AS DECIMAL(15,12))), + (CAST(0.000000000456 AS NUMERIC(15,12))), + (CAST(0.000000000789 AS DECIMAL(15,12))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23E-10 +4.56E-10 +7.89E-10 +~~END~~ + + +-- Test Case 63: Very large numbers +SELECT * FROM (VALUES + (CAST(123456789012345678901234567890.12 AS DECIMAL(38,2))), + (CAST(987654321098765432109876543210.98 AS NUMERIC(38,2))), + (CAST(111111111111111111111111111111.11 AS DECIMAL(38,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +123456789012345678901234567890.12 +987654321098765432109876543210.98 +111111111111111111111111111111.11 +~~END~~ + + +-- Test Case 64: Mix of integer and fractional parts +SELECT * FROM (VALUES + (CAST(1 AS DECIMAL(38,0))), + (CAST(2.2 AS NUMERIC(38,1))), + (CAST(3.33 AS DECIMAL(38,2))), + (CAST(4.444 AS NUMERIC(38,3))) +) AS "VALUES"; +GO +~~START~~ +numeric +1 +2 +3 +4 +~~END~~ + + +-- Test Case 65: Edge cases +SELECT * FROM (VALUES + (CAST(0.9999999999999999999999999999999999999 AS DECIMAL(38,37))), + (CAST(9.999999999999999999999999999999999999 AS NUMERIC(38,36))), + (CAST(0.0000000000000000000000000000000000001 AS DECIMAL(38,37))) +) AS "VALUES"; +GO +~~START~~ +numeric +0.999999999999999999999999999999999999 +9.999999999999999999999999999999999999 +0E-36 +~~END~~ + + +-- Test Case 66: Mix of DECIMAL and NUMERIC with different precisions +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(5,1))), + (CAST(2.22 AS NUMERIC(10,2))), + (CAST(3.333 AS DECIMAL(15,3))), + (CAST(4.4444 AS NUMERIC(20,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1000 +2.2200 +3.3330 +4.4444 +~~END~~ + + +-- Test Case 67: Mix of numeric, decimal, integer, and varchar +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), 10, 'ABC'), + (CAST(2.2 AS NUMERIC(3,1)), 20, 'DEF'), + (CAST(3.3 AS DECIMAL(3,1)), 30, 'GHI') +) AS "VALUES" (dec_num, int_num, str_val); +GO +~~START~~ +numeric#!#int#!#varchar +1.1#!#10#!#ABC +2.2#!#20#!#DEF +3.3#!#30#!#GHI +~~END~~ + + +-- Test Case 68: Mix with date, time, and boolean +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(4,2)), CAST('2023-01-01' AS DATE), CAST('10:30:00' AS TIME), TRUE), + (CAST(4.56 AS NUMERIC(4,2)), CAST('2023-02-15' AS DATE), CAST('14:45:00' AS TIME), FALSE), + (CAST(7.89 AS DECIMAL(4,2)), CAST('2023-03-30' AS DATE), CAST('20:15:00' AS TIME), TRUE) +) AS "VALUES" (num_val, date_val, time_val, bool_val); +GO +~~START~~ +numeric#!#date#!#time#!#bit +1.23#!#2023-01-01#!#10:30:00.0000000#!#1 +4.56#!#2023-02-15#!#14:45:00.0000000#!#0 +7.89#!#2023-03-30#!#20:15:00.0000000#!#1 +~~END~~ + + +-- Test Case 69: Mix with timestamp and interval +SELECT * FROM (VALUES + (CAST(123.45 AS DECIMAL(5,2)), CAST('2023-01-01 12:00:00' AS TIMESTAMP), CAST('1 day' AS INTERVAL)), + (CAST(678.90 AS NUMERIC(5,2)), CAST('2023-06-15 18:30:00' AS TIMESTAMP), CAST('2 hours' AS INTERVAL)), + (CAST(246.80 AS DECIMAL(5,2)), CAST('2023-12-31 23:59:59' AS TIMESTAMP), CAST('30 minutes' AS INTERVAL)) +) AS "VALUES" (num_val, ts_val, interval_val); +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: To use the TIMESTAMP datatype, set 'babelfishpg_tsql.escape_hatch_rowversion' to 'ignore')~~ + + +-- Test Case 70: Mix with char, varchar, and text +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), CAST('A' AS CHAR(1)), CAST('ABC' AS VARCHAR(10)), 'This is a text'), + (CAST(2.2 AS NUMERIC(3,1)), CAST('B' AS CHAR(1)), CAST('DEF' AS VARCHAR(10)), 'Another text'), + (CAST(3.3 AS DECIMAL(3,1)), CAST('C' AS CHAR(1)), CAST('GHI' AS VARCHAR(10)), 'Yet another text') +) AS "VALUES" (num_val, char_val, varchar_val, text_val); +GO +~~START~~ +numeric#!#char#!#varchar#!#varchar +1.1#!#A#!#ABC#!#This is a text +2.2#!#B#!#DEF#!#Another text +3.3#!#C#!#GHI#!#Yet another text +~~END~~ + + +-- Test Case 71: Mix with money and bit +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(3,2)), CAST(100.00 AS MONEY), CAST('1' AS BIT)), + (CAST(4.56 AS NUMERIC(3,2)), CAST(200.50 AS MONEY), CAST('0' AS BIT)), + (CAST(7.89 AS DECIMAL(3,2)), CAST(350.75 AS MONEY), CAST('1' AS BIT)) +) AS "VALUES" (num_val, money_val, bit_val); +GO +~~START~~ +numeric#!#money#!#bit +1.23#!#100.0000#!#1 +4.56#!#200.5000#!#0 +7.89#!#350.7500#!#1 +~~END~~ + + +-- Test Case 72: UNION with DECIMAL and INTEGER +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT 456 +ORDER BY value; +GO +~~START~~ +numeric +1.23 +456.00 +~~END~~ + + +-- Test Case 73: UNION with NUMERIC, DECIMAL, and FLOAT +SELECT CAST(1.23456 AS NUMERIC(10,5)) AS value +UNION ALL +SELECT CAST(2.34567 AS DECIMAL(10,5)) +UNION ALL +SELECT CAST(3.45678 AS FLOAT) +ORDER BY value; +GO +~~START~~ +float +1.23456 +2.34567 +3.45678 +~~END~~ + + +-- Test Case 74: UNION with different precisions and scales +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(2.3456 AS NUMERIC(10,4)) +UNION ALL +SELECT CAST(3.456789 AS DECIMAL(15,6)) +ORDER BY value; +GO +~~START~~ +numeric +1.230000 +2.345600 +3.456789 +~~END~~ + + +-- Test Case 75: UNION with negative numbers and zero +SELECT CAST(-1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(0 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(1.23 AS DECIMAL(5,2)) +ORDER BY value; +GO +~~START~~ +numeric +-1.23 +0.00 +1.23 +~~END~~ + + +-- Test Case 75: UNION with large numbers +SELECT CAST(1234567890.12345 AS DECIMAL(20,5)) AS value +UNION ALL +SELECT CAST(9876543210.98765 AS NUMERIC(20,5)) +UNION ALL +SELECT CAST(1111111111.11111 AS DECIMAL(20,5)) +ORDER BY value; +GO +~~START~~ +numeric +1111111111.11111 +1234567890.12345 +9876543210.98765 +~~END~~ + + +-- Test Case 76: UNION with small numbers +SELECT CAST(0.00000123 AS DECIMAL(10,8)) AS value +UNION ALL +SELECT CAST(0.00000456 AS NUMERIC(10,8)) +UNION ALL +SELECT CAST(0.00000789 AS DECIMAL(10,8)) +ORDER BY value; +GO +~~START~~ +numeric +0.00000123 +0.00000456 +0.00000789 +~~END~~ + + +-- Test Case 77: UNION with DECIMAL, NUMERIC, and VARCHAR +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST('7.89' AS VARCHAR(10)) +ORDER BY value; +GO +~~START~~ +numeric +1.2300000000 +4.5600000000 +7.8900000000 +~~END~~ + + +-- Test Case 78: UNION with different integer parts +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(123.45 AS NUMERIC(10,2)) +UNION ALL +SELECT CAST(12345.67 AS DECIMAL(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +123.45 +12345.67 +~~END~~ + + +-- Test Case 79: UNION with extreme values +SELECT CAST(9999999999.99999999 AS DECIMAL(18,8)) AS value +UNION ALL +SELECT CAST(0.00000001 AS NUMERIC(18,8)) +UNION ALL +SELECT CAST(5555555555.55555555 AS DECIMAL(18,8)) +ORDER BY value; +GO +~~START~~ +numeric +1E-8 +5555555555.55555555 +9999999999.99999999 +~~END~~ + + +-- Test Case 80: UNION with NULL values +SELECT CAST(NULL AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(1.23 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(NULL AS DECIMAL(5,2)) +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +1.23 +4.56 +~~END~~ + + +-- Test Case 81: UNION with MONEY type +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(4.56 AS MONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 82: UNION with SMALLMONEY type +SELECT CAST(1.23 AS DECIMAL(6,2)) AS value +UNION ALL +SELECT CAST(4.56 AS SMALLMONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(6,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 83: DECIMAL(38,1) - 37 digits before decimal, 1 after +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(1000000000000000000000000000000000000.0 AS DECIMAL(38,1)) +ORDER BY value; +GO +~~START~~ +numeric +1000000000000000000000000000000000000.0 +1234567890123456789012345678901234567.8 +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 84: DECIMAL(38,2) - 36 digits before decimal, 2 after +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) AS value +UNION ALL +SELECT CAST(999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(100000000000000000000000000000000000.00 AS DECIMAL(38,2)) +ORDER BY value; +GO +~~START~~ +numeric +100000000000000000000000000000000000.00 +123456789012345678901234567890123456.78 +999999999999999999999999999999999999.99 +~~END~~ + + +-- Test Case 85: DECIMAL(38,5) - 33 digits before decimal, 5 after +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) AS value +UNION ALL +SELECT CAST(99999999999999999999999999999999.99999 AS DECIMAL(38,5)) +UNION ALL +SELECT CAST(10000000000000000000000000000000.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +10000000000000000000000000000000.00001 +12345678901234567890123456789012.34567 +99999999999999999999999999999999.99999 +~~END~~ + + +-- Test Case 86: Mixing different scales with precision 38 +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.7 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 88: Very small fractional part with precision 38 +SELECT CAST(9999999999999999999999999999999999999.1 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.01 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 89: Overflow scenarios with precision 38 +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(10000000000000000000000000000000000000.0 AS DECIMAL(38,1)) -- This will cause an overflow +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 90: Mixing DECIMAL and NUMERIC with precision 38 and small scales +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS NUMERIC(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.8 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 91: NULL values with precision 38 and small scales +SELECT CAST(NULL AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(NULL AS NUMERIC(38,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 92: customer query +DECLARE @test_int int = 1; +SELECT a.integer_one, a.integer_two, +ratio = a.integer_one / CONVERT(DECIMAL, a.integer_two), +ratio_case_one = CASE WHEN a.integer_two = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_two = CASE WHEN 1 = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_three = CASE WHEN @test_int = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END +FROM BABEL_5341_T2 a; +GO +~~START~~ +int#!#int#!#numeric#!#numeric#!#numeric#!#numeric +1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 +~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out index 8c161b466c..6a911aa930 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out @@ -13189,7 +13189,7 @@ SELECT * FROM BABEL_5341_V2; GO ~~START~~ numeric -6789 +6789.0000 ~~END~~ @@ -13730,21 +13730,6 @@ smalldatetime ~~END~~ -SELECT CASE 2 - WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) - WHEN 2 THEN CAST(GETDATE() AS DATE) - WHEN 3 THEN CAST(GETDATE() AS TIME) - WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) - WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) - WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) -END AS Result -GO -~~START~~ -smalldatetime -2024-12-06 00:00:00.0 -~~END~~ - - -- Test Case 42: NUMERIC and TINYINT SELECT CASE 1 WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) @@ -13805,7 +13790,7 @@ END AS RESULT GO ~~START~~ numeric -99.99 +99.9900000000 ~~END~~ @@ -13835,7 +13820,7 @@ END AS RESULT GO ~~START~~ numeric -49382.7161 +49382.7161000000 ~~END~~ @@ -13850,7 +13835,7 @@ END AS RESULT GO ~~START~~ numeric -12345.68 +12345.6800000000 ~~END~~ @@ -13865,7 +13850,7 @@ END AS RESULT GO ~~START~~ numeric -99.9900 +99.9900000000 ~~END~~ @@ -13896,7 +13881,7 @@ FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) GO ~~START~~ numeric -600.0000 +600.0000000000 ~~END~~ @@ -13911,7 +13896,7 @@ END AS RESULT GO ~~START~~ numeric -1000 +1000.0000000000 ~~END~~ @@ -13941,7 +13926,7 @@ END AS RESULT GO ~~START~~ numeric -9876.54 +9876.5400 ~~END~~ @@ -13971,7 +13956,7 @@ END AS RESULT GO ~~START~~ numeric -1234568.8901000000 +1234568.9 ~~END~~ @@ -13986,3 +13971,564 @@ GO DROP TYPE SmallDecimalType_BABEL_5341; GO + +-- test cases +-- Test Case 57: Basic DECIMAL and NUMERIC mix +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1))), + (CAST(2.2 AS NUMERIC(3,1))), + (CAST(3.3 AS DECIMAL(3,1))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +2.2 +3.3 +~~END~~ + + +-- Test Case 58: Different precisions and scales +SELECT * FROM (VALUES + (CAST(1.23456 AS DECIMAL(6,5))), + (CAST(23.4567 AS NUMERIC(6,4))), + (CAST(345.678 AS DECIMAL(6,3))), + (CAST(4567.89 AS NUMERIC(6,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23456 +23.45670 +345.67800 +4567.89000 +~~END~~ + + +-- Test Case 59: Large precisions +SELECT * FROM (VALUES + (CAST(1234567890123456789.1234567890 AS DECIMAL(38,10))), + (CAST(9876543210987654321.0987654321 AS NUMERIC(38,10))), + (CAST(1111111111111111111.1111111111 AS DECIMAL(38,10))) +) AS "VALUES"; +GO +~~START~~ +numeric +1234567890123456789.1234567890 +9876543210987654321.0987654321 +1111111111111111111.1111111111 +~~END~~ + + +-- Test Case 60: Small scales +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(38,1))), + (CAST(22.22 AS NUMERIC(38,2))), + (CAST(333.333 AS DECIMAL(38,3))), + (CAST(4444.4444 AS NUMERIC(38,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1 +22.2 +333.3 +4444.4 +~~END~~ + + +-- Test Case 61: Mix of positive and negative numbers +SELECT * FROM (VALUES + (CAST(-1.23 AS DECIMAL(5,2))), + (CAST(4.56 AS NUMERIC(5,2))), + (CAST(-7.89 AS DECIMAL(5,2))), + (CAST(0.12 AS NUMERIC(5,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +-1.23 +4.56 +-7.89 +0.12 +~~END~~ + + +-- Test Case 62: Very small numbers +SELECT * FROM (VALUES + (CAST(0.000000000123 AS DECIMAL(15,12))), + (CAST(0.000000000456 AS NUMERIC(15,12))), + (CAST(0.000000000789 AS DECIMAL(15,12))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.23E-10 +4.56E-10 +7.89E-10 +~~END~~ + + +-- Test Case 63: Very large numbers +SELECT * FROM (VALUES + (CAST(123456789012345678901234567890.12 AS DECIMAL(38,2))), + (CAST(987654321098765432109876543210.98 AS NUMERIC(38,2))), + (CAST(111111111111111111111111111111.11 AS DECIMAL(38,2))) +) AS "VALUES"; +GO +~~START~~ +numeric +123456789012345678901234567890.12 +987654321098765432109876543210.98 +111111111111111111111111111111.11 +~~END~~ + + +-- Test Case 64: Mix of integer and fractional parts +SELECT * FROM (VALUES + (CAST(1 AS DECIMAL(38,0))), + (CAST(2.2 AS NUMERIC(38,1))), + (CAST(3.33 AS DECIMAL(38,2))), + (CAST(4.444 AS NUMERIC(38,3))) +) AS "VALUES"; +GO +~~START~~ +numeric +1 +2 +3 +4 +~~END~~ + + +-- Test Case 65: Edge cases +SELECT * FROM (VALUES + (CAST(0.9999999999999999999999999999999999999 AS DECIMAL(38,37))), + (CAST(9.999999999999999999999999999999999999 AS NUMERIC(38,36))), + (CAST(0.0000000000000000000000000000000000001 AS DECIMAL(38,37))) +) AS "VALUES"; +GO +~~START~~ +numeric +0.999999999999999999999999999999999999 +9.999999999999999999999999999999999999 +0E-36 +~~END~~ + + +-- Test Case 66: Mix of DECIMAL and NUMERIC with different precisions +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(5,1))), + (CAST(2.22 AS NUMERIC(10,2))), + (CAST(3.333 AS DECIMAL(15,3))), + (CAST(4.4444 AS NUMERIC(20,4))) +) AS "VALUES"; +GO +~~START~~ +numeric +1.1000 +2.2200 +3.3330 +4.4444 +~~END~~ + + +-- Test Case 67: Mix of numeric, decimal, integer, and varchar +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), 10, 'ABC'), + (CAST(2.2 AS NUMERIC(3,1)), 20, 'DEF'), + (CAST(3.3 AS DECIMAL(3,1)), 30, 'GHI') +) AS "VALUES" (dec_num, int_num, str_val); +GO +~~START~~ +numeric#!#int#!#varchar +1.1#!#10#!#ABC +2.2#!#20#!#DEF +3.3#!#30#!#GHI +~~END~~ + + +-- Test Case 68: Mix with date, time, and boolean +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(4,2)), CAST('2023-01-01' AS DATE), CAST('10:30:00' AS TIME), TRUE), + (CAST(4.56 AS NUMERIC(4,2)), CAST('2023-02-15' AS DATE), CAST('14:45:00' AS TIME), FALSE), + (CAST(7.89 AS DECIMAL(4,2)), CAST('2023-03-30' AS DATE), CAST('20:15:00' AS TIME), TRUE) +) AS "VALUES" (num_val, date_val, time_val, bool_val); +GO +~~START~~ +numeric#!#date#!#time#!#bit +1.23#!#2023-01-01#!#10:30:00.0000000#!#1 +4.56#!#2023-02-15#!#14:45:00.0000000#!#0 +7.89#!#2023-03-30#!#20:15:00.0000000#!#1 +~~END~~ + + +-- Test Case 69: Mix with timestamp and interval +SELECT * FROM (VALUES + (CAST(123.45 AS DECIMAL(5,2)), CAST('2023-01-01 12:00:00' AS TIMESTAMP), CAST('1 day' AS INTERVAL)), + (CAST(678.90 AS NUMERIC(5,2)), CAST('2023-06-15 18:30:00' AS TIMESTAMP), CAST('2 hours' AS INTERVAL)), + (CAST(246.80 AS DECIMAL(5,2)), CAST('2023-12-31 23:59:59' AS TIMESTAMP), CAST('30 minutes' AS INTERVAL)) +) AS "VALUES" (num_val, ts_val, interval_val); +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: To use the TIMESTAMP datatype, set 'babelfishpg_tsql.escape_hatch_rowversion' to 'ignore')~~ + + +-- Test Case 70: Mix with char, varchar, and text +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), CAST('A' AS CHAR(1)), CAST('ABC' AS VARCHAR(10)), 'This is a text'), + (CAST(2.2 AS NUMERIC(3,1)), CAST('B' AS CHAR(1)), CAST('DEF' AS VARCHAR(10)), 'Another text'), + (CAST(3.3 AS DECIMAL(3,1)), CAST('C' AS CHAR(1)), CAST('GHI' AS VARCHAR(10)), 'Yet another text') +) AS "VALUES" (num_val, char_val, varchar_val, text_val); +GO +~~START~~ +numeric#!#char#!#varchar#!#varchar +1.1#!#A#!#ABC#!#This is a text +2.2#!#B#!#DEF#!#Another text +3.3#!#C#!#GHI#!#Yet another text +~~END~~ + + +-- Test Case 71: Mix with money and bit +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(3,2)), CAST(100.00 AS MONEY), CAST('1' AS BIT)), + (CAST(4.56 AS NUMERIC(3,2)), CAST(200.50 AS MONEY), CAST('0' AS BIT)), + (CAST(7.89 AS DECIMAL(3,2)), CAST(350.75 AS MONEY), CAST('1' AS BIT)) +) AS "VALUES" (num_val, money_val, bit_val); +GO +~~START~~ +numeric#!#money#!#bit +1.23#!#100.0000#!#1 +4.56#!#200.5000#!#0 +7.89#!#350.7500#!#1 +~~END~~ + + +-- Test Case 72: UNION with DECIMAL and INTEGER +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT 456 +ORDER BY value; +GO +~~START~~ +numeric +1.23 +456.00 +~~END~~ + + +-- Test Case 73: UNION with NUMERIC, DECIMAL, and FLOAT +SELECT CAST(1.23456 AS NUMERIC(10,5)) AS value +UNION ALL +SELECT CAST(2.34567 AS DECIMAL(10,5)) +UNION ALL +SELECT CAST(3.45678 AS FLOAT) +ORDER BY value; +GO +~~START~~ +float +1.23456 +2.34567 +3.45678 +~~END~~ + + +-- Test Case 74: UNION with different precisions and scales +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(2.3456 AS NUMERIC(10,4)) +UNION ALL +SELECT CAST(3.456789 AS DECIMAL(15,6)) +ORDER BY value; +GO +~~START~~ +numeric +1.230000 +2.345600 +3.456789 +~~END~~ + + +-- Test Case 75: UNION with negative numbers and zero +SELECT CAST(-1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(0 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(1.23 AS DECIMAL(5,2)) +ORDER BY value; +GO +~~START~~ +numeric +-1.23 +0.00 +1.23 +~~END~~ + + +-- Test Case 75: UNION with large numbers +SELECT CAST(1234567890.12345 AS DECIMAL(20,5)) AS value +UNION ALL +SELECT CAST(9876543210.98765 AS NUMERIC(20,5)) +UNION ALL +SELECT CAST(1111111111.11111 AS DECIMAL(20,5)) +ORDER BY value; +GO +~~START~~ +numeric +1111111111.11111 +1234567890.12345 +9876543210.98765 +~~END~~ + + +-- Test Case 76: UNION with small numbers +SELECT CAST(0.00000123 AS DECIMAL(10,8)) AS value +UNION ALL +SELECT CAST(0.00000456 AS NUMERIC(10,8)) +UNION ALL +SELECT CAST(0.00000789 AS DECIMAL(10,8)) +ORDER BY value; +GO +~~START~~ +numeric +0.00000123 +0.00000456 +0.00000789 +~~END~~ + + +-- Test Case 77: UNION with DECIMAL, NUMERIC, and VARCHAR +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST('7.89' AS VARCHAR(10)) +ORDER BY value; +GO +~~START~~ +numeric +1.2300000000 +4.5600000000 +7.8900000000 +~~END~~ + + +-- Test Case 78: UNION with different integer parts +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(123.45 AS NUMERIC(10,2)) +UNION ALL +SELECT CAST(12345.67 AS DECIMAL(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +123.45 +12345.67 +~~END~~ + + +-- Test Case 79: UNION with extreme values +SELECT CAST(9999999999.99999999 AS DECIMAL(18,8)) AS value +UNION ALL +SELECT CAST(0.00000001 AS NUMERIC(18,8)) +UNION ALL +SELECT CAST(5555555555.55555555 AS DECIMAL(18,8)) +ORDER BY value; +GO +~~START~~ +numeric +1E-8 +5555555555.55555555 +9999999999.99999999 +~~END~~ + + +-- Test Case 80: UNION with NULL values +SELECT CAST(NULL AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(1.23 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(NULL AS DECIMAL(5,2)) +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +1.23 +4.56 +~~END~~ + + +-- Test Case 81: UNION with MONEY type +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(4.56 AS MONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(10,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 82: UNION with SMALLMONEY type +SELECT CAST(1.23 AS DECIMAL(6,2)) AS value +UNION ALL +SELECT CAST(4.56 AS SMALLMONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(6,2)) +ORDER BY value; +GO +~~START~~ +numeric +1.23 +4.56 +7.89 +~~END~~ + + +-- Test Case 83: DECIMAL(38,1) - 37 digits before decimal, 1 after +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(1000000000000000000000000000000000000.0 AS DECIMAL(38,1)) +ORDER BY value; +GO +~~START~~ +numeric +1000000000000000000000000000000000000.0 +1234567890123456789012345678901234567.8 +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 84: DECIMAL(38,2) - 36 digits before decimal, 2 after +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) AS value +UNION ALL +SELECT CAST(999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(100000000000000000000000000000000000.00 AS DECIMAL(38,2)) +ORDER BY value; +GO +~~START~~ +numeric +100000000000000000000000000000000000.00 +123456789012345678901234567890123456.78 +999999999999999999999999999999999999.99 +~~END~~ + + +-- Test Case 85: DECIMAL(38,5) - 33 digits before decimal, 5 after +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) AS value +UNION ALL +SELECT CAST(99999999999999999999999999999999.99999 AS DECIMAL(38,5)) +UNION ALL +SELECT CAST(10000000000000000000000000000000.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +10000000000000000000000000000000.00001 +12345678901234567890123456789012.34567 +99999999999999999999999999999999.99999 +~~END~~ + + +-- Test Case 86: Mixing different scales with precision 38 +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.7 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 88: Very small fractional part with precision 38 +SELECT CAST(9999999999999999999999999999999999999.1 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.01 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 89: Overflow scenarios with precision 38 +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(10000000000000000000000000000000000000.0 AS DECIMAL(38,1)) -- This will cause an overflow +ORDER BY value; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: numeric field overflow)~~ + + +-- Test Case 90: Mixing DECIMAL and NUMERIC with precision 38 and small scales +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS NUMERIC(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO +~~START~~ +numeric +12345678901234567890123456789012.3 +123456789012345678901234567890123456.8 +1234567890123456789012345678901234567.8 +~~END~~ + + +-- Test Case 91: NULL values with precision 38 and small scales +SELECT CAST(NULL AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(NULL AS NUMERIC(38,2)) +ORDER BY value; +GO +~~START~~ +numeric + + +9999999999999999999999999999999999999.9 +~~END~~ + + +-- Test Case 92: customer query +DECLARE @test_int int = 1; +SELECT a.integer_one, a.integer_two, +ratio = a.integer_one / CONVERT(DECIMAL, a.integer_two), +ratio_case_one = CASE WHEN a.integer_two = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_two = CASE WHEN 1 = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_three = CASE WHEN @test_int = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END +FROM BABEL_5341_T2 a; +GO +~~START~~ +int#!#int#!#numeric#!#numeric#!#numeric#!#numeric +1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 +~~END~~ diff --git a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.sql b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.sql index 1765f5a25e..debf59e513 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.sql @@ -34,3 +34,6 @@ GO DROP FUNCTION BABEL_5341_F1; GO + +DROP TABLE BABEL_5341_T2; +GO \ No newline at end of file diff --git a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.sql b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.sql index 9a14e11351..8e78716383 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.sql @@ -139,3 +139,18 @@ BEGIN ); END; GO + +CREATE TABLE BABEL_5341_T2 +( + [integer_one] INT, + [integer_two] INT +); +GO +INSERT INTO BABEL_5341_T2 +( + [integer_one], + [integer_two] +) +VALUES +(1, 3); +GO \ No newline at end of file diff --git a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql index a5956d1ce3..55ad3d01a3 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql @@ -7816,16 +7816,6 @@ SELECT CASE 2 END AS Result GO -SELECT CASE 2 - WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) - WHEN 2 THEN CAST(GETDATE() AS DATE) - WHEN 3 THEN CAST(GETDATE() AS TIME) - WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) - WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) - WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) -END AS Result -GO - -- Test Case 42: NUMERIC and TINYINT SELECT CASE 1 WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) @@ -7992,3 +7982,319 @@ GO DROP TYPE SmallDecimalType_BABEL_5341; GO + +-- test cases +-- Test Case 57: Basic DECIMAL and NUMERIC mix +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1))), + (CAST(2.2 AS NUMERIC(3,1))), + (CAST(3.3 AS DECIMAL(3,1))) +) AS "VALUES"; +GO + +-- Test Case 58: Different precisions and scales +SELECT * FROM (VALUES + (CAST(1.23456 AS DECIMAL(6,5))), + (CAST(23.4567 AS NUMERIC(6,4))), + (CAST(345.678 AS DECIMAL(6,3))), + (CAST(4567.89 AS NUMERIC(6,2))) +) AS "VALUES"; +GO + +-- Test Case 59: Large precisions +SELECT * FROM (VALUES + (CAST(1234567890123456789.1234567890 AS DECIMAL(38,10))), + (CAST(9876543210987654321.0987654321 AS NUMERIC(38,10))), + (CAST(1111111111111111111.1111111111 AS DECIMAL(38,10))) +) AS "VALUES"; +GO + +-- Test Case 60: Small scales +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(38,1))), + (CAST(22.22 AS NUMERIC(38,2))), + (CAST(333.333 AS DECIMAL(38,3))), + (CAST(4444.4444 AS NUMERIC(38,4))) +) AS "VALUES"; +GO + +-- Test Case 61: Mix of positive and negative numbers +SELECT * FROM (VALUES + (CAST(-1.23 AS DECIMAL(5,2))), + (CAST(4.56 AS NUMERIC(5,2))), + (CAST(-7.89 AS DECIMAL(5,2))), + (CAST(0.12 AS NUMERIC(5,2))) +) AS "VALUES"; +GO + +-- Test Case 62: Very small numbers +SELECT * FROM (VALUES + (CAST(0.000000000123 AS DECIMAL(15,12))), + (CAST(0.000000000456 AS NUMERIC(15,12))), + (CAST(0.000000000789 AS DECIMAL(15,12))) +) AS "VALUES"; +GO + +-- Test Case 63: Very large numbers +SELECT * FROM (VALUES + (CAST(123456789012345678901234567890.12 AS DECIMAL(38,2))), + (CAST(987654321098765432109876543210.98 AS NUMERIC(38,2))), + (CAST(111111111111111111111111111111.11 AS DECIMAL(38,2))) +) AS "VALUES"; +GO + +-- Test Case 64: Mix of integer and fractional parts +SELECT * FROM (VALUES + (CAST(1 AS DECIMAL(38,0))), + (CAST(2.2 AS NUMERIC(38,1))), + (CAST(3.33 AS DECIMAL(38,2))), + (CAST(4.444 AS NUMERIC(38,3))) +) AS "VALUES"; +GO + +-- Test Case 65: Edge cases +SELECT * FROM (VALUES + (CAST(0.9999999999999999999999999999999999999 AS DECIMAL(38,37))), + (CAST(9.999999999999999999999999999999999999 AS NUMERIC(38,36))), + (CAST(0.0000000000000000000000000000000000001 AS DECIMAL(38,37))) +) AS "VALUES"; +GO + +-- Test Case 66: Mix of DECIMAL and NUMERIC with different precisions +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(5,1))), + (CAST(2.22 AS NUMERIC(10,2))), + (CAST(3.333 AS DECIMAL(15,3))), + (CAST(4.4444 AS NUMERIC(20,4))) +) AS "VALUES"; +GO + +-- Test Case 67: Mix of numeric, decimal, integer, and varchar +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), 10, 'ABC'), + (CAST(2.2 AS NUMERIC(3,1)), 20, 'DEF'), + (CAST(3.3 AS DECIMAL(3,1)), 30, 'GHI') +) AS "VALUES" (dec_num, int_num, str_val); +GO + +-- Test Case 68: Mix with date, time, and boolean +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(4,2)), CAST('2023-01-01' AS DATE), CAST('10:30:00' AS TIME), TRUE), + (CAST(4.56 AS NUMERIC(4,2)), CAST('2023-02-15' AS DATE), CAST('14:45:00' AS TIME), FALSE), + (CAST(7.89 AS DECIMAL(4,2)), CAST('2023-03-30' AS DATE), CAST('20:15:00' AS TIME), TRUE) +) AS "VALUES" (num_val, date_val, time_val, bool_val); +GO + +-- Test Case 69: Mix with timestamp and interval +SELECT * FROM (VALUES + (CAST(123.45 AS DECIMAL(5,2)), CAST('2023-01-01 12:00:00' AS TIMESTAMP), CAST('1 day' AS INTERVAL)), + (CAST(678.90 AS NUMERIC(5,2)), CAST('2023-06-15 18:30:00' AS TIMESTAMP), CAST('2 hours' AS INTERVAL)), + (CAST(246.80 AS DECIMAL(5,2)), CAST('2023-12-31 23:59:59' AS TIMESTAMP), CAST('30 minutes' AS INTERVAL)) +) AS "VALUES" (num_val, ts_val, interval_val); +GO + +-- Test Case 70: Mix with char, varchar, and text +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), CAST('A' AS CHAR(1)), CAST('ABC' AS VARCHAR(10)), 'This is a text'), + (CAST(2.2 AS NUMERIC(3,1)), CAST('B' AS CHAR(1)), CAST('DEF' AS VARCHAR(10)), 'Another text'), + (CAST(3.3 AS DECIMAL(3,1)), CAST('C' AS CHAR(1)), CAST('GHI' AS VARCHAR(10)), 'Yet another text') +) AS "VALUES" (num_val, char_val, varchar_val, text_val); +GO + +-- Test Case 71: Mix with money and bit +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(3,2)), CAST(100.00 AS MONEY), CAST('1' AS BIT)), + (CAST(4.56 AS NUMERIC(3,2)), CAST(200.50 AS MONEY), CAST('0' AS BIT)), + (CAST(7.89 AS DECIMAL(3,2)), CAST(350.75 AS MONEY), CAST('1' AS BIT)) +) AS "VALUES" (num_val, money_val, bit_val); +GO + +-- Test Case 72: UNION with DECIMAL and INTEGER +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT 456 +ORDER BY value; +GO + +-- Test Case 73: UNION with NUMERIC, DECIMAL, and FLOAT +SELECT CAST(1.23456 AS NUMERIC(10,5)) AS value +UNION ALL +SELECT CAST(2.34567 AS DECIMAL(10,5)) +UNION ALL +SELECT CAST(3.45678 AS FLOAT) +ORDER BY value; +GO + +-- Test Case 74: UNION with different precisions and scales +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(2.3456 AS NUMERIC(10,4)) +UNION ALL +SELECT CAST(3.456789 AS DECIMAL(15,6)) +ORDER BY value; +GO + +-- Test Case 75: UNION with negative numbers and zero +SELECT CAST(-1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(0 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(1.23 AS DECIMAL(5,2)) +ORDER BY value; +GO + +-- Test Case 75: UNION with large numbers +SELECT CAST(1234567890.12345 AS DECIMAL(20,5)) AS value +UNION ALL +SELECT CAST(9876543210.98765 AS NUMERIC(20,5)) +UNION ALL +SELECT CAST(1111111111.11111 AS DECIMAL(20,5)) +ORDER BY value; +GO + +-- Test Case 76: UNION with small numbers +SELECT CAST(0.00000123 AS DECIMAL(10,8)) AS value +UNION ALL +SELECT CAST(0.00000456 AS NUMERIC(10,8)) +UNION ALL +SELECT CAST(0.00000789 AS DECIMAL(10,8)) +ORDER BY value; +GO + +-- Test Case 77: UNION with DECIMAL, NUMERIC, and VARCHAR +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST('7.89' AS VARCHAR(10)) +ORDER BY value; +GO + +-- Test Case 78: UNION with different integer parts +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(123.45 AS NUMERIC(10,2)) +UNION ALL +SELECT CAST(12345.67 AS DECIMAL(10,2)) +ORDER BY value; +GO + +-- Test Case 79: UNION with extreme values +SELECT CAST(9999999999.99999999 AS DECIMAL(18,8)) AS value +UNION ALL +SELECT CAST(0.00000001 AS NUMERIC(18,8)) +UNION ALL +SELECT CAST(5555555555.55555555 AS DECIMAL(18,8)) +ORDER BY value; +GO + +-- Test Case 80: UNION with NULL values +SELECT CAST(NULL AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(1.23 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(NULL AS DECIMAL(5,2)) +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +ORDER BY value; +GO + +-- Test Case 81: UNION with MONEY type +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(4.56 AS MONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(10,2)) +ORDER BY value; +GO + +-- Test Case 82: UNION with SMALLMONEY type +SELECT CAST(1.23 AS DECIMAL(6,2)) AS value +UNION ALL +SELECT CAST(4.56 AS SMALLMONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(6,2)) +ORDER BY value; +GO + +-- Test Case 83: DECIMAL(38,1) - 37 digits before decimal, 1 after +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(1000000000000000000000000000000000000.0 AS DECIMAL(38,1)) +ORDER BY value; +GO + +-- Test Case 84: DECIMAL(38,2) - 36 digits before decimal, 2 after +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) AS value +UNION ALL +SELECT CAST(999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(100000000000000000000000000000000000.00 AS DECIMAL(38,2)) +ORDER BY value; +GO + +-- Test Case 85: DECIMAL(38,5) - 33 digits before decimal, 5 after +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) AS value +UNION ALL +SELECT CAST(99999999999999999999999999999999.99999 AS DECIMAL(38,5)) +UNION ALL +SELECT CAST(10000000000000000000000000000000.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO + +-- Test Case 86: Mixing different scales with precision 38 +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO + +-- Test Case 88: Very small fractional part with precision 38 +SELECT CAST(9999999999999999999999999999999999999.1 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.01 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO + +-- Test Case 89: Overflow scenarios with precision 38 +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(10000000000000000000000000000000000000.0 AS DECIMAL(38,1)) -- This will cause an overflow +ORDER BY value; +GO + +-- Test Case 90: Mixing DECIMAL and NUMERIC with precision 38 and small scales +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS NUMERIC(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO + +-- Test Case 91: NULL values with precision 38 and small scales +SELECT CAST(NULL AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(NULL AS NUMERIC(38,2)) +ORDER BY value; +GO + +-- Test Case 92: customer query +DECLARE @test_int int = 1; +SELECT a.integer_one, a.integer_two, +ratio = a.integer_one / CONVERT(DECIMAL, a.integer_two), +ratio_case_one = CASE WHEN a.integer_two = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_two = CASE WHEN 1 = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_three = CASE WHEN @test_int = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END +FROM BABEL_5341_T2 a; +GO \ No newline at end of file diff --git a/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-cleanup.sql b/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-cleanup.sql new file mode 100644 index 0000000000..debf59e513 --- /dev/null +++ b/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-cleanup.sql @@ -0,0 +1,39 @@ + +DROP VIEW BABEL_5103_V1; +GO + +DROP TABLE BABEL_5103_T1; +GO + +DROP VIEW BABEL_5103_V2; +GO + +DROP FUNCTION BABEL_5103_F1; +GO + +DROP TABLE BABEL_5341_T1; +GO + +DROP VIEW BABEL_5341_V1; +GO + +DROP VIEW BABEL_5341_V2; +GO + +DROP VIEW BABEL_5341_V3; +GO + +DROP VIEW BABEL_5341_V4; +GO + +DROP VIEW BABEL_5341_V5; +GO + +DROP VIEW BABEL_5341_V6; +GO + +DROP FUNCTION BABEL_5341_F1; +GO + +DROP TABLE BABEL_5341_T2; +GO \ No newline at end of file diff --git a/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-prepare.sql b/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-prepare.sql new file mode 100644 index 0000000000..8e78716383 --- /dev/null +++ b/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-prepare.sql @@ -0,0 +1,156 @@ +CREATE TABLE BABEL_5103_T1( + COL1 VARCHAR(2000) NOT NULL, + COL2 AS CAST(COL1 AS NCHAR(2001)), + COL3 AS CAST(COL1 AS VARCHAR(MAX)), + COL4 AS CAST(COL1 AS NVARCHAR(2001)), + COL5 AS CAST(COL1 AS TEXT), + COL6 AS CAST(COL1 AS NTEXT) +) +GO + +INSERT INTO BABEL_5103_T1 (COL1) +VALUES (N'Registration Card - Standard'); +GO + +INSERT INTO BABEL_5103_T1 (COL1) +VALUES (N'بطاقة التسجيل - قياسية'); +GO + +INSERT INTO BABEL_5103_T1 (COL1) +VALUES (N'登録カード–標準'); +GO + +CREATE VIEW BABEL_5103_V1 AS +SELECT COL1, COL2, COL3, COL4, COL5, COL6 +FROM BABEL_5103_T1; +GO + +CREATE VIEW BABEL_5103_V2 AS +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(10)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(10)) +END AS RESULT +GO + +CREATE FUNCTION BABEL_5103_F1(@ARG NVARCHAR(1001)) +RETURNS NVARCHAR(1001) +AS +BEGIN + RETURN ( + CASE + WHEN @ARG = 'REGULAR' THEN 'REGULAR' + WHEN @ARG = N'登録カード–標準' THEN N'登録カード–標準' + WHEN @ARG = N'بطاقة التسجيل - قياسية'THEN N'بطاقة التسجيل - قياسية' + END + ); +END; +GO + +CREATE TABLE BABEL_5341_T1 ( + COL1 NUMERIC(20,2), + COL2 DECIMAL(20,2), + COL3 NUMERIC(38,0), + COL4 DECIMAL(38,0), + COL5 NUMERIC(2,0), + COL6 DECIMAL(2,0) +); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (12345.67, 54321.98, 1234567890123456789, 9876543210987654321, 42, 99); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (98765.43, 12345.67, 9876543210987654321, 1234567890123456789, 10, 50); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (11111.11, 22222.22, 1111111111111111111, 2222222222222222222, 11, 22); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (33333.33, 44444.44, 3333333333333333333, 4444444444444444444, 33, 44); +GO + +INSERT INTO BABEL_5341_T1 (COL1, COL2, COL3, COL4, COL5, COL6) +VALUES (55555.55, 66666.66, 5555555555555555555, 6666666666666666666, 55, 66); +GO + +CREATE VIEW BABEL_5341_V1 AS +SELECT CASE 3 + WHEN 1 THEN CAST(123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(678.90 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(1234.56 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V2 AS +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(6789 AS NUMERIC(10,0)) + WHEN 3 THEN CAST(12.3456 AS NUMERIC(10,4)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V3 AS +SELECT CASE 1 + WHEN 1 THEN CAST(1234567890123456 AS NUMERIC(20,0)) + WHEN 2 THEN CAST(9876543210987654 AS NUMERIC(20,0)) + WHEN 3 THEN CAST(1111222233334444 AS NUMERIC(20,0)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V4 AS +SELECT CASE 3 + WHEN 1 THEN CAST(0.0001 AS NUMERIC(10,4)) + WHEN 2 THEN CAST(0.0002 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(0.0003 AS NUMERIC(10,4)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V5 AS +SELECT CASE 2 + WHEN 1 THEN CAST(-123.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(678.90 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(-1234.56 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE VIEW BABEL_5341_V6 AS +SELECT CASE 3 + WHEN 1 THEN CAST(100 + 23.45 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(1000 - 321.10 AS NUMERIC(10,2)) + WHEN 3 THEN CAST(500 * 2.5 AS NUMERIC(10,2)) +END AS RESULT +GO + +CREATE FUNCTION BABEL_5341_F1(@ARG NUMERIC(20,2)) +RETURNS NUMERIC(20,4) +AS +BEGIN + RETURN ( + CASE + WHEN @ARG = 100.00 THEN CAST(123.45 AS NUMERIC(20,2)) + WHEN @ARG = 200.00 THEN CAST(6789 AS NUMERIC(20,0)) + WHEN @ARG = 300.00 THEN CAST(12.3456 AS NUMERIC(20,4)) + ELSE @ARG + END + ); +END; +GO + +CREATE TABLE BABEL_5341_T2 +( + [integer_one] INT, + [integer_two] INT +); +GO +INSERT INTO BABEL_5341_T2 +( + [integer_one], + [integer_two] +) +VALUES +(1, 3); +GO \ No newline at end of file diff --git a/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-verify.sql b/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-verify.sql new file mode 100644 index 0000000000..76b90ffce2 --- /dev/null +++ b/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-verify.sql @@ -0,0 +1,8301 @@ +-- sla 100000 +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO + +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO + +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_T1 +GO + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO + +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO + +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 +END AS RESULT FROM BABEL_5103_V1 +GO + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_T1 +GO + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO + +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO + +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 +END AS RESULT FROM BABEL_5103_V1 +GO + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_T1 +GO + +SELECT CASE 1 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_V1 +GO + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_T1 +GO + +SELECT CASE 2 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 +END AS RESULT FROM BABEL_5103_V1 +GO + +-- Function call +SELECT BABEL_5103_F1('REGULAR'); +GO + +SELECT BABEL_5103_F1(N'登録カード–標準'); +GO + +SELECT BABEL_5103_F1(N'بطاقة التسجيل - قياسية'); +GO + +-- selecting from view +SELECT * FROM BABEL_5103_V2 +GO + +-- single branch +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS NTEXT) +END AS RESULT +GO + +-- single branch with multibyte character +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +-- multiple branch without NULL one being NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +-- multiple branch without NULL one being VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +-- multiple branch without NULL one being CHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS Char(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS Char(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS CHAR(100)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +-- multiple branch without NULL one being NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS NCHAR(100)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +-- multiple branch without NULL one being TEXT +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS TEXT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS TEXT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +-- multiple branch with one being string literal +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 3 + WHEN 1 THEN N'登録カード–標準' + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +-- multiple branches one being NULL +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +-- NULL tests +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NVARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS Char(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS CHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST('char0' AS TEXT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS Char(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) + WHEN 3 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NVARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS Char(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN NULL + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) + WHEN 3 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +-- other datatypes then string +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(123.456 AS FLOAT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(123.456 AS BIGINT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('2024-01-01' AS DATE) + WHEN 2 THEN CAST('2024-09-27 12:34:56' AS DATETIME) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('12:34:56' AS TIME) + WHEN 2 THEN CAST('2024-09-27 12:34:56.1234567' AS DATETIME2(7)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1 AS BIT) + WHEN 2 THEN CAST(0 AS BIT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BINARY(3)) + WHEN 2 THEN CAST(0xABCDEF AS VARBINARY(6)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1000.00 AS MONEY) + WHEN 2 THEN CAST(100.00 AS SMALLMONEY) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123.456 AS FLOAT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456 AS DECIMAL(10, 2)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123.456 AS BIGINT) + WHEN 2 THEN CAST(789.123 AS NUMERIC(10, 3)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS SMALLINT) + WHEN 2 THEN CAST(456789123 AS BIGINT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('2024-01-01' AS DATE) + WHEN 2 THEN CAST('2024-09-27 12:34:56' AS DATETIME) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('12:34:56' AS TIME) + WHEN 2 THEN CAST('2024-09-27 12:34:56.1234567' AS DATETIME2(7)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(1 AS BIT) + WHEN 2 THEN CAST(0 AS BIT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BINARY(3)) + WHEN 2 THEN CAST(0xABCDEF AS VARBINARY(6)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(1000.00 AS MONEY) + WHEN 2 THEN CAST(100.00 AS SMALLMONEY) +END AS RESULT +GO + +-- Collation tests +-- FIX ME: Following test cases shows behaviour mismatch, +-- When we compare N' 比尔·拉莫斯 ' COLLATE japanese_ci_as +-- with N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS for CASE expression, +-- Gives 'true' (as used in PG), whereas it should give 'false' (as in TSQL). + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN CAST('abcd' AS VARCHAR(100)) + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' 比尔·拉莫斯 ' AS VARCHAR(100)) + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' +END AS RESULT +GO + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN CAST(N' abc🙂defghi🙂🙂 ' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 'abcd' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS +END AS RESULT +GO + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE japanese_ci_as + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as +END AS RESULT +GO + +SELECT CASE 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS +END AS RESULT +GO + +SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE japanese_ci_as + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE japanese_ci_as + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE japanese_ci_as + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as +END AS RESULT +GO + +SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE ARABIC_CI_AS + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE ARABIC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE ARABIC_CI_AS +END AS RESULT +GO + +SELECT CASE 'abcd' COLLATE ARABIC_CI_AS + WHEN 'abcd' COLLATE japanese_ci_as THEN 'abcd' COLLATE CHINESE_PRC_CI_AS + WHEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS THEN N' 比尔·拉莫斯 ' COLLATE CHINESE_PRC_CI_AS + WHEN N'بطاقة التسجيل - قياسية' COLLATE ARABIC_CI_AS THEN N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_AS + WHEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS THEN N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS +END AS RESULT +GO + +--- SYSNAME tests +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN 'abc' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS sysname) +END AS RESULT +GO + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS sysname) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS sysname) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS sysname) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS sysname) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS sysname) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS sysname) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS sysname) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +--- UDT testing +create type BABEL_CASE_EXPR_TEST_UDT from NVARCHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from sysname; +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + + +create type BABEL_CASE_EXPR_TEST_UDT from VARCHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from CHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from NCHAR(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from TEXT; +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +create type BABEL_CASE_EXPR_TEST_UDT from NTEXT; +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + + +SELECT CASE 1 + WHEN 1 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- multiple branch one being Binary +create type BABEL_CASE_EXPR_TEST_UDT from BINARY(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 0x123456 +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 0x123456 +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 0x123456 + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(0x123456 AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- multiple branch one being VARBINARY +create type BABEL_CASE_EXPR_TEST_UDT from VARBINARY(100); +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'بطاقة التسجيل - قياسية' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'abc' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 3 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- multiple UDT branches +create type BABEL_CASE_EXPR_TEST_UDT0 from NVARCHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT1 from NCHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT2 from CHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT3 from VARCHAR(100); +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'بطاقة التسجيل - قياسية' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST('char' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT0; +go + +drop type BABEL_CASE_EXPR_TEST_UDT1; +go + +drop type BABEL_CASE_EXPR_TEST_UDT2; +go + +drop type BABEL_CASE_EXPR_TEST_UDT3; +go + +-- Numeric datatypes +create type BABEL_CASE_EXPR_TEST_UDT0 from INT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT1 from DECIMAL; +GO + +create type BABEL_CASE_EXPR_TEST_UDT2 from FLOAT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT3 from BIT; +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(2.300 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(12.3 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(1 AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(1.345 AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(1 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(1321 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST(1.234 AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(1235 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.345 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(234.234 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(346 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(04545 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(12.4 AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(1 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST(234.234 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 2 THEN CAST(123.3 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(546 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 2 THEN CAST(54 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.123 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 2 THEN CAST(23 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(6356 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(3456.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 3 THEN CAST(0 AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(23.12 AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(2354 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT0; +go + +drop type BABEL_CASE_EXPR_TEST_UDT1; +go + +drop type BABEL_CASE_EXPR_TEST_UDT2; +go + +drop type BABEL_CASE_EXPR_TEST_UDT3; +go + +-- Mixture of numeric and string types +create type BABEL_CASE_EXPR_TEST_UDT0 from INT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT1 from NCHAR(100); +GO + +create type BABEL_CASE_EXPR_TEST_UDT2 from FLOAT; +GO + +create type BABEL_CASE_EXPR_TEST_UDT3 from VARCHAR(100); +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(2.300 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(1321 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(1235 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.345 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(346 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(04545 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT1) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 3 THEN CAST(234.234 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT3) + WHEN 2 THEN CAST(3.456 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(546 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(54 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 3 THEN CAST(0.123 AS BABEL_CASE_EXPR_TEST_UDT2) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(6356 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS BABEL_CASE_EXPR_TEST_UDT0) + WHEN 2 THEN CAST(3456.34 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 3 THEN CAST('char1' AS BABEL_CASE_EXPR_TEST_UDT3) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS BABEL_CASE_EXPR_TEST_UDT2) + WHEN 2 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT1) + WHEN 3 THEN CAST(2354 AS BABEL_CASE_EXPR_TEST_UDT0) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT0; +go + +drop type BABEL_CASE_EXPR_TEST_UDT1; +go + +drop type BABEL_CASE_EXPR_TEST_UDT2; +go + +drop type BABEL_CASE_EXPR_TEST_UDT3; +go + +-- Mixture of datatypes and numeric without UDT +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(2.300 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS INT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS NCHAR(100)) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS INT) + WHEN 2 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS FLOAT) + WHEN 2 THEN CAST(N'登録カード–標準' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(N'登録カード–標準' AS VARCHAR(100)) + WHEN 2 THEN CAST(1321 AS INT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(1235 AS INT) + WHEN 3 THEN CAST(0.345 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(346 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(04545 AS INT) + WHEN 3 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS VARCHAR(100)) + WHEN 3 THEN CAST(234.234 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS VARCHAR(100)) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(546 AS INT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST(54 AS INT) + WHEN 3 THEN CAST(0.123 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN 'abc' + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(6356 AS INT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS INT) + WHEN 2 THEN CAST(3456.34 AS FLOAT) + WHEN 3 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS FLOAT) + WHEN 2 THEN CAST('char0' AS NCHAR(100)) + WHEN 3 THEN CAST(2354 AS INT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(123 AS INT) + WHEN 2 THEN CAST(2.300 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(54132 AS INT) + WHEN 2 THEN CAST(0 AS BIT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(12.3 AS DECIMAL) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(324 AS INT) + WHEN 2 THEN CAST(1 AS BIT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(5.34 AS FLOAT) + WHEN 2 THEN CAST(1.345 AS DECIMAL) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(1 AS BIT) + WHEN 2 THEN CAST(1321 AS INT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(0 AS BIT) + WHEN 3 THEN CAST(1.234 AS DECIMAL) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(1235 AS INT) + WHEN 3 THEN CAST(0.345 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(234.234 AS DECIMAL) + WHEN 3 THEN CAST(346 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(04545 AS INT) + WHEN 3 THEN CAST(12.4 AS DECIMAL) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.24 AS DECIMAL) + WHEN 2 THEN CAST(1 AS BIT) + WHEN 3 THEN CAST(234.234 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0 AS BIT) + WHEN 2 THEN CAST(3.456 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 2 THEN CAST(123.3 AS DECIMAL) + WHEN 3 THEN CAST(546 AS INT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 2 THEN CAST(54 AS INT) + WHEN 3 THEN CAST(0.123 AS FLOAT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 2 THEN CAST(23 AS DECIMAL) + WHEN 3 THEN CAST(6356 AS INT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(234 AS INT) + WHEN 2 THEN CAST(3456.34 AS FLOAT) + WHEN 3 THEN CAST(0 AS BIT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(345.345 AS FLOAT) + WHEN 2 THEN CAST(23.12 AS DECIMAL) + WHEN 3 THEN CAST(2354 AS INT) +END AS RESULT +GO + +-- UDT on varchar(max) +create type BABEL_CASE_EXPR_TEST_UDT from varchar(max); +go + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- UDT on nvarchar(max) +create type BABEL_CASE_EXPR_TEST_UDT from nvarchar(max); +go + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('abc' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN 'a' +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS VARCHAR(1)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS CHAR(1)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NCHAR(1)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('char0' AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +drop type BABEL_CASE_EXPR_TEST_UDT; +go + +-- With max typmod +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS VARCHAR(MAX)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS CHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('char0' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('char1' AS NCHAR(100)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(1)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(1)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NTEXT) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS TEXT) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO + +SELECT CASE 1 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS VARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS NCHAR(10000)) +END AS RESULT +GO + +SELECT CASE 2 + WHEN 1 THEN CAST('ASDGASDKGJNASDLIUFAISDUFB' AS NVARCHAR(MAX)) + WHEN 2 THEN CAST('NCHAR' AS CHAR(10000)) +END AS RESULT +GO + +-- Testing for numeric and decimal +-- Test Case 1: Basic CASE with 6 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 0 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 2: CASE with 5 columns and ELSE +SELECT CASE 6 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 3: CASE with 4 columns and ELSE +SELECT CASE 5 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + ELSE COL5 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 4: CASE with 3 columns and ELSE +SELECT CASE 4 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + ELSE COL4 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 5: CASE with 2 columns and ELSE +SELECT CASE 3 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + ELSE COL3 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 6: CASE with 1 column and ELSE +SELECT CASE 2 + WHEN 1 THEN COL1 + ELSE COL2 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 7: CASE with all columns returning a constant value +SELECT CASE 7 + WHEN 1 THEN COL1 + WHEN 2 THEN COL2 + WHEN 3 THEN COL3 + WHEN 4 THEN COL4 + WHEN 5 THEN COL5 + WHEN 6 THEN COL6 + ELSE 999.99 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 8: CASE with mixed constant and column values +SELECT CASE 4 + WHEN 1 THEN 100 + WHEN 2 THEN COL2 + WHEN 3 THEN 300 + WHEN 4 THEN COL4 + WHEN 5 THEN 500 + ELSE COL6 +END AS RESULT +FROM BABEL_5341_T1; +GO + +-- Test Case 9: CASE with views +SELECT * FROM BABEL_5341_V1; +GO + +SELECT * FROM BABEL_5341_V2; +GO + +SELECT * FROM BABEL_5341_V3; +GO + +SELECT * FROM BABEL_5341_V4; +GO + +SELECT * FROM BABEL_5341_V5; +GO + +SELECT * FROM BABEL_5341_V6; +GO + +-- Test Case 10: Using the function +SELECT BABEL_5341_F1(100.00); +GO + +SELECT BABEL_5341_F1(200.00); +GO + +SELECT BABEL_5341_F1(300.00); +GO + +SELECT BABEL_5341_F1(400.00); +GO + +-- Test Case 11: Basic DECIMAL and NUMERIC usage +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO + +-- Test Case 12: Different scales within the same precision +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.43 AS DECIMAL(10,2)) + WHEN 3 THEN CAST(123456.7 AS DECIMAL(10,1)) + WHEN 4 THEN CAST(1234567 AS DECIMAL(10,0)) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS RESULT +GO + +-- Test Case 13: Mixing DECIMAL and NUMERIC with different precisions +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765.4321 AS NUMERIC(12,4)) + WHEN 3 THEN CAST(1234567.89 AS DECIMAL(15,2)) + WHEN 4 THEN CAST(9.87654321 AS NUMERIC(9,8)) + ELSE CAST(0 AS DECIMAL(5,2)) +END AS RESULT +GO + +-- Test Case 14: Large precisions and scales +SELECT CASE 2 + WHEN 1 THEN CAST(12345678901234567890.1234567890 AS DECIMAL(30,10)) + WHEN 2 THEN CAST(98765432109876543210.9876543210 AS NUMERIC(30,10)) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS DECIMAL(25,10)) + WHEN 4 THEN CAST(9.8765432109876543210 AS NUMERIC(20,19)) + ELSE CAST(0 AS DECIMAL(30,10)) +END AS RESULT +GO + +-- Test Case 15: Small fractional parts +SELECT CASE 3 + WHEN 1 THEN CAST(12345.000001 AS DECIMAL(12,6)) + WHEN 2 THEN CAST(98765.0000001 AS NUMERIC(14,7)) + WHEN 3 THEN CAST(1234567.0000000001 AS DECIMAL(18,10)) + WHEN 4 THEN CAST(9.000000000000001 AS NUMERIC(17,15)) + ELSE CAST(0.00000001 AS DECIMAL(10,8)) +END AS RESULT +GO + +-- Test Case 16: Negative numbers +SELECT CASE 2 + WHEN 1 THEN CAST(-12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(-98765.4321 AS NUMERIC(10,4)) + WHEN 3 THEN CAST(-1234567.89 AS DECIMAL(12,2)) + WHEN 4 THEN CAST(-9.87654321 AS NUMERIC(9,8)) + ELSE CAST(-0.01 AS DECIMAL(5,2)) +END AS RESULT +GO + +-- Test Case 17: Potential overflow scenarios +SELECT CASE 3 + WHEN 1 THEN CAST(99999.9999 AS DECIMAL(9,4)) + WHEN 2 THEN CAST(999999.999 AS NUMERIC(9,3)) + WHEN 3 THEN CAST(9999999.99 AS DECIMAL(9,2)) + WHEN 4 THEN CAST(99999999.9 AS NUMERIC(9,1)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT +GO + +-- Test Case 18: Mixing with other numeric types +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS DECIMAL(10,4)) + WHEN 2 THEN CAST(98765 AS INT) + WHEN 3 THEN CAST(1234567.89 AS FLOAT) + WHEN 4 THEN CAST(9 AS BIGINT) + ELSE CAST(0 AS NUMERIC(5,2)) +END AS RESULT +GO + +-- Test Case 19: NUMERIC, DATETIME, and SQL_VARIANT in different branches +DECLARE @var SQL_VARIANT +SET @var = CAST(12345.6789 AS NUMERIC(10,4)) + +SELECT CASE + WHEN CAST('2023-05-15' AS DATETIME) > '2023-01-01' THEN CAST(98765.4321 AS NUMERIC(10,4)) + WHEN @var > 10000 THEN CAST('2023-12-31' AS DATETIME) + WHEN YEAR(GETDATE()) = 2023 THEN @var + ELSE CAST(11111.1111 AS NUMERIC(10,4)) +END AS RESULT +GO + +-- Test Case 20: NUMERIC with different precisions, DATETIME, and SQL_VARIANT +DECLARE @var SQL_VARIANT +SET @var = CAST(123456.789 AS NUMERIC(15,3)) + +SELECT CASE + WHEN CAST(12345.6789 AS NUMERIC(10,4)) > 10000 THEN CAST(9876543.21 AS NUMERIC(15,2)) + WHEN CAST('2023-05-15' AS DATETIME) < GETDATE() THEN CAST(123.456789 AS NUMERIC(9,6)) + WHEN SQL_VARIANT_PROPERTY(@var, 'Scale') > 2 THEN CAST(GETDATE() AS DATETIME) + ELSE @var +END AS RESULT +GO + +-- Test Case 21: SQL_VARIANT from BIGINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9223372036854775807 AS BIGINT) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 22: SQL_VARIANT from DECIMAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(123.456 AS DECIMAL(10,3)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 23: SQL_VARIANT from FLOAT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(3.14159265359 AS FLOAT) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 24: SQL_VARIANT from CHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('A' AS CHAR(1)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 25: SQL_VARIANT from VARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('Hello, World!' AS VARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 26: SQL_VARIANT from NVARCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(N'こんにちは' AS NVARCHAR(50)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 27: SQL_VARIANT from DATE +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15' AS DATE) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 28: SQL_VARIANT from TIME +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('14:30:00' AS TIME) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 29: SQL_VARIANT from DATETIME2 +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00.1234567' AS DATETIME2(7)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 30: SQL_VARIANT from DATETIMEOFFSET +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST('2023-05-15 14:30:00 +01:00' AS DATETIMEOFFSET) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 31: SQL_VARIANT from BIT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1 AS BIT) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 32: SQL_VARIANT from UNIQUEIDENTIFIER +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(NEWID() AS UNIQUEIDENTIFIER) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 33: SQL_VARIANT from VARBINARY +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0x1234567890 AS VARBINARY(10)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 34: SQL_VARIANT from NUMERIC(10,2) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567.89 AS NUMERIC(10,2)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 35: SQL_VARIANT from NUMERIC(5,4) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.1234 AS NUMERIC(5,4)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 36: SQL_VARIANT from NUMERIC(20,10) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(1234567890.1234567890 AS NUMERIC(20,10)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 37: SQL_VARIANT from NUMERIC(38,0) (maximum precision, no decimal places) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(12345678901234567890123456789012345678 AS NUMERIC(38,0)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 38: SQL_VARIANT from NUMERIC(38,38) (maximum precision and scale) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(0.12345678901234567890123456789012345678 AS NUMERIC(38,38)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 39: SQL_VARIANT from NUMERIC(1,0) (minimum precision) +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(9 AS NUMERIC(1,0)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 40: SQL_VARIANT from negative NUMERIC +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(CAST(-9876.54321 AS NUMERIC(10,5)) AS SQL_VARIANT) +END AS Result +GO + +-- Test Case 41: Numeric branch with time +select case 1 + when 1 then cast(1.23 as numeric(20,2)) + when 2 then cast(1900-01-01 as datetime) +END +go + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) +END AS Result +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('12:34:56' AS TIME) +END AS Result +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) +END AS Result +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) +END AS Result +GO + +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST('1900-01-01' AS DATE) + WHEN 3 THEN CAST('12:34:56' AS TIME) + WHEN 4 THEN CAST('1900-01-01 12:34:56.1234567' AS DATETIME2(7)) + WHEN 5 THEN CAST('1900-01-01 12:34:56 +01:00' AS DATETIMEOFFSET) + WHEN 6 THEN CAST('1900-01-01 12:34:00' AS SMALLDATETIME) +END AS Result +GO + +-- Test Case 42: NUMERIC and TINYINT +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(255 AS TINYINT) +END AS Result +GO + +-- Test Case 43: NUMERIC and REAL +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(3.14 AS REAL) +END AS Result +GO + +-- Test Case 44: NUMERIC and NCHAR +SELECT CASE 1 + WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) + WHEN 2 THEN CAST(N'A' AS NCHAR(1)) +END AS Result +GO + +-- Create UDTs +CREATE TYPE NumericType_BABEL_5341 FROM NUMERIC(20,2); +GO + +CREATE TYPE DecimalType_BABEL_5341 FROM DECIMAL(18,4); +GO + +CREATE TYPE BigNumericType_BABEL_5341 FROM NUMERIC(38,10); +GO + +CREATE TYPE SmallDecimalType_BABEL_5341 FROM DECIMAL(5,2); +GO + +-- Test Case 45: Basic CASE with all UDTs +SELECT CASE 4 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 46: CASE with UDTs and different precisions +SELECT CASE 3 + WHEN 1 THEN CAST(12345.6789 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567890123456.7890123456 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS DecimalType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 47: CASE with UDTs and mathematical operations +SELECT CASE 2 + WHEN 1 THEN CAST(12345.6789 * 2 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 / 2 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1234567.8901234567890 + 1000 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(99.99 - 50 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 48: CASE with UDTs and rounding +SELECT CASE 1 + WHEN 1 THEN CAST(ROUND(12345.6789, 2) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(ROUND(98765.4321, 4) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(ROUND(1234567.8901234567890, 10) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(ROUND(99.99, 1) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 49: CASE with UDTs and type conversion +SELECT CASE 4 + WHEN 1 THEN CAST(CAST(12345.6789 AS NumericType_BABEL_5341) AS BigNumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(98765.4321 AS DecimalType_BABEL_5341) AS SmallDecimalType_BABEL_5341) + WHEN 3 THEN CAST(CAST(1234567.8901234567890 AS BigNumericType_BABEL_5341) AS NumericType_BABEL_5341) + WHEN 4 THEN CAST(CAST(99.99 AS SmallDecimalType_BABEL_5341) AS DecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 50: CASE with UDTs and potential overflow +SELECT CASE 3 + WHEN 1 THEN CAST(9999999999999999.99 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(99999999999999.9999 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(12345678901234567890.1234567890 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(999.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 51: CASE with UDTs and aggregate functions +SELECT CASE 2 + WHEN 1 THEN CAST(AVG(CAST(COLUMN_VALUE AS NumericType_BABEL_5341)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(SUM(CAST(COLUMN_VALUE AS DecimalType_BABEL_5341)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(MAX(CAST(COLUMN_VALUE AS BigNumericType_BABEL_5341)) AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(MIN(CAST(COLUMN_VALUE AS SmallDecimalType_BABEL_5341)) AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +FROM (VALUES (100), (200), (300)) AS T(COLUMN_VALUE) +GO + +-- Test Case 52: UDTs with INT and BIGINT +SELECT CASE 3 + WHEN 1 THEN CAST(12345 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(9876543210 AS BigNumericType_BABEL_5341) + WHEN 3 THEN CAST(1000 AS INT) + WHEN 4 THEN CAST(9223372036854775807 AS BIGINT) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 53: UDTs with FLOAT and REAL +SELECT CASE 2 + WHEN 1 THEN CAST(123.45 AS DecimalType_BABEL_5341) + WHEN 2 THEN CAST(98765.4321 AS FLOAT) + WHEN 3 THEN CAST(1234.56 AS REAL) + WHEN 4 THEN CAST(9.87654321 AS NumericType_BABEL_5341) + ELSE CAST(0 AS BigNumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 54: UDTs with MONEY and SMALLMONEY +SELECT CASE 4 + WHEN 1 THEN CAST(12345.67 AS MONEY) + WHEN 2 THEN CAST(98.76 AS SMALLMONEY) + WHEN 3 THEN CAST(1234.5678 AS DecimalType_BABEL_5341) + WHEN 4 THEN CAST(9876.54 AS NumericType_BABEL_5341) + ELSE CAST(0 AS SmallDecimalType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 55: UDTs with VARCHAR and NVARCHAR +SELECT CASE 3 + WHEN 1 THEN CAST(CAST('12345.67' AS VARCHAR(20)) AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(CAST(N'98765.4321' AS NVARCHAR(20)) AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST('1234567.8901' AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(N'99.99' AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO + +-- Test Case 56: UDTs with BIT and mathematical operations +SELECT CASE 3 + WHEN 1 THEN CAST(1 AS BIT) * CAST(12345.67 AS NumericType_BABEL_5341) + WHEN 2 THEN CAST(0 AS BIT) * CAST(98765.4321 AS DecimalType_BABEL_5341) + WHEN 3 THEN CAST(1 AS BIT) + CAST(1234567.8901 AS BigNumericType_BABEL_5341) + WHEN 4 THEN CAST(1 AS BIT) - CAST(99.99 AS SmallDecimalType_BABEL_5341) + ELSE CAST(0 AS NumericType_BABEL_5341) +END AS RESULT +GO + +DROP TYPE NumericType_BABEL_5341; +GO + +DROP TYPE DecimalType_BABEL_5341; +GO + +DROP TYPE BigNumericType_BABEL_5341; +GO + +DROP TYPE SmallDecimalType_BABEL_5341; +GO + +-- test cases +-- Test Case 57: Basic DECIMAL and NUMERIC mix +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1))), + (CAST(2.2 AS NUMERIC(3,1))), + (CAST(3.3 AS DECIMAL(3,1))) +) AS "VALUES"; +GO + +-- Test Case 58: Different precisions and scales +SELECT * FROM (VALUES + (CAST(1.23456 AS DECIMAL(6,5))), + (CAST(23.4567 AS NUMERIC(6,4))), + (CAST(345.678 AS DECIMAL(6,3))), + (CAST(4567.89 AS NUMERIC(6,2))) +) AS "VALUES"; +GO + +-- Test Case 59: Large precisions +SELECT * FROM (VALUES + (CAST(1234567890123456789.1234567890 AS DECIMAL(38,10))), + (CAST(9876543210987654321.0987654321 AS NUMERIC(38,10))), + (CAST(1111111111111111111.1111111111 AS DECIMAL(38,10))) +) AS "VALUES"; +GO + +-- Test Case 60: Small scales +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(38,1))), + (CAST(22.22 AS NUMERIC(38,2))), + (CAST(333.333 AS DECIMAL(38,3))), + (CAST(4444.4444 AS NUMERIC(38,4))) +) AS "VALUES"; +GO + +-- Test Case 61: Mix of positive and negative numbers +SELECT * FROM (VALUES + (CAST(-1.23 AS DECIMAL(5,2))), + (CAST(4.56 AS NUMERIC(5,2))), + (CAST(-7.89 AS DECIMAL(5,2))), + (CAST(0.12 AS NUMERIC(5,2))) +) AS "VALUES"; +GO + +-- Test Case 62: Very small numbers +SELECT * FROM (VALUES + (CAST(0.000000000123 AS DECIMAL(15,12))), + (CAST(0.000000000456 AS NUMERIC(15,12))), + (CAST(0.000000000789 AS DECIMAL(15,12))) +) AS "VALUES"; +GO + +-- Test Case 63: Very large numbers +SELECT * FROM (VALUES + (CAST(123456789012345678901234567890.12 AS DECIMAL(38,2))), + (CAST(987654321098765432109876543210.98 AS NUMERIC(38,2))), + (CAST(111111111111111111111111111111.11 AS DECIMAL(38,2))) +) AS "VALUES"; +GO + +-- Test Case 64: Mix of integer and fractional parts +SELECT * FROM (VALUES + (CAST(1 AS DECIMAL(38,0))), + (CAST(2.2 AS NUMERIC(38,1))), + (CAST(3.33 AS DECIMAL(38,2))), + (CAST(4.444 AS NUMERIC(38,3))) +) AS "VALUES"; +GO + +-- Test Case 65: Edge cases +SELECT * FROM (VALUES + (CAST(0.9999999999999999999999999999999999999 AS DECIMAL(38,37))), + (CAST(9.999999999999999999999999999999999999 AS NUMERIC(38,36))), + (CAST(0.0000000000000000000000000000000000001 AS DECIMAL(38,37))) +) AS "VALUES"; +GO + +-- Test Case 66: Mix of DECIMAL and NUMERIC with different precisions +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(5,1))), + (CAST(2.22 AS NUMERIC(10,2))), + (CAST(3.333 AS DECIMAL(15,3))), + (CAST(4.4444 AS NUMERIC(20,4))) +) AS "VALUES"; +GO + +-- Test Case 67: Mix of numeric, decimal, integer, and varchar +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), 10, 'ABC'), + (CAST(2.2 AS NUMERIC(3,1)), 20, 'DEF'), + (CAST(3.3 AS DECIMAL(3,1)), 30, 'GHI') +) AS "VALUES" (dec_num, int_num, str_val); +GO + +-- Test Case 68: Mix with date, time, and boolean +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(4,2)), CAST('2023-01-01' AS DATE), CAST('10:30:00' AS TIME), TRUE), + (CAST(4.56 AS NUMERIC(4,2)), CAST('2023-02-15' AS DATE), CAST('14:45:00' AS TIME), FALSE), + (CAST(7.89 AS DECIMAL(4,2)), CAST('2023-03-30' AS DATE), CAST('20:15:00' AS TIME), TRUE) +) AS "VALUES" (num_val, date_val, time_val, bool_val); +GO + +-- Test Case 69: Mix with timestamp and interval +SELECT * FROM (VALUES + (CAST(123.45 AS DECIMAL(5,2)), CAST('2023-01-01 12:00:00' AS TIMESTAMP), CAST('1 day' AS INTERVAL)), + (CAST(678.90 AS NUMERIC(5,2)), CAST('2023-06-15 18:30:00' AS TIMESTAMP), CAST('2 hours' AS INTERVAL)), + (CAST(246.80 AS DECIMAL(5,2)), CAST('2023-12-31 23:59:59' AS TIMESTAMP), CAST('30 minutes' AS INTERVAL)) +) AS "VALUES" (num_val, ts_val, interval_val); +GO + +-- Test Case 70: Mix with char, varchar, and text +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), CAST('A' AS CHAR(1)), CAST('ABC' AS VARCHAR(10)), 'This is a text'), + (CAST(2.2 AS NUMERIC(3,1)), CAST('B' AS CHAR(1)), CAST('DEF' AS VARCHAR(10)), 'Another text'), + (CAST(3.3 AS DECIMAL(3,1)), CAST('C' AS CHAR(1)), CAST('GHI' AS VARCHAR(10)), 'Yet another text') +) AS "VALUES" (num_val, char_val, varchar_val, text_val); +GO + +-- Test Case 71: Mix with money and bit +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(3,2)), CAST(100.00 AS MONEY), CAST('1' AS BIT)), + (CAST(4.56 AS NUMERIC(3,2)), CAST(200.50 AS MONEY), CAST('0' AS BIT)), + (CAST(7.89 AS DECIMAL(3,2)), CAST(350.75 AS MONEY), CAST('1' AS BIT)) +) AS "VALUES" (num_val, money_val, bit_val); +GO + +-- Test Case 72: UNION with DECIMAL and INTEGER +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT 456 +ORDER BY value; +GO + +-- Test Case 73: UNION with NUMERIC, DECIMAL, and FLOAT +SELECT CAST(1.23456 AS NUMERIC(10,5)) AS value +UNION ALL +SELECT CAST(2.34567 AS DECIMAL(10,5)) +UNION ALL +SELECT CAST(3.45678 AS FLOAT) +ORDER BY value; +GO + +-- Test Case 74: UNION with different precisions and scales +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(2.3456 AS NUMERIC(10,4)) +UNION ALL +SELECT CAST(3.456789 AS DECIMAL(15,6)) +ORDER BY value; +GO + +-- Test Case 75: UNION with negative numbers and zero +SELECT CAST(-1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(0 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(1.23 AS DECIMAL(5,2)) +ORDER BY value; +GO + +-- Test Case 75: UNION with large numbers +SELECT CAST(1234567890.12345 AS DECIMAL(20,5)) AS value +UNION ALL +SELECT CAST(9876543210.98765 AS NUMERIC(20,5)) +UNION ALL +SELECT CAST(1111111111.11111 AS DECIMAL(20,5)) +ORDER BY value; +GO + +-- Test Case 76: UNION with small numbers +SELECT CAST(0.00000123 AS DECIMAL(10,8)) AS value +UNION ALL +SELECT CAST(0.00000456 AS NUMERIC(10,8)) +UNION ALL +SELECT CAST(0.00000789 AS DECIMAL(10,8)) +ORDER BY value; +GO + +-- Test Case 77: UNION with DECIMAL, NUMERIC, and VARCHAR +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST('7.89' AS VARCHAR(10)) +ORDER BY value; +GO + +-- Test Case 78: UNION with different integer parts +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(123.45 AS NUMERIC(10,2)) +UNION ALL +SELECT CAST(12345.67 AS DECIMAL(10,2)) +ORDER BY value; +GO + +-- Test Case 79: UNION with extreme values +SELECT CAST(9999999999.99999999 AS DECIMAL(18,8)) AS value +UNION ALL +SELECT CAST(0.00000001 AS NUMERIC(18,8)) +UNION ALL +SELECT CAST(5555555555.55555555 AS DECIMAL(18,8)) +ORDER BY value; +GO + +-- Test Case 80: UNION with NULL values +SELECT CAST(NULL AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(1.23 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(NULL AS DECIMAL(5,2)) +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +ORDER BY value; +GO + +-- Test Case 81: UNION with MONEY type +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(4.56 AS MONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(10,2)) +ORDER BY value; +GO + +-- Test Case 82: UNION with SMALLMONEY type +SELECT CAST(1.23 AS DECIMAL(6,2)) AS value +UNION ALL +SELECT CAST(4.56 AS SMALLMONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(6,2)) +ORDER BY value; +GO + +-- Test Case 83: DECIMAL(38,1) - 37 digits before decimal, 1 after +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(1000000000000000000000000000000000000.0 AS DECIMAL(38,1)) +ORDER BY value; +GO + +-- Test Case 84: DECIMAL(38,2) - 36 digits before decimal, 2 after +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) AS value +UNION ALL +SELECT CAST(999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(100000000000000000000000000000000000.00 AS DECIMAL(38,2)) +ORDER BY value; +GO + +-- Test Case 85: DECIMAL(38,5) - 33 digits before decimal, 5 after +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) AS value +UNION ALL +SELECT CAST(99999999999999999999999999999999.99999 AS DECIMAL(38,5)) +UNION ALL +SELECT CAST(10000000000000000000000000000000.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO + +-- Test Case 86: Mixing different scales with precision 38 +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO + +-- Test Case 88: Very small fractional part with precision 38 +SELECT CAST(9999999999999999999999999999999999999.1 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.01 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO + +-- Test Case 89: Overflow scenarios with precision 38 +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(10000000000000000000000000000000000000.0 AS DECIMAL(38,1)) -- This will cause an overflow +ORDER BY value; +GO + +-- Test Case 90: Mixing DECIMAL and NUMERIC with precision 38 and small scales +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS NUMERIC(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO + +-- Test Case 91: NULL values with precision 38 and small scales +SELECT CAST(NULL AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(NULL AS NUMERIC(38,2)) +ORDER BY value; +GO + +-- Test Case 92: customer query +DECLARE @test_int int = 1; +SELECT a.integer_one, a.integer_two, +ratio = a.integer_one / CONVERT(DECIMAL, a.integer_two), +ratio_case_one = CASE WHEN a.integer_two = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_two = CASE WHEN 1 = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_three = CASE WHEN @test_int = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END +FROM BABEL_5341_T2 a; +GO \ No newline at end of file diff --git a/test/JDBC/input/BABEL-CASE_EXPR-vu-cleanup.sql b/test/JDBC/input/BABEL-CASE_EXPR-vu-cleanup.sql index 1765f5a25e..debf59e513 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-vu-cleanup.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-vu-cleanup.sql @@ -34,3 +34,6 @@ GO DROP FUNCTION BABEL_5341_F1; GO + +DROP TABLE BABEL_5341_T2; +GO \ No newline at end of file diff --git a/test/JDBC/input/BABEL-CASE_EXPR-vu-prepare.sql b/test/JDBC/input/BABEL-CASE_EXPR-vu-prepare.sql index 9a14e11351..8e78716383 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-vu-prepare.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-vu-prepare.sql @@ -139,3 +139,18 @@ BEGIN ); END; GO + +CREATE TABLE BABEL_5341_T2 +( + [integer_one] INT, + [integer_two] INT +); +GO +INSERT INTO BABEL_5341_T2 +( + [integer_one], + [integer_two] +) +VALUES +(1, 3); +GO \ No newline at end of file diff --git a/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql b/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql index 775302fc0c..76b90ffce2 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql @@ -7817,16 +7817,6 @@ SELECT CASE 2 END AS Result GO -SELECT CASE 2 - WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) - WHEN 2 THEN CAST(GETDATE() AS DATE) - WHEN 3 THEN CAST(GETDATE() AS TIME) - WHEN 4 THEN CAST(SYSDATETIME() AS DATETIME2(7)) - WHEN 5 THEN CAST(SYSDATETIMEOFFSET() AS DATETIMEOFFSET) - WHEN 6 THEN CAST(GETDATE() AS SMALLDATETIME) -END AS Result -GO - -- Test Case 42: NUMERIC and TINYINT SELECT CASE 1 WHEN 1 THEN CAST(1.23 AS NUMERIC(20,2)) @@ -7993,3 +7983,319 @@ GO DROP TYPE SmallDecimalType_BABEL_5341; GO + +-- test cases +-- Test Case 57: Basic DECIMAL and NUMERIC mix +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1))), + (CAST(2.2 AS NUMERIC(3,1))), + (CAST(3.3 AS DECIMAL(3,1))) +) AS "VALUES"; +GO + +-- Test Case 58: Different precisions and scales +SELECT * FROM (VALUES + (CAST(1.23456 AS DECIMAL(6,5))), + (CAST(23.4567 AS NUMERIC(6,4))), + (CAST(345.678 AS DECIMAL(6,3))), + (CAST(4567.89 AS NUMERIC(6,2))) +) AS "VALUES"; +GO + +-- Test Case 59: Large precisions +SELECT * FROM (VALUES + (CAST(1234567890123456789.1234567890 AS DECIMAL(38,10))), + (CAST(9876543210987654321.0987654321 AS NUMERIC(38,10))), + (CAST(1111111111111111111.1111111111 AS DECIMAL(38,10))) +) AS "VALUES"; +GO + +-- Test Case 60: Small scales +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(38,1))), + (CAST(22.22 AS NUMERIC(38,2))), + (CAST(333.333 AS DECIMAL(38,3))), + (CAST(4444.4444 AS NUMERIC(38,4))) +) AS "VALUES"; +GO + +-- Test Case 61: Mix of positive and negative numbers +SELECT * FROM (VALUES + (CAST(-1.23 AS DECIMAL(5,2))), + (CAST(4.56 AS NUMERIC(5,2))), + (CAST(-7.89 AS DECIMAL(5,2))), + (CAST(0.12 AS NUMERIC(5,2))) +) AS "VALUES"; +GO + +-- Test Case 62: Very small numbers +SELECT * FROM (VALUES + (CAST(0.000000000123 AS DECIMAL(15,12))), + (CAST(0.000000000456 AS NUMERIC(15,12))), + (CAST(0.000000000789 AS DECIMAL(15,12))) +) AS "VALUES"; +GO + +-- Test Case 63: Very large numbers +SELECT * FROM (VALUES + (CAST(123456789012345678901234567890.12 AS DECIMAL(38,2))), + (CAST(987654321098765432109876543210.98 AS NUMERIC(38,2))), + (CAST(111111111111111111111111111111.11 AS DECIMAL(38,2))) +) AS "VALUES"; +GO + +-- Test Case 64: Mix of integer and fractional parts +SELECT * FROM (VALUES + (CAST(1 AS DECIMAL(38,0))), + (CAST(2.2 AS NUMERIC(38,1))), + (CAST(3.33 AS DECIMAL(38,2))), + (CAST(4.444 AS NUMERIC(38,3))) +) AS "VALUES"; +GO + +-- Test Case 65: Edge cases +SELECT * FROM (VALUES + (CAST(0.9999999999999999999999999999999999999 AS DECIMAL(38,37))), + (CAST(9.999999999999999999999999999999999999 AS NUMERIC(38,36))), + (CAST(0.0000000000000000000000000000000000001 AS DECIMAL(38,37))) +) AS "VALUES"; +GO + +-- Test Case 66: Mix of DECIMAL and NUMERIC with different precisions +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(5,1))), + (CAST(2.22 AS NUMERIC(10,2))), + (CAST(3.333 AS DECIMAL(15,3))), + (CAST(4.4444 AS NUMERIC(20,4))) +) AS "VALUES"; +GO + +-- Test Case 67: Mix of numeric, decimal, integer, and varchar +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), 10, 'ABC'), + (CAST(2.2 AS NUMERIC(3,1)), 20, 'DEF'), + (CAST(3.3 AS DECIMAL(3,1)), 30, 'GHI') +) AS "VALUES" (dec_num, int_num, str_val); +GO + +-- Test Case 68: Mix with date, time, and boolean +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(4,2)), CAST('2023-01-01' AS DATE), CAST('10:30:00' AS TIME), TRUE), + (CAST(4.56 AS NUMERIC(4,2)), CAST('2023-02-15' AS DATE), CAST('14:45:00' AS TIME), FALSE), + (CAST(7.89 AS DECIMAL(4,2)), CAST('2023-03-30' AS DATE), CAST('20:15:00' AS TIME), TRUE) +) AS "VALUES" (num_val, date_val, time_val, bool_val); +GO + +-- Test Case 69: Mix with timestamp and interval +SELECT * FROM (VALUES + (CAST(123.45 AS DECIMAL(5,2)), CAST('2023-01-01 12:00:00' AS TIMESTAMP), CAST('1 day' AS INTERVAL)), + (CAST(678.90 AS NUMERIC(5,2)), CAST('2023-06-15 18:30:00' AS TIMESTAMP), CAST('2 hours' AS INTERVAL)), + (CAST(246.80 AS DECIMAL(5,2)), CAST('2023-12-31 23:59:59' AS TIMESTAMP), CAST('30 minutes' AS INTERVAL)) +) AS "VALUES" (num_val, ts_val, interval_val); +GO + +-- Test Case 70: Mix with char, varchar, and text +SELECT * FROM (VALUES + (CAST(1.1 AS DECIMAL(3,1)), CAST('A' AS CHAR(1)), CAST('ABC' AS VARCHAR(10)), 'This is a text'), + (CAST(2.2 AS NUMERIC(3,1)), CAST('B' AS CHAR(1)), CAST('DEF' AS VARCHAR(10)), 'Another text'), + (CAST(3.3 AS DECIMAL(3,1)), CAST('C' AS CHAR(1)), CAST('GHI' AS VARCHAR(10)), 'Yet another text') +) AS "VALUES" (num_val, char_val, varchar_val, text_val); +GO + +-- Test Case 71: Mix with money and bit +SELECT * FROM (VALUES + (CAST(1.23 AS DECIMAL(3,2)), CAST(100.00 AS MONEY), CAST('1' AS BIT)), + (CAST(4.56 AS NUMERIC(3,2)), CAST(200.50 AS MONEY), CAST('0' AS BIT)), + (CAST(7.89 AS DECIMAL(3,2)), CAST(350.75 AS MONEY), CAST('1' AS BIT)) +) AS "VALUES" (num_val, money_val, bit_val); +GO + +-- Test Case 72: UNION with DECIMAL and INTEGER +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT 456 +ORDER BY value; +GO + +-- Test Case 73: UNION with NUMERIC, DECIMAL, and FLOAT +SELECT CAST(1.23456 AS NUMERIC(10,5)) AS value +UNION ALL +SELECT CAST(2.34567 AS DECIMAL(10,5)) +UNION ALL +SELECT CAST(3.45678 AS FLOAT) +ORDER BY value; +GO + +-- Test Case 74: UNION with different precisions and scales +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(2.3456 AS NUMERIC(10,4)) +UNION ALL +SELECT CAST(3.456789 AS DECIMAL(15,6)) +ORDER BY value; +GO + +-- Test Case 75: UNION with negative numbers and zero +SELECT CAST(-1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(0 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(1.23 AS DECIMAL(5,2)) +ORDER BY value; +GO + +-- Test Case 75: UNION with large numbers +SELECT CAST(1234567890.12345 AS DECIMAL(20,5)) AS value +UNION ALL +SELECT CAST(9876543210.98765 AS NUMERIC(20,5)) +UNION ALL +SELECT CAST(1111111111.11111 AS DECIMAL(20,5)) +ORDER BY value; +GO + +-- Test Case 76: UNION with small numbers +SELECT CAST(0.00000123 AS DECIMAL(10,8)) AS value +UNION ALL +SELECT CAST(0.00000456 AS NUMERIC(10,8)) +UNION ALL +SELECT CAST(0.00000789 AS DECIMAL(10,8)) +ORDER BY value; +GO + +-- Test Case 77: UNION with DECIMAL, NUMERIC, and VARCHAR +SELECT CAST(1.23 AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST('7.89' AS VARCHAR(10)) +ORDER BY value; +GO + +-- Test Case 78: UNION with different integer parts +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(123.45 AS NUMERIC(10,2)) +UNION ALL +SELECT CAST(12345.67 AS DECIMAL(10,2)) +ORDER BY value; +GO + +-- Test Case 79: UNION with extreme values +SELECT CAST(9999999999.99999999 AS DECIMAL(18,8)) AS value +UNION ALL +SELECT CAST(0.00000001 AS NUMERIC(18,8)) +UNION ALL +SELECT CAST(5555555555.55555555 AS DECIMAL(18,8)) +ORDER BY value; +GO + +-- Test Case 80: UNION with NULL values +SELECT CAST(NULL AS DECIMAL(5,2)) AS value +UNION ALL +SELECT CAST(1.23 AS NUMERIC(5,2)) +UNION ALL +SELECT CAST(NULL AS DECIMAL(5,2)) +UNION ALL +SELECT CAST(4.56 AS NUMERIC(5,2)) +ORDER BY value; +GO + +-- Test Case 81: UNION with MONEY type +SELECT CAST(1.23 AS DECIMAL(10,2)) AS value +UNION ALL +SELECT CAST(4.56 AS MONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(10,2)) +ORDER BY value; +GO + +-- Test Case 82: UNION with SMALLMONEY type +SELECT CAST(1.23 AS DECIMAL(6,2)) AS value +UNION ALL +SELECT CAST(4.56 AS SMALLMONEY) +UNION ALL +SELECT CAST(7.89 AS NUMERIC(6,2)) +ORDER BY value; +GO + +-- Test Case 83: DECIMAL(38,1) - 37 digits before decimal, 1 after +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(1000000000000000000000000000000000000.0 AS DECIMAL(38,1)) +ORDER BY value; +GO + +-- Test Case 84: DECIMAL(38,2) - 36 digits before decimal, 2 after +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) AS value +UNION ALL +SELECT CAST(999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(100000000000000000000000000000000000.00 AS DECIMAL(38,2)) +ORDER BY value; +GO + +-- Test Case 85: DECIMAL(38,5) - 33 digits before decimal, 5 after +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) AS value +UNION ALL +SELECT CAST(99999999999999999999999999999999.99999 AS DECIMAL(38,5)) +UNION ALL +SELECT CAST(10000000000000000000000000000000.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO + +-- Test Case 86: Mixing different scales with precision 38 +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO + +-- Test Case 88: Very small fractional part with precision 38 +SELECT CAST(9999999999999999999999999999999999999.1 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.01 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.00001 AS DECIMAL(38,5)) +ORDER BY value; +GO + +-- Test Case 89: Overflow scenarios with precision 38 +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.99 AS DECIMAL(38,2)) +UNION ALL +SELECT CAST(10000000000000000000000000000000000000.0 AS DECIMAL(38,1)) -- This will cause an overflow +ORDER BY value; +GO + +-- Test Case 90: Mixing DECIMAL and NUMERIC with precision 38 and small scales +SELECT CAST(1234567890123456789012345678901234567.8 AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(123456789012345678901234567890123456.78 AS NUMERIC(38,2)) +UNION ALL +SELECT CAST(12345678901234567890123456789012.34567 AS DECIMAL(38,5)) +ORDER BY value; +GO + +-- Test Case 91: NULL values with precision 38 and small scales +SELECT CAST(NULL AS DECIMAL(38,1)) AS value +UNION ALL +SELECT CAST(9999999999999999999999999999999999999.9 AS DECIMAL(38,1)) +UNION ALL +SELECT CAST(NULL AS NUMERIC(38,2)) +ORDER BY value; +GO + +-- Test Case 92: customer query +DECLARE @test_int int = 1; +SELECT a.integer_one, a.integer_two, +ratio = a.integer_one / CONVERT(DECIMAL, a.integer_two), +ratio_case_one = CASE WHEN a.integer_two = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_two = CASE WHEN 1 = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END, +ratio_case_three = CASE WHEN @test_int = 0 THEN NULL ELSE a.integer_one / CONVERT(DECIMAL, a.integer_two) END +FROM BABEL_5341_T2 a; +GO \ No newline at end of file diff --git a/test/JDBC/jdbc_schedule b/test/JDBC/jdbc_schedule index dad474ff8e..385c704524 100644 --- a/test/JDBC/jdbc_schedule +++ b/test/JDBC/jdbc_schedule @@ -79,6 +79,9 @@ ignore#!#test_like_for_AI-before-16_5-or-15_9-vu-cleanup ignore#!#BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare ignore#!#BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify ignore#!#BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup +ignore#!#BABEL-CASE_EXPR-before-16_6-vu-prepare +ignore#!#BABEL-CASE_EXPR-before-16_6-vu-verify +ignore#!#BABEL-CASE_EXPR-before-16_6-vu-cleanup ignore#!#BABEL-2736-before-16_5-vu-prepare ignore#!#BABEL-2736-before-16_5-vu-verify ignore#!#BABEL-2736-before-16_5-vu-cleanup diff --git a/test/JDBC/upgrade/15_10/schedule b/test/JDBC/upgrade/15_10/schedule index b62187055c..0e643417e6 100644 --- a/test/JDBC/upgrade/15_10/schedule +++ b/test/JDBC/upgrade/15_10/schedule @@ -549,7 +549,7 @@ BABEL-5119_before_16_5 dbcreator_role db_accessadmin db_securityadmin -BABEL-CASE_EXPR +BABEL-CASE_EXPR-before-16_6 datareader_datawriter db_ddladmin BABEL-5186 diff --git a/test/JDBC/upgrade/15_11/schedule b/test/JDBC/upgrade/15_11/schedule index 8b7c71d746..c9015fb3bb 100644 --- a/test/JDBC/upgrade/15_11/schedule +++ b/test/JDBC/upgrade/15_11/schedule @@ -549,7 +549,7 @@ dbcreator_role db_accessadmin db_ddladmin db_securityadmin -BABEL-CASE_EXPR +BABEL-CASE_EXPR-before-16_6 datareader_datawriter BABEL-5186 BABEL-2736 diff --git a/test/JDBC/upgrade/16_6/schedule b/test/JDBC/upgrade/16_6/schedule index f5cc36dbe8..5891a071a3 100644 --- a/test/JDBC/upgrade/16_6/schedule +++ b/test/JDBC/upgrade/16_6/schedule @@ -575,7 +575,7 @@ xml_exist test_db_collation BABEL-5119 BABEL-5129 -BABEL-CASE_EXPR +BABEL-CASE_EXPR-before-16_6 charindex_replace_patindex BABEL-5186 BABEL-2736 From 9c29cc53dbbff07f69479103741d7cc106284660 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 18 Dec 2024 13:06:40 +0000 Subject: [PATCH 13/21] minor change --- .../babelfishpg_tds/src/backend/tds/tdsresponse.c | 12 +++++++----- ...ABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out | 2 +- .../BABEL-CASE_EXPR-before-16_6-vu-cleanup.out | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index ea16b7bbf2..096ec38410 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -576,11 +576,11 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) Var *var = (Var *) expr; /* If this var referes to tuple returned by its outer plan then find the original tle from it */ - if (plan && var->varno == OUTER_VAR) - { - Assert(plan); - return (resolve_numeric_typmod_outer_var(plan, var->varattno)); - } + // if (plan && var->varno == OUTER_VAR) + // { + // Assert(plan); + // return (resolve_numeric_typmod_outer_var(plan, var->varattno)); + // } return var->vartypmod; } case T_OpExpr: @@ -1797,6 +1797,8 @@ PrepareRowDescription(TupleDesc typeinfo, PlannedStmt *plannedstmt, List *target /* * Get the IO function info from our type cache */ + if (atttypmod == TSQLMaxTypmod) + atttypmod = -1; finfo = TdsLookupTypeFunctionsByOid(atttypid, &atttypmod); /* atttypid = getBaseTypeAndTypmod(atttypid, &atttypmod); */ #if 0 diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out index a45aea03c9..5c7578a055 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out @@ -34,4 +34,4 @@ DROP FUNCTION BABEL_5341_F1; GO DROP TABLE BABEL_5341_T2; -GO \ No newline at end of file +GO diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-cleanup.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-cleanup.out index debf59e513..61c1332e78 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-cleanup.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-cleanup.out @@ -36,4 +36,4 @@ DROP FUNCTION BABEL_5341_F1; GO DROP TABLE BABEL_5341_T2; -GO \ No newline at end of file +GO From 533b0ecfcb48b346fce1f13ebc65c5f0e0adb786 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 18 Dec 2024 13:23:28 +0000 Subject: [PATCH 14/21] minor change --- contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c | 10 +++++----- .../BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index 096ec38410..6fda8dd73d 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -576,11 +576,11 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) Var *var = (Var *) expr; /* If this var referes to tuple returned by its outer plan then find the original tle from it */ - // if (plan && var->varno == OUTER_VAR) - // { - // Assert(plan); - // return (resolve_numeric_typmod_outer_var(plan, var->varattno)); - // } + if (plan && var->varno == OUTER_VAR) + { + Assert(plan); + return (resolve_numeric_typmod_outer_var(plan, var->varattno)); + } return var->vartypmod; } case T_OpExpr: diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out index 7e1779c1cf..a32fcf4b93 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-prepare.out @@ -171,3 +171,4 @@ VALUES (1, 3); GO ~~ROW COUNT: 1~~ + From 87ed2639b38182674da7a7f48fca483a10209900 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 18 Dec 2024 13:44:45 +0000 Subject: [PATCH 15/21] extra line --- test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out | 1 + 1 file changed, 1 insertion(+) diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out index 7e1779c1cf..a32fcf4b93 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out @@ -171,3 +171,4 @@ VALUES (1, 3); GO ~~ROW COUNT: 1~~ + From cd55d09e6160ace450effd606cf56b61bdf5c7f0 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Wed, 18 Dec 2024 14:16:19 +0000 Subject: [PATCH 16/21] extra spaces --- .../expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out | 2 ++ .../expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out | 1 + test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-prepare.out | 1 + test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out | 1 + test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out | 1 + .../BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out | 1 + .../chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out | 1 + .../chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out | 1 + .../BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out | 1 + .../japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out | 1 + .../japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out | 1 + 11 files changed, 12 insertions(+) diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out index 5c7578a055..61c1332e78 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-cleanup.out @@ -1,8 +1,10 @@ DROP VIEW BABEL_5103_V1; GO + DROP TABLE BABEL_5103_T1; GO + DROP VIEW BABEL_5103_V2; GO diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index 2330fe2193..3c961a8d1d 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -14532,3 +14532,4 @@ GO int#!#int#!#numeric#!#numeric#!#numeric#!#numeric 1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 ~~END~~ + diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-prepare.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-prepare.out index 7e1779c1cf..a32fcf4b93 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-prepare.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-prepare.out @@ -171,3 +171,4 @@ VALUES (1, 3); GO ~~ROW COUNT: 1~~ + diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out index 72a1a40f32..acab3a9a25 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out @@ -14532,3 +14532,4 @@ GO int#!#int#!#numeric#!#numeric#!#numeric#!#numeric 1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 ~~END~~ + diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out index e058c032a6..43fceb206d 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out @@ -14532,3 +14532,4 @@ GO int#!#int#!#numeric#!#numeric#!#numeric#!#numeric 1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 ~~END~~ + diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index 130dcee418..c6e42e637d 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -14532,3 +14532,4 @@ GO int#!#int#!#numeric#!#numeric#!#numeric#!#numeric 1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 ~~END~~ + diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out index 758f59983b..c7e4d5d57f 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out @@ -14532,3 +14532,4 @@ GO int#!#int#!#numeric#!#numeric#!#numeric#!#numeric 1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 ~~END~~ + diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out index ce384f1886..28f720a39c 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out @@ -14532,3 +14532,4 @@ GO int#!#int#!#numeric#!#numeric#!#numeric#!#numeric 1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 ~~END~~ + diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index 1bd8b428fa..639e506e38 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -14532,3 +14532,4 @@ GO int#!#int#!#numeric#!#numeric#!#numeric#!#numeric 1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 ~~END~~ + diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out index 96db09670e..e539428afc 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out @@ -14532,3 +14532,4 @@ GO int#!#int#!#numeric#!#numeric#!#numeric#!#numeric 1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 ~~END~~ + diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out index 6a911aa930..b44afe0b6e 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out @@ -14532,3 +14532,4 @@ GO int#!#int#!#numeric#!#numeric#!#numeric#!#numeric 1#!#3#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333#!#0.3333333333333333333 ~~END~~ + From 377744c46beb6a0e59c72a2733c098fd94a5a1b1 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Fri, 20 Dec 2024 10:26:59 +0000 Subject: [PATCH 17/21] handling parallel query and removing redundant function calls Signed-off-by: Tanya Gupta --- .../src/backend/tds/tdsresponse.c | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index 6fda8dd73d..2a7915a525 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -574,13 +574,26 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) case T_Var: { Var *var = (Var *) expr; - - /* If this var referes to tuple returned by its outer plan then find the original tle from it */ - if (plan && var->varno == OUTER_VAR) + Plan *outerplan = NULL; + TargetEntry *tle; + if (plan && IsA(plan, Gather)) { Assert(plan); - return (resolve_numeric_typmod_outer_var(plan, var->varattno)); + outerplan = outerPlan(plan); + tle = get_tle_by_resno(outerplan->targetlist, var->varattno); + resolve_numeric_typmod_from_exp(outerplan, (Node *)tle->expr); } + + /* If this var referes to tuple returned by its outer plan then find the original tle from it */ + // if (plan && var->varno == OUTER_VAR) + // { + // Assert(plan); + // return (resolve_numeric_typmod_outer_var(plan, var->varattno)); + // } // if gather node then + // outerplan = outerPlan(plan); + // Assert(outerplan); + // tle = get_tle_by_resno(outerplan->targetlist, var->varattno); + // return resolve_numeric_typmod_from_exp(outerplan, (Node *)tle->expr); return var->vartypmod; } case T_OpExpr: @@ -1782,9 +1795,9 @@ PrepareRowDescription(TupleDesc typeinfo, PlannedStmt *plannedstmt, List *target { Oid serverCollationOid; TdsIoFunctionInfo finfo; - Form_pg_attribute att = TupleDescAttr(typeinfo, attno); + Form_pg_attribute att = TupleDescAttr(typeinfo, attno); // able to extract from var Oid atttypid = att->atttypid; - int32 atttypmod = att->atttypmod; + int32 atttypmod = att->atttypmod; // -1 TdsColumnMetaData *col = &colMetaData[attno]; uint32_t tdsVersion = GetClientTDSVersion(); TargetEntry *tle = NULL; From 643bddb4c8b2b1930747d8d9d498cf13fa12b5ad Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Fri, 20 Dec 2024 11:47:55 +0000 Subject: [PATCH 18/21] minor change Signed-off-by: Tanya Gupta --- contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index 2a7915a525..9c099ba988 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -581,7 +581,7 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) Assert(plan); outerplan = outerPlan(plan); tle = get_tle_by_resno(outerplan->targetlist, var->varattno); - resolve_numeric_typmod_from_exp(outerplan, (Node *)tle->expr); + return resolve_numeric_typmod_from_exp(outerplan, (Node *)tle->expr); } /* If this var referes to tuple returned by its outer plan then find the original tle from it */ From 727ddffd5e8b601cc214807c262bed3e9ce33425 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Fri, 20 Dec 2024 14:23:12 +0000 Subject: [PATCH 19/21] handling agg nodes in parallel query Signed-off-by: Tanya Gupta --- .../src/backend/tds/tdsresponse.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index 9c099ba988..5a383b946c 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -497,6 +497,9 @@ resolve_numeric_typmod_outer_var(Plan *plan, AttrNumber attno) return resolve_numeric_typmod_from_append_or_mergeappend(plan, attno); else outerplan = outerPlan(plan); + // outerplan = outerPlan(plan); + // tle = get_tle_by_resno(outerplan->targetlist, attno); + // return resolve_numeric_typmod_from_exp(outerplan, (Node *)tle->expr); /* if outerplan is SubqueryScan then use actual subplan */ if (IsA(outerplan, SubqueryScan)) @@ -576,10 +579,13 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) Var *var = (Var *) expr; Plan *outerplan = NULL; TargetEntry *tle; - if (plan && IsA(plan, Gather)) + if (plan) + outerplan = outerPlan(plan); + + if (plan && outerplan && (IsA(outerplan, Gather) || IsA(plan, Gather))) { Assert(plan); - outerplan = outerPlan(plan); + Assert(outerplan); tle = get_tle_by_resno(outerplan->targetlist, var->varattno); return resolve_numeric_typmod_from_exp(outerplan, (Node *)tle->expr); } @@ -907,6 +913,12 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) int32 typmod; uint8_t precision, scale; + // Plan *outerplan = NULL; + // TargetEntry *tle; + // if (plan && IsA(plan, Gather)) + // { + // Assert(plan); + // outerplan = outerPlan(plan); Assert(aggref->args != NIL); From ead2002a134bb4e1f1aca19d77d47af70e64ac15 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Fri, 27 Dec 2024 05:31:13 +0000 Subject: [PATCH 20/21] adding test cases Signed-off-by: Tanya Gupta --- .../src/backend/tds/tdsresponse.c | 4 +- test/JDBC/input/babel-5454.sql | 110 +++++++++++++++++- 2 files changed, 109 insertions(+), 5 deletions(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index 5a383b946c..a36f37f00f 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -441,8 +441,8 @@ resolve_numeric_typmod_from_append_or_mergeappend(Plan *plan, AttrNumber attno) Plan *outerplan = (Plan *) lfirst(lc); /* if outerplan is SubqueryScan then use actual subplan */ - // if (IsA(outerplan, SubqueryScan)) - // outerplan = ((SubqueryScan *)outerplan)->subplan; + if (IsA(outerplan, SubqueryScan)) + outerplan = ((SubqueryScan *)outerplan)->subplan; tle = get_tle_by_resno(outerplan->targetlist, attno); if (IsA(tle->expr, Var)) diff --git a/test/JDBC/input/babel-5454.sql b/test/JDBC/input/babel-5454.sql index d61b9ffa83..f71b3f42d1 100644 --- a/test/JDBC/input/babel-5454.sql +++ b/test/JDBC/input/babel-5454.sql @@ -34,9 +34,35 @@ GO INSERT INTO ExchangeRate2 (ToCurrencyCode, ExchangeRate, Hello) VALUES ('EUR', 0.12, 1.12345678), ('GBP', 23.87, 2.12345678), ('JPY', 110.50, 3.12345678), ('CAD', 1.25, 4.12345678), ('USD', 1.00 , 5.12345678); GO +-- formatted +SELECT + cr1 AS description, + ex + Hello AS sum_num +FROM ( + SELECT + ExchangeRate AS ex, + CurrencyName AS cr1, + CurrencyName, + Hello + FROM currency2 + INNER JOIN ExchangeRate2 + ON ToCurrencyCode = CurrencyCode + + UNION ALL + + SELECT + 1 AS aw, + CurrencyName AS cr, + CurrencyName, + curr_num AS aw1 + FROM currency2 +) a; +GO + -- should notb work withoit my changes --- SELECT cr1 description, ex + Hello sum_num FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a; --- GO +SELECT cr1 description, ex + Hello sum_num FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT 1 AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a; +GO + -- 1.1 THIS QUERY DOES WORK when union with decimal, so not an issue of position? - 5,2 and 9,8 , went to NUMERIC_SUB_OID, final 12,8 SELECT cr1 description, ex + Hello ex1 FROM (SELECT ExchangeRate ex,CurrencyName cr1, CurrencyName ,Hello FROM currency2 INNER JOIN ExchangeRate2 ON ToCurrencyCode = CurrencyCode UNION ALL SELECT curr_num AS aw,CurrencyName as cr, CurrencyName,curr_num as aw1 FROM currency2) a; @@ -223,4 +249,82 @@ GO DROP TABLE Exchange; GO DROP TYPE TestUDT; -GO \ No newline at end of file +GO + + +CREATE TABLE testdecimal_vu_prepare_tab21 (id INT IDENTITY(1,1) PRIMARY KEY,in4 DECIMAL(10,2),in5 DECIMAL(10,2)); + +CREATE TABLE tab2 (id INT IDENTITY(1,1) PRIMARY KEY, a DECIMAL(10,2)); + +INSERT INTO testdecimal_vu_prepare_tab21 (in4, in5) VALUES (10.50, 2.00), (25.75, 4.00), (100.00, 0.50), (7.25, 3.00), (50.00, 1.50); +go + +INSERT INTO tab2 (a) VALUES (30.00), (45.50), (75.25), (12.75), (60.00); + +select result1+result1 as result2 , a from (SELECT a , a AS result1 FROM tab2 union all SELECT in4, in4 + in5 AS result FROM testdecimal_vu_prepare_tab21) +go + +-- getting +-- result2 a +-- ---------------------------------------- ------------ +-- 25.00000000 10.50 +-- 59.50000000 25.75 +-- 201.00000000 100.00 +-- 20.50000000 7.25 +-- 103.00000000 50.00 +-- 60.00000000 30.00 +-- 91.00000000 45.50 +-- 150.50000000 75.25 +-- 25.50000000 12.75 +-- 120.00000000 60.00 + +-- expected +-- result2 a +-- -------------- ------------ +-- 25.00 10.50 +-- 59.50 25.75 +-- 201.00 100.00 +-- 20.50 7.25 +-- 103.00 50.00 +-- 60.00 30.00 +-- 91.00 45.50 +-- 150.50 75.25 +-- 25.50 12.75 +-- 120.00 60.00 + +-- with my change and without parallel query +-- result2 a +-- -------------- ------------ +-- 60.00 30.00 +-- 91.00 45.50 +-- 150.50 75.25 +-- 25.50 12.75 +-- 120.00 60.00 +-- 25.00 10.50 +-- 59.50 25.75 +-- 201.00 100.00 +-- 20.50 7.25 +-- 103.00 50.00 + +-- with return -> with my changes 9n parallel +-- 2> go +-- result2 a +-- -------------- ------------ +-- 25.00 10.50 +-- 59.50 25.75 +-- 201.00 100.00 +-- 20.50 7.25 +-- 103.00 50.00 +-- 60.00 30.00 +-- 91.00 45.50 +-- 150.50 75.25 +-- 25.50 12.75 +-- 120.00 60.00 + + +CREATE TABLE testdecimal_vu_prepare_tab2 (id INT IDENTITY(1,1) PRIMARY KEY, in4 DECIMAL(20,6), in5 DECIMAL(20,6)); +CREATE TABLE tab2 (id INT IDENTITY(1,1) PRIMARY KEY, a DECIMAL(20,6)); +INSERT INTO testdecimal_vu_prepare_tab2 (in4, in5) VALUES (99999999999999.111111, 11111111111111.999999); +INSERT INTO tab2 (a) VALUES (99999999999999.111111); +-- correct +select result1+result1 as result2 , a from (SELECT a , a AS result1 FROM tab2 union all SELECT in4, in4 + in5 AS result FROM testdecimal_vu_prepare_tab2) From 74afd33a8f2e2ba5ab22d220aa15d6494dc25e0a Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Fri, 24 Jan 2025 08:56:15 +0000 Subject: [PATCH 21/21] updating condition Signed-off-by: Tanya Gupta --- contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index 412c5ec69c..b0e4c3a20c 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -705,7 +705,7 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) outerplan = outerPlan(plan); /* If this var referes to tuple returned by its outer plan then find the original tle from it */ - if (plan != NULL && var->varno == OUTER_VAR) + if (plan && outerplan && (IsA(outerplan, Gather) || IsA(plan, Gather))) { Assert(plan); Assert(outerplan);