diff --git a/contrib/babelfishpg_tds/src/backend/tds/tds_srv.c b/contrib/babelfishpg_tds/src/backend/tds/tds_srv.c index 08fe027b7f..812602532d 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tds_srv.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tds_srv.c @@ -204,6 +204,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 406f17d90d..0277465baf 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -23,6 +23,7 @@ #include "catalog/indexing.h" #include "catalog/pg_proc.h" #include "catalog/pg_type.h" +#include "catalog/pg_cast.h" #include "miscadmin.h" #include "nodes/makefuncs.h" #include "nodes/pathnodes.h" @@ -131,15 +132,27 @@ static Oid sys_vector_oid = InvalidOid; static Oid sys_sparsevec_oid = InvalidOid; static Oid sys_halfvec_oid = InvalidOid; static Oid decimal_oid = InvalidOid; +static Oid tsql_fixeddecimal_numeric_oid = InvalidOid; +static Oid tsql_numeric_fixeddecimal_oid = InvalidOid; +static Oid tsql_bit_numeric_oid = InvalidOid; +static Oid tsql_int4_bit_oid = InvalidOid; +static Oid sys_nspoid = InvalidOid; +static Oid tsql_bit_oid = InvalidOid; +static Oid tsql_fixeddecimal_oid = InvalidOid; static void FillTabNameWithNumParts(StringInfo buf, uint8 numParts, TdsRelationMetaDataInfo relMetaDataInfo); static void FillTabNameWithoutNumParts(StringInfo buf, uint8 numParts, TdsRelationMetaDataInfo relMetaDataInfo); static void SetTdsEstateErrorData(void); static void ResetTdsEstateErrorData(void); +static bool is_numeric_cast(Oid func_oid); 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); +static bool is_tsql_fixeddecimal_numeric(Oid oid); +static bool is_tsql_numeric_fixeddecimal(Oid oid); +static bool is_tsql_bit_numeric(Oid oid); +static bool is_tsql_int4_bit(Oid oid); +static Oid LookupCastFuncName(Oid castsource, Oid casttarget); static inline void SendPendingDone(bool more) @@ -516,6 +529,96 @@ resolve_numeric_typmod_outer_var(Plan *plan, AttrNumber attno) return resolve_numeric_typmod_from_exp(outerplan, (Node *)tle->expr); } +static Oid +LookupCastFuncName(Oid castsource, Oid casttarget) +{ + HeapTuple tuple; + Form_pg_cast castForm; + + tuple = SearchSysCache2(CASTSOURCETARGET, + ObjectIdGetDatum(castsource), + ObjectIdGetDatum(casttarget)); + if (HeapTupleIsValid(tuple)) + { + castForm = (Form_pg_cast) GETSTRUCT(tuple); + ReleaseSysCache(tuple); + return castForm->castfunc; + } + return InvalidOid; +} + +static bool +is_tsql_bit_numeric(Oid oid) +{ + if (!OidIsValid(tsql_bit_numeric_oid)) + tsql_bit_numeric_oid = LookupCastFuncName(tsql_bit_oid, NUMERICOID); + return tsql_bit_numeric_oid == oid; +} + +static bool +is_tsql_fixeddecimal_numeric(Oid oid) +{ + if (!OidIsValid(tsql_fixeddecimal_numeric_oid)) + tsql_fixeddecimal_numeric_oid = LookupCastFuncName(tsql_fixeddecimal_oid, NUMERICOID); + return tsql_fixeddecimal_numeric_oid == oid; +} + +static bool +is_tsql_numeric_fixeddecimal(Oid oid) +{ + if (!OidIsValid(tsql_numeric_fixeddecimal_oid)) + tsql_numeric_fixeddecimal_oid = LookupCastFuncName(NUMERICOID, tsql_fixeddecimal_oid); + return tsql_numeric_fixeddecimal_oid == oid; +} + +static bool +is_tsql_int4_bit(Oid oid) +{ + if (!OidIsValid(tsql_int4_bit_oid)) + tsql_int4_bit_oid = LookupCastFuncName(INT4OID, tsql_bit_oid); + return tsql_int4_bit_oid == oid; +} + +/* + * is_numeric_cast checks if the given datatype can be cast to NUMERIC. + * This information is used when processing T_FuncExpr nodes to determine + * if resolve_numeric_typmod_from_exp should be called recursively. + * This ensures proper typmod resolution for nested numeric conversions. + */ +static bool +is_numeric_cast(Oid func_oid) +{ + if (!OidIsValid(sys_nspoid)) + sys_nspoid = get_namespace_oid("sys", false); + + if (!OidIsValid(tsql_bit_oid)) + tsql_bit_oid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid, CStringGetDatum("bit"), ObjectIdGetDatum(sys_nspoid)); + + if (!OidIsValid(tsql_fixeddecimal_oid)) + tsql_fixeddecimal_oid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid, CStringGetDatum("fixeddecimal"), ObjectIdGetDatum(sys_nspoid)); + + if (func_oid == F_NUMERIC_INT4 || + func_oid == F_NUMERIC_INT8 || + func_oid == F_NUMERIC_INT2 || + func_oid == F_NUMERIC_FLOAT4 || + func_oid == F_NUMERIC_FLOAT8 || + func_oid == F_INT8_INT4 || + func_oid == F_INT4_INT8 || + func_oid == F_INT8_INT2 || + func_oid == F_INT2_INT8 || + func_oid == F_INT4_INT2 || + func_oid == F_INT2_INT4 || + func_oid == F_INT4_NUMERIC || + func_oid == F_INT2_NUMERIC || + func_oid == F_INT8_NUMERIC || + is_tsql_bit_numeric(func_oid) || + is_tsql_int4_bit(func_oid) || + is_tsql_fixeddecimal_numeric(func_oid) || + is_tsql_numeric_fixeddecimal(func_oid)) + return true; + return false; +} + /* * is_numeric_datatype - returns bool if given datatype is numeric or decimal. */ @@ -535,7 +638,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) @@ -546,14 +649,32 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) { Const *con = (Const *) expr; Numeric num; - - if (!is_numeric_datatype(con->consttype) || con->constisnull) + int64 val; + + if ((!(con->consttype == INT4OID) && !is_numeric_datatype(con->consttype)) || + con->constisnull) { /* typmod is undefined */ return -1; } else { + /* + * This function calculates the typmod for INT4 + * constants when called from the babelfishpg_tsql + * extension (referred to as non-plan context). It + * converts the INT4 value to NUMERIC and then determines + * the appropriate typmod. This process ensures correct + * numeric precision handling in Babelfish TSQL operations. + */ + if (plan == NULL && con->consttype == INT4OID) + { + val = con->constvalue; + num = int64_to_numeric(val); + return numeric_get_typmod(num); + } + else if (plan != NULL && con->consttype == INT4OID) + return -1; num = (Numeric) con->constvalue; return numeric_get_typmod(num); } @@ -563,7 +684,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 != NULL && var->varno == OUTER_VAR) { Assert(plan); return (resolve_numeric_typmod_outer_var(plan, var->varattno)); @@ -743,7 +864,6 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) precision = TDS_MAX_NUM_PRECISION; scale = Max(scale - delta, 0); } - /* * Control reaching here for only arithmetic overflow * cases @@ -756,7 +876,7 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) FuncExpr *func = (FuncExpr *) expr; Oid func_oid = InvalidOid; int rettypmod = -1; - + Node *arg = NULL; /* Be smart about length-coercion functions... */ if (exprIsLengthCoercion(expr, &rettypmod)) return rettypmod; @@ -772,6 +892,21 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) rettypmod = pltsql_plugin_handler_ptr->pltsql_read_numeric_typmod(func_oid, func->args == NIL ? 0 : func->args->length, func->funcresulttype); + + /* + * If the following conditions are met then we will recursively find typmod from arg. + * 1) plan == NULL means we are invoking this function during parsing phase. + * 2) rettypmod == -1 means unable to find typmod till now. + * 3) check if only one args and then is that castable to numeric. + */ + if (plan == NULL && + rettypmod == -1 && + list_length(func->args) == 1 && + is_numeric_cast(func_oid)) + { + arg = linitial(func->args); + return resolve_numeric_typmod_from_exp(plan, arg); + } return rettypmod; } case T_NullIfExpr: @@ -943,6 +1078,38 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) else return resolve_numeric_typmod_from_exp(plan, (Node *) rlt->arg); } + case T_CoerceToDomain: + { + /* Copied from exprTypmod. */ + 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: + { + /* Copied from exprTypmod. */ + 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 ec6a1e961f..737e8ef89f 100644 --- a/contrib/babelfishpg_tsql/src/pltsql.h +++ b/contrib/babelfishpg_tsql/src/pltsql.h @@ -1760,6 +1760,7 @@ typedef struct PLtsql_protocol_plugin bool (*get_reset_tds_connection_flag) (); void (*get_tvp_typename_typeschemaname) (char *proc_name, char *target_arg_name, char **tvp_type_name, char **tvp_type_schema_name); + int32 (*get_numeric_typmod_from_exp) (Plan *plan, Node *expr); /* Session level GUCs */ bool quoted_identifier; bool arithabort; diff --git a/contrib/babelfishpg_tsql/src/pltsql_coerce.c b/contrib/babelfishpg_tsql/src/pltsql_coerce.c index ae53fca3e2..5ca58b6748 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_coerce.c +++ b/contrib/babelfishpg_tsql/src/pltsql_coerce.c @@ -51,6 +51,7 @@ #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; @@ -1896,16 +1897,21 @@ 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 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, + numeric_result_typmod = -1; ListCell *lc; common_utility_plugin *utilptr = common_utility_plugin_ptr; @@ -1916,10 +1922,17 @@ 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 */ + /* + * 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 b1 & b2 and p1, p2 are the precision. + */ foreach(lc, exprs) { Node *expr = (Node*) lfirst(lc); @@ -1927,25 +1940,85 @@ tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) 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 UDT then calculate typmod.*/ + if (OidIsValid(immediate_base_type)) + type = getBaseTypeAndTypmod(type, &typmod); + if (typmod == -1 && (*pltsql_protocol_plugin_ptr)) + typmod = (*pltsql_protocol_plugin_ptr)->get_numeric_typmod_from_exp(NULL, expr); + + if (typmod == -1 || getBaseType(type) != NUMERICOID) + 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 > TDS_MAX_NUM_PRECISION) + { + max_scale = Max(0, max_scale - (max_precision - TDS_MAX_NUM_PRECISION)); + max_precision = TDS_MAX_NUM_PRECISION; + } + numeric_result_typmod = ((max_precision << 16) | max_scale) + VARHDRSZ; + } + 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) + * 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; @@ -1954,41 +2027,17 @@ 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) + return numeric_result_typmod; + return max_typmods; } diff --git a/test/JDBC/expected/BABEL-4424.out b/test/JDBC/expected/BABEL-4424.out index 5659724c1a..3094cb026c 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~~ @@ -305,7 +305,7 @@ go ~~START~~ numeric 11 -99 +100 2222222222222222222222222222222222222 19999999999999999999999999999999999998 ~~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..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 @@ -10,3 +10,30 @@ 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 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..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 @@ -52,3 +52,123 @@ 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 + +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 7cbd7d9bfb..f7461d45cb 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~~ @@ -13014,3 +13014,1646 @@ 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~~ + + +-- 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(1 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 + +-- 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.23 +4.56 +7.89 +~~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~~ + + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- 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~~ + + +-- Test Case 93: to get scale and precision of views from system metadata +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V1' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v1#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V2' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v2#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V3' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v3#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V4' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v4#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V5' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v5#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V6' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v6#!#RESULT#!#numeric#!#38#!#38 +~~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..61c1332e78 --- /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 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..a32fcf4b93 --- /dev/null +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-prepare.out @@ -0,0 +1,174 @@ +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..8f0dcf72a0 --- /dev/null +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out @@ -0,0 +1,14659 @@ +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~~ +nvarchar +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~~ +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' 比尔·拉莫斯 ' 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~~ +nvarchar +بطاقة التسجيل - قياسية +~~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~~ +nvarchar + 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~~ +nvarchar +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +بطاقة التسجيل - قياسية +~~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~~ +ntext +登録カード–標準 +~~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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +بطاقة التسجيل - قياسية +~~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~~ +ntext +登録カード–標準 +~~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~~ +ntext +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~~ +ntext +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(1 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 + +-- 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.23 +4.56 +7.89 +~~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~~ + + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- 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~~ + + +-- Test Case 93: to get scale and precision of views from system metadata +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V1' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v1#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V2' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v2#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V3' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v3#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V4' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v4#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V5' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v5#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V6' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v6#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-cleanup.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-cleanup.out index 66fe560185..61c1332e78 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-cleanup.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-cleanup.out @@ -10,3 +10,30 @@ 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 diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out index 6299c6aaa4..a32fcf4b93 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-prepare.out @@ -52,3 +52,123 @@ 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 + +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 3d2606ea2b..b80f9636f6 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~~ @@ -13014,3 +13014,1646 @@ 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~~ + + +-- 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(1 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 + +-- 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.23 +4.56 +7.89 +~~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~~ + + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- 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~~ + + +-- Test Case 93: to get scale and precision of views from system metadata +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V1' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v1#!#RESULT#!#numeric#!#10#!#2 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V2' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v2#!#RESULT#!#numeric#!#14#!#4 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V3' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v3#!#RESULT#!#numeric#!#20#!#0 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V4' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v4#!#RESULT#!#numeric#!#10#!#4 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V5' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v5#!#RESULT#!#numeric#!#10#!#2 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V6' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v6#!#RESULT#!#numeric#!#10#!#2 +~~END~~ + diff --git a/test/JDBC/expected/NUMERIC_TYPMOD.out b/test/JDBC/expected/NUMERIC_TYPMOD.out new file mode 100644 index 0000000000..a4f12d6360 --- /dev/null +++ b/test/JDBC/expected/NUMERIC_TYPMOD.out @@ -0,0 +1,1889 @@ + +-- T_Var (Variable reference) +DECLARE @num1 NUMERIC(10,4) = 1234.5678; +DECLARE @dec1 DECIMAL(12,2) = 9876.54; +SELECT CASE + WHEN 1 = 1 THEN @num1 + ELSE @dec1 +END AS result; +GO +~~START~~ +numeric +1234.5678 +~~END~~ + + +-- T_Const (Constant value) +SELECT CASE 1 + WHEN 1 THEN CAST(1234.5678 AS NUMERIC(10,4)) + WHEN 2 THEN CAST(9876.54 AS DECIMAL(12,2)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS result; +GO +~~START~~ +numeric +1234.5678 +~~END~~ + + +-- T_SubscriptingRef (Array or json subscripting) +DECLARE @jsonVar NVARCHAR(MAX) = N'{"a": 123.45, "b": 678.90}'; +SELECT CASE + WHEN 1 = 1 THEN CAST(JSON_VALUE(@jsonVar, '$.a') AS NUMERIC(10,2)) + ELSE CAST(JSON_VALUE(@jsonVar, '$.b') AS DECIMAL(10,2)) +END AS result; +GO +~~START~~ +numeric +123.45 +~~END~~ + + +-- T_NamedArgExpr (Named argument in a function call) +CREATE FUNCTION dbo.TestNamedArg (@param1 NUMERIC(10,4) = 0, @param2 DECIMAL(12,2) = 0) +RETURNS DECIMAL(15,4) +AS +BEGIN + RETURN CASE + WHEN 1 = 1 THEN @param1 + ELSE @param2 + END; +END; +GO + +SELECT dbo.TestNamedArg(1234.56, 7890.1234) AS result; +GO +~~START~~ +numeric +1234.5600 +~~END~~ + + +DROP FUNCTION dbo.TestNamedArg +GO + +-- T_NullIfExpr (NULLIF expression) +SELECT CASE + WHEN 1 = 1 THEN NULLIF(CAST(1234.56 AS NUMERIC(10,2)), CAST(1234.56 AS DECIMAL(12,2))) + ELSE CAST(9999.99 AS DECIMAL(10,2)) +END AS result; +GO +~~START~~ +numeric + +~~END~~ + + +-- T_SubLink (Subquery expressions) +SELECT CASE + WHEN 1 = 1 THEN (SELECT AVG(CAST(1234.56 AS NUMERIC(10,2)))) + ELSE CAST(9876.54 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +1234.560000 +~~END~~ + + +-- T_SubPlan (Subplan expression) +SELECT CASE + WHEN 1 = 1 THEN (SELECT TOP 1 CAST(1234.56 AS NUMERIC(10,2)) WHERE 1=1) + ELSE CAST(9876.54 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +-- T_AlternativeSubPlan (Alternative subplan) +SELECT CASE + WHEN 1 = 1 THEN ( + SELECT CAST(1234.56 AS NUMERIC(10,2)) WHERE 1=1 + UNION ALL + SELECT CAST(9876.54 AS DECIMAL(12,2)) WHERE 1=0 + ) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +-- T_FieldSelect (Field selection) +DECLARE @myTable TABLE (id INT, num_col NUMERIC(10,2), dec_col DECIMAL(12,2)); +INSERT INTO @myTable VALUES (1, 1234.56, 7890.12); +SELECT CASE + WHEN 1 = 1 THEN t.num_col + ELSE t.dec_col +END AS result +FROM @myTable t; +GO +~~ROW COUNT: 1~~ + +~~START~~ +numeric +1234.56 +~~END~~ + + +-- T_RelabelType (Relabel Type) +SELECT CASE + WHEN 1 = 1 THEN CAST(CAST(1234.56 AS NUMERIC(10,2)) AS DECIMAL(12,2)) + ELSE CAST(9876.54 AS NUMERIC(10,2)) +END AS result; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + + +-- T_ArrayCoerceExpr (Array Coerce Expression) +DECLARE @myArray TABLE (val NUMERIC(10,2)); +INSERT INTO @myArray VALUES (1234.56), (7890.12), (5678.90); +SELECT CASE + WHEN 1 = 1 THEN CAST(val AS DECIMAL(12,2)) + ELSE val +END AS result +FROM @myArray; +GO +~~ROW COUNT: 3~~ + +~~START~~ +numeric +1234.56 +7890.12 +5678.90 +~~END~~ + + +-- T_CollateExpr (Collate Expression) +SELECT CASE + WHEN 1 = 1 THEN CAST(1234.56 AS NUMERIC(10,2)) COLLATE Latin1_General_CI_AS + ELSE CAST(9876.54 AS DECIMAL(12,2)) +END AS result; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: collations are not supported by type numeric)~~ + + +-- T_CaseExpr (Nested CASE expression) +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN 9876.54 > 5000 THEN CAST(9876.54 AS DECIMAL(12,2)) + ELSE CAST(1234.56 AS NUMERIC(10,2)) + END + ELSE CAST(5678.90 AS DECIMAL(10,2)) +END AS result; +GO +~~START~~ +numeric +9876.54 +~~END~~ + + +-- T_CaseTestExpr (CASE test expression) +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)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT; +GO +~~START~~ +numeric +9999999.9900 +~~END~~ + + +-- T_CoalesceExpr (COALESCE expression) +SELECT CASE + WHEN 1 = 1 THEN COALESCE(CAST(NULL AS NUMERIC(10,2)), CAST(1234.56 AS DECIMAL(12,2)), CAST(7890.12 AS NUMERIC(10,2))) + ELSE CAST(1111.11 AS NUMERIC(10,2)) +END AS result; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +-- T_MinMaxExpr (GREATEST and LEAST expressions) +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN CAST(1234.56 AS NUMERIC(10,2)) > CAST(7890.12 AS DECIMAL(12,2)) + THEN CAST(1234.56 AS NUMERIC(10,2)) + ELSE CAST(7890.12 AS DECIMAL(12,2)) + END + ELSE CAST(0 AS DECIMAL(12,2)) +END AS greatest_result; +GO +~~START~~ +numeric +7890.12 +~~END~~ + + +-- T_JsonValueExpr (JSON Value Expression) +DECLARE @json NVARCHAR(MAX) = N'{"value": 1234.56}'; +SELECT CASE + WHEN 1 = 1 THEN CAST(JSON_VALUE(@json, '$.value') AS DECIMAL(10,2)) + ELSE CAST(1111.11 AS NUMERIC(10,2)) +END AS result; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +-- T_JsonConstructorExpr (JSON Constructor Expression) +SELECT CASE + WHEN 1 = 1 THEN CAST(JSON_VALUE(JSON_MODIFY('{}', '$.num', CAST(1234.56 AS NUMERIC(10,2))), '$.num') AS DECIMAL(10,3)) + ELSE CAST(1111.11 AS NUMERIC(10,2)) +END AS result; +GO +~~START~~ +numeric +1234.560 +~~END~~ + + + + +-- T_CoerceToDomain (Coerce to Domain) +CREATE TABLE dbo.MyDomainTable ( + id INT PRIMARY KEY, + value DECIMAL(10,2) CHECK (value BETWEEN 0 AND 10000) +); +INSERT INTO dbo.MyDomainTable (id, value) +SELECT 1, CASE + WHEN 1 = 1 THEN CAST(1234.56 AS NUMERIC(10,2)) + ELSE CAST(9999.99 AS DECIMAL(10,2)) +END; +SELECT * FROM dbo.MyDomainTable; +GO +~~ROW COUNT: 1~~ + +~~START~~ +int#!#numeric +1#!#1234.56 +~~END~~ + + +DROP TABLE dbo.MyDomainTable; +GO + +-- T_CoerceToDomainValue (Coerce to Domain Value) +SELECT CASE + WHEN 1 = 1 THEN CAST(1234.56 AS NUMERIC(10,2)) + ELSE CAST(9999.99 AS DECIMAL(10,2)) +END AS result; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + + + +-- T_SetToDefault (Set to Default) +CREATE TABLE dbo.DefaultTable ( + id INT PRIMARY KEY, + num_col NUMERIC(10,2) DEFAULT 100.00, + dec_col DECIMAL(12,2) DEFAULT 200.00 +); +INSERT INTO dbo.DefaultTable (id, num_col, dec_col) +VALUES (1, DEFAULT, DEFAULT); +SELECT CASE + WHEN 1 = 1 THEN num_col + ELSE dec_col +END AS result +FROM dbo.DefaultTable; +GO +~~ROW COUNT: 1~~ + +~~START~~ +numeric +100.00 +~~END~~ + + +DROP TABLE dbo.DefaultTable; +GO + +-- T_PlaceHolderVar (Placeholder Variable) +WITH cte AS ( + SELECT CAST(1234.56 AS NUMERIC(10,2)) AS num_val, CAST(7890.12 AS DECIMAL(12,2)) AS dec_val +) +SELECT CASE + WHEN 1 = 1 THEN num_val + ELSE dec_val +END AS result +FROM cte; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +-- For union +-- T_Var (Variable reference) +DECLARE @num1 NUMERIC(10,4) = 1234.5678; +DECLARE @dec1 DECIMAL(12,2) = 9876.54; +SELECT @num1 AS result +UNION ALL +SELECT @dec1 +ORDER BY result; +GO +~~START~~ +numeric +1234.5678 +9876.5400 +~~END~~ + + +-- T_Const (Constant value) +SELECT CAST(1234.5678 AS NUMERIC(10,4)) AS result +UNION ALL +SELECT CAST(9876.54 AS DECIMAL(12,2)) +UNION ALL +SELECT CAST(0 AS DECIMAL(9,4)) +ORDER BY result; +GO +~~START~~ +numeric +0.0000 +1234.5678 +9876.5400 +~~END~~ + + +-- T_SubscriptingRef (Array or json subscripting) +DECLARE @jsonVar NVARCHAR(MAX) = N'{"a": 123.45, "b": 678.90}'; +SELECT CAST(JSON_VALUE(@jsonVar, '$.a') AS NUMERIC(10,2)) AS result +UNION ALL +SELECT CAST(JSON_VALUE(@jsonVar, '$.b') AS DECIMAL(10,2)) +ORDER BY result; +GO +~~START~~ +numeric +123.45 +678.90 +~~END~~ + + +-- T_NullIfExpr (NULLIF expression) +SELECT NULLIF(CAST(1234.56 AS NUMERIC(10,2)), CAST(1234.56 AS DECIMAL(12,2))) AS result +UNION ALL +SELECT CAST(9999.99 AS DECIMAL(10,2)) +ORDER BY result; +GO +~~START~~ +numeric + +9999.99 +~~END~~ + + +-- T_SubLink (Subquery expressions) +SELECT (SELECT AVG(CAST(1234.56 AS NUMERIC(10,2)))) AS result +UNION ALL +SELECT CAST(9876.54 AS DECIMAL(12,2)) +ORDER BY result; +GO +~~START~~ +numeric +1234.560000 +9876.540000 +~~END~~ + + +-- T_SubPlan (Subplan expression) +SELECT (SELECT TOP 1 CAST(1234.56 AS NUMERIC(10,2)) WHERE 1=1) AS result +UNION ALL +SELECT CAST(9876.54 AS DECIMAL(12,2)) +ORDER BY result; +GO +~~START~~ +numeric +1234.56 +9876.54 +~~END~~ + + +-- T_AlternativeSubPlan (Alternative subplan) +SELECT CAST(1234.56 AS NUMERIC(10,2)) AS result WHERE 1=1 +UNION ALL +SELECT CAST(9876.54 AS DECIMAL(12,2)) WHERE 1=1 +UNION ALL +SELECT CAST(0 AS DECIMAL(12,2)) +ORDER BY result; +GO +~~START~~ +numeric +0.00 +1234.56 +9876.54 +~~END~~ + + +-- T_FieldSelect (Field selection) +DECLARE @myTable TABLE (id INT, num_col NUMERIC(10,2), dec_col DECIMAL(12,2)); +INSERT INTO @myTable VALUES (1, 1234.56, 7890.12); +SELECT t.num_col AS result +FROM @myTable t +UNION ALL +SELECT t.dec_col +FROM @myTable t +ORDER BY result; +GO +~~ROW COUNT: 1~~ + +~~START~~ +numeric +1234.56 +7890.12 +~~END~~ + + + + +-- T_RelabelType (Relabel Type) +SELECT CAST(CAST(1234.56 AS NUMERIC(10,2)) AS DECIMAL(12,2)) AS result +UNION ALL +SELECT CAST(9876.54 AS NUMERIC(10,2)) +ORDER BY result; +GO +~~START~~ +numeric +1234.56 +9876.54 +~~END~~ + + +-- T_ArrayCoerceExpr (Array Coerce Expression) +DECLARE @myArray TABLE (val NUMERIC(10,2)); +INSERT INTO @myArray VALUES (1234.56), (7890.12), (5678.90); +SELECT CAST(val AS DECIMAL(12,2)) AS result +FROM @myArray +UNION ALL +SELECT val +FROM @myArray +ORDER BY result; +GO +~~ROW COUNT: 3~~ + +~~START~~ +numeric +1234.56 +1234.56 +5678.90 +5678.90 +7890.12 +7890.12 +~~END~~ + + +-- T_CollateExpr (Collate Expression) +SELECT CAST(1234.56 AS NUMERIC(10,2)) COLLATE Latin1_General_CI_AS AS result +UNION ALL +SELECT CAST(9876.54 AS DECIMAL(12,2)) +ORDER BY result; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: collations are not supported by type numeric)~~ + + +-- T_CaseExpr (Nested CASE expression) +SELECT CASE + WHEN 9876.54 > 5000 THEN CAST(9876.54 AS DECIMAL(12,2)) + ELSE CAST(1234.56 AS NUMERIC(10,2)) +END AS result +UNION ALL +SELECT CAST(5678.90 AS DECIMAL(10,2)) +ORDER BY result; +GO +~~START~~ +numeric +5678.90 +9876.54 +~~END~~ + + +-- T_CaseTestExpr (CASE test expression) +SELECT CAST(99999.9999 AS DECIMAL(9,4)) AS result +UNION ALL +SELECT CAST(999999.999 AS NUMERIC(9,3)) +UNION ALL +SELECT CAST(9999999.99 AS DECIMAL(9,2)) +UNION ALL +SELECT CAST(0 AS DECIMAL(9,4)) +ORDER BY result; +GO +~~START~~ +numeric +0.0000 +99999.9999 +999999.9990 +9999999.9900 +~~END~~ + + +-- T_ArrayExpr (Array constructor) +SELECT v +FROM (VALUES (CAST(1234.56 AS DECIMAL(12,2))), (CAST(7890.12 AS NUMERIC(10,2)))) AS t(v) +UNION ALL +SELECT CAST(1111.11 AS NUMERIC(10,2)) +ORDER BY v; +GO +~~START~~ +numeric +1111.11 +1234.56 +7890.12 +~~END~~ + + +-- T_CoalesceExpr (COALESCE expression) +SELECT COALESCE(CAST(NULL AS NUMERIC(10,2)), CAST(1234.56 AS DECIMAL(12,2)), CAST(7890.12 AS NUMERIC(10,2))) AS result +UNION ALL +SELECT CAST(1111.11 AS NUMERIC(10,2)) +ORDER BY result; +GO +~~START~~ +numeric +1111.11 +1234.56 +~~END~~ + + +-- T_MinMaxExpr (GREATEST and LEAST expressions) +SELECT CASE + WHEN CAST(1234.56 AS NUMERIC(10,2)) > CAST(7890.12 AS DECIMAL(12,2)) + THEN CAST(1234.56 AS NUMERIC(10,2)) + ELSE CAST(7890.12 AS DECIMAL(12,2)) +END AS result +UNION ALL +SELECT CAST(0 AS DECIMAL(12,2)) +ORDER BY result; +GO +~~START~~ +numeric +0.00 +7890.12 +~~END~~ + + +-- T_JsonValueExpr (JSON Value Expression) +DECLARE @json NVARCHAR(MAX) = N'{"value": 1234.56}'; +SELECT CAST(JSON_VALUE(@json, '$.value') AS DECIMAL(10,2)) AS result +UNION ALL +SELECT CAST(1111.11 AS NUMERIC(10,2)) +ORDER BY result; +GO +~~START~~ +numeric +1111.11 +1234.56 +~~END~~ + + +-- T_JsonConstructorExpr (JSON Constructor Expression) +SELECT CASE + WHEN 1 = 1 THEN CAST(JSON_VALUE(JSON_MODIFY('{}', '$.num', CAST(1234.56 AS NUMERIC(10,2))), '$.num') AS DECIMAL(10,2)) + ELSE CAST(1111.11 AS NUMERIC(10,2)) +END AS result; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + + + +-- T_CoerceToDomain (Coerce to Domain) +CREATE TABLE dbo.MyDomainTable ( + id INT PRIMARY KEY, + value DECIMAL(10,2) CHECK (value BETWEEN 0 AND 10000) +); +INSERT INTO dbo.MyDomainTable (id, value) +VALUES (1, CAST(1234.56 AS NUMERIC(10,2))); +SELECT value AS result FROM dbo.MyDomainTable +UNION ALL +SELECT CAST(9999.99 AS DECIMAL(10,2)) +ORDER BY result; +GO +~~ROW COUNT: 1~~ + +~~START~~ +numeric +1234.56 +9999.99 +~~END~~ + + +DROP TABLE dbo.MyDomainTable; +GO + +-- T_CoerceToDomainValue (Coerce to Domain Value) +SELECT CAST(1234.56 AS NUMERIC(10,2)) AS result +UNION ALL +SELECT CAST(9999.99 AS DECIMAL(10,2)) +ORDER BY result; +GO +~~START~~ +numeric +1234.56 +9999.99 +~~END~~ + + + + +-- T_SetToDefault (Set to Default) +CREATE TABLE dbo.DefaultTable ( + id INT PRIMARY KEY, + num_col NUMERIC(10,2) DEFAULT 100.00, + dec_col DECIMAL(12,2) DEFAULT 200.00 +); +INSERT INTO dbo.DefaultTable (id, num_col, dec_col) +VALUES (1, DEFAULT, DEFAULT); +SELECT num_col AS result +FROM dbo.DefaultTable +UNION ALL +SELECT dec_col +FROM dbo.DefaultTable +ORDER BY result; +GO +~~ROW COUNT: 1~~ + +~~START~~ +numeric +100.00 +200.00 +~~END~~ + + +DROP TABLE dbo.DefaultTable; +GO + +-- T_PlaceHolderVar (Placeholder Variable) +WITH cte AS ( + SELECT CAST(1234.56 AS NUMERIC(10,2)) AS num_val, CAST(7890.12 AS DECIMAL(12,2)) AS dec_val +) +SELECT num_val AS result +FROM cte +UNION ALL +SELECT dec_val +FROM cte +ORDER BY result; +GO +~~START~~ +numeric +1234.56 +7890.12 +~~END~~ + + +-- Test Case 1: Basic T_SubPlan in CASE +SELECT CASE + WHEN 1 = 1 THEN (SELECT CAST(1234.5678 AS NUMERIC(10,4))) + ELSE (SELECT CAST(9876.54 AS DECIMAL(12,2))) +END AS result; +GO +~~START~~ +numeric +1234.5678 +~~END~~ + + +-- Test Case 2: T_SubPlan with different precisions and scales +SELECT CASE + WHEN (SELECT value FROM (VALUES (1), (2), (3)) AS t(value) WHERE value = 2) = 2 + THEN (SELECT CAST(123456.789 AS NUMERIC(9,3))) + ELSE (SELECT CAST(987.654321 AS DECIMAL(12,6))) +END AS result; +GO +~~START~~ +numeric +123456.789000 +~~END~~ + + +-- Test Case 3: T_SubPlan with aggregation +SELECT CASE + WHEN (SELECT AVG(value) FROM (VALUES (1), (2), (3)) AS t(value)) > 1 + THEN (SELECT SUM(value) FROM (VALUES (10.1), (20.2), (30.3)) AS t(value)) + ELSE (SELECT AVG(value) FROM (VALUES (1.1), (2.2), (3.3)) AS t(value)) +END AS result; +GO +~~START~~ +numeric +60.6 +~~END~~ + + +-- Test Case 4: Multiple T_SubPlans in one CASE +SELECT CASE + WHEN (SELECT CAST(1000.00 AS NUMERIC(10,2))) > + (SELECT CAST(999.99 AS DECIMAL(10,2))) + THEN (SELECT MAX(value) FROM (VALUES (1), (2), (3)) AS t(value)) + ELSE (SELECT MIN(value) FROM (VALUES (4), (5), (6)) AS t(value)) +END AS result; +GO +~~START~~ +int +3 +~~END~~ + + +-- Test Case 5: Nested CASE with T_SubPlan +SELECT CASE + WHEN (SELECT CAST(100 AS NUMERIC(10,0))) > 50 + THEN + CASE + WHEN (SELECT CAST(5.25 AS DECIMAL(5,2))) < 10 + THEN (SELECT AVG(value) FROM (VALUES (1.1111), (2.2222), (3.3333)) AS t(value)) + ELSE (SELECT AVG(value) FROM (VALUES (4.444444), (5.555555), (6.666666)) AS t(value)) + END + ELSE (SELECT CAST(1000.00 AS NUMERIC(12,2))) +END AS result; +GO +~~START~~ +numeric +2.222200 +~~END~~ + + +-- Test Case 6: T_SubPlan with arithmetic operations +SELECT CASE + WHEN 1 = 1 + THEN (SELECT CAST(1000.00 AS NUMERIC(10,2)) / 2) + ELSE (SELECT CAST(500.5555 AS DECIMAL(8,4)) * 3) +END AS result; +GO +~~START~~ +numeric +500.000000 +~~END~~ + + +-- Test Case 8: T_SubPlan with multiple values +SELECT CASE + WHEN (SELECT value FROM (VALUES (1.23), (4.56), (7.89)) AS t(value) WHERE value = 4.56) = 4.56 + THEN (SELECT CAST(123.456 AS NUMERIC(10,3))) + ELSE (SELECT CAST(789.012 AS DECIMAL(10,3))) +END AS result; +GO +~~START~~ +numeric +123.456 +~~END~~ + + +-- Test Case 10: T_SubPlan with conditional aggregation +SELECT CASE + WHEN EXISTS ( + SELECT 1 FROM (VALUES (1), (2), (3)) AS t(value) + WHERE value > 2 + ) + THEN ( + SELECT AVG(CAST(value AS DECIMAL(10,4))) + FROM (VALUES (10.1111), (20.2222), (30.3333)) AS t(value) + WHERE value > 15 + ) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS result; +GO +~~START~~ +numeric +25.277750 +~~END~~ + + +-- Test Case 1: Basic GREATEST simulation in CASE +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN CAST(1234.5678 AS NUMERIC(10,4)) > CAST(9876.54 AS DECIMAL(12,2)) + THEN CAST(1234.5678 AS NUMERIC(10,4)) + ELSE CAST(9876.54 AS DECIMAL(12,2)) + END + ELSE CAST(0 AS DECIMAL(12,4)) +END AS result; +GO +~~START~~ +numeric +9876.5400 +~~END~~ + + +-- Test Case 2: LEAST simulation with different precisions and scales +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN CAST(123.456 AS NUMERIC(6,3)) < CAST(789.12 AS DECIMAL(8,2)) + THEN CAST(123.456 AS NUMERIC(6,3)) + ELSE CAST(789.12 AS DECIMAL(8,2)) + END + ELSE CAST(999.999 AS DECIMAL(6,3)) +END AS result; +GO +~~START~~ +numeric +123.456 +~~END~~ + + +-- Test Case 3: GREATEST with multiple values +SELECT CASE + WHEN 1 = 1 THEN + (SELECT MAX(v) FROM (VALUES + (CAST(1234.56 AS NUMERIC(10,2))), + (CAST(7890.12 AS DECIMAL(12,2))), + (CAST(4567.89 AS NUMERIC(8,2))) + ) AS value(v)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +7890.12 +~~END~~ + + +-- Test Case 4: LEAST with multiple values and different scales +SELECT CASE + WHEN 1 = 1 THEN + (SELECT MIN(v) FROM (VALUES + (CAST(123.4567 AS NUMERIC(10,4))), + (CAST(789.12 AS DECIMAL(8,2))), + (CAST(456.789 AS NUMERIC(6,3))) + ) AS value(v)) + ELSE CAST(999.9999 AS DECIMAL(10,4)) +END AS result; +GO +~~START~~ +numeric +123.4567 +~~END~~ + + +-- Test Case 5: GREATEST with arithmetic operations +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN CAST(1234.56 AS NUMERIC(10,2)) * 2 > CAST(9876.54 AS DECIMAL(12,2)) / 2 + THEN CAST(1234.56 AS NUMERIC(10,2)) * 2 + ELSE CAST(9876.54 AS DECIMAL(12,2)) / 2 + END + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +4938.270000 +~~END~~ + + +-- Test Case 6: LEAST with NULL values +SELECT CASE + WHEN 1 = 1 THEN + (SELECT MIN(v) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(NULL AS DECIMAL(12,2))), + (CAST(789.12 AS NUMERIC(8,2))) + ) AS value(v)) + ELSE CAST(999.99 AS DECIMAL(10,2)) +END AS result; +GO +~~START~~ +numeric +123.45 +~~END~~ + + +-- Test Case 7: GREATEST with all NULL values +SELECT CASE + WHEN 1 = 1 THEN + (SELECT MAX(v) FROM (VALUES + (CAST(NULL AS NUMERIC(10,2))), + (CAST(NULL AS DECIMAL(12,2))), + (CAST(NULL AS NUMERIC(8,2))) + ) AS value(v)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric + +~~END~~ + + +-- Test Case 8: LEAST with very small and very large numbers +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN CAST(0.00000001 AS NUMERIC(16,8)) < CAST(99999999.99 AS DECIMAL(10,2)) + THEN CAST(0.00000001 AS NUMERIC(16,8)) + ELSE CAST(99999999.99 AS DECIMAL(10,2)) + END + ELSE CAST(1 AS DECIMAL(16,8)) +END AS result; +GO +~~START~~ +numeric +1E-8 +~~END~~ + + +-- Test Case 9: GREATEST with negative numbers +SELECT CASE + WHEN 1 = 1 THEN + (SELECT MAX(v) FROM (VALUES + (CAST(-1234.56 AS NUMERIC(10,2))), + (CAST(-7890.12 AS DECIMAL(12,2))), + (CAST(-4567.89 AS NUMERIC(8,2))) + ) AS value(v)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +-1234.56 +~~END~~ + + +-- Test Case 10: Complex CASE with multiple GREATEST/LEAST simulations +SELECT CASE + WHEN (SELECT MAX(v) FROM (VALUES + (CAST(1234.56 AS NUMERIC(10,2))), + (CAST(7890.12 AS DECIMAL(12,2))) + ) AS value(v)) > 5000 + THEN + (SELECT MIN(v) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(789.12 AS DECIMAL(12,2))) + ) AS value(v)) + ELSE + (SELECT MAX(v) FROM (VALUES + (CAST(4567.89 AS NUMERIC(10,2))), + (CAST(9876.54 AS DECIMAL(12,2))) + ) AS value(v)) +END AS result; +GO +~~START~~ +numeric +123.45 +~~END~~ + + +-- T_CoerceToDomainValue: +-- Setup +CREATE TYPE NumericDomain FROM NUMERIC(10,4); +CREATE TYPE DecimalDomain FROM DECIMAL(12,2); +GO + +-- Test Case 1 +SELECT CASE WHEN 1=1 THEN CAST(123.4567 AS NumericDomain) ELSE CAST(9876.54 AS DecimalDomain) END AS result; +GO +~~START~~ +numeric +123.4567 +~~END~~ + + +-- Test Case 2 +SELECT CASE WHEN 1=0 THEN CAST(123.4567 AS NumericDomain) ELSE CAST(9876.54 AS DecimalDomain) END AS result; +GO +~~START~~ +numeric +9876.5400 +~~END~~ + + +-- Test Case 3 +DECLARE @n NumericDomain = 123.4567; +DECLARE @d DecimalDomain = 9876.54; +SELECT CASE WHEN @n > 100 THEN @n ELSE @d END AS result; +GO +~~START~~ +numeric +123.4567 +~~END~~ + + +-- Test Case 4 +SELECT CASE + WHEN CAST(123.4567 AS NumericDomain) > CAST(100 AS NumericDomain) THEN CAST(123.4567 AS NumericDomain) + ELSE CAST(9876.54 AS DecimalDomain) +END AS result; +GO +~~START~~ +numeric +123.4567 +~~END~~ + + +-- Test Case 5 +SELECT CASE + WHEN 1=1 THEN CAST(CAST(123.4567 AS NUMERIC(10,4)) AS NumericDomain) + ELSE CAST(CAST(9876.54 AS DECIMAL(12,2)) AS DecimalDomain) +END AS result; +GO +~~START~~ +numeric +123.4567 +~~END~~ + + +DROP TYPE NumericDomain +GO + +DROP TYPE DecimalDomain +GO + +-- T_SQLValueFunction: +-- Test Case 1 +SELECT CASE + WHEN SERVERPROPERTY('Edition') = 'Express Edition' THEN CAST(1 AS NUMERIC(1,0)) + ELSE CAST(0 AS DECIMAL(1,0)) +END AS result; +GO +~~START~~ +numeric +0 +~~END~~ + + + +-- T_MinMaxExpr: +-- Test Case 1 +SELECT CASE + WHEN 1=1 THEN + (SELECT MAX(v) FR FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))) + ) AS value(v)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +678.90 +~~END~~ + + +-- Test Case 2 +SELECT CASE + WHEN 1=1 THEN + (SELECT MIN(v) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))), + (CAST(456.78 AS NUMERIC(8,2))) + ) AS value(v)) + ELSE CAST(999.99 AS DECIMAL(10,2)) +END AS result; +GO +~~START~~ +numeric +123.45 +~~END~~ + + +-- Test Case 3 +DECLARE @num1 NUMERIC(10,4) = 123.4567; +DECLARE @num2 DECIMAL(12,2) = 9876.54; +SELECT CASE + WHEN @num1 > @num2 THEN @num1 + ELSE @num2 +END AS result; +GO +~~START~~ +numeric +9876.5400 +~~END~~ + + +-- Test Case 4 +SELECT CASE + WHEN 1=1 THEN + (SELECT MAX(v) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2)) * 2), + (CAST(678.90 AS DECIMAL(12,2)) / 2) + ) AS value(v)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +339.450000 +~~END~~ + + +-- Test Case 5 +SELECT CASE + WHEN (SELECT MAX(v) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))) + ) AS value(v)) > 500 + THEN CAST(1 AS NUMERIC(1,0)) + ELSE CAST(0 AS DECIMAL(1,0)) +END AS result; +GO +~~START~~ +numeric +1 +~~END~~ + + +-- T_ArrayExpr: +-- Test Case 1 +SELECT CASE + WHEN 1=1 THEN + (SELECT v FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))) + ) AS value(v) WHERE v > 500) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +678.90 +~~END~~ + + +-- Test Case 2 +SELECT CASE + WHEN EXISTS(SELECT 1 FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))) + ) AS value(v) WHERE v > 500) + THEN CAST(1 AS NUMERIC(1,0)) + ELSE CAST(0 AS DECIMAL(1,0)) +END AS result; +GO +~~START~~ +numeric +1 +~~END~~ + + +-- Test Case 3 +DECLARE @values TABLE (v NUMERIC(10,2)); +INSERT INTO @values VALUES (123.45), (678.90), (456.78); +SELECT CASE + WHEN EXISTS(SELECT 1 FROM @values WHERE v > 500) + THEN (SELECT MAX(v) FROM @values) + ELSE (SELECT MIN(v) FROM @values) +END AS result; +GO +~~ROW COUNT: 3~~ + +~~START~~ +numeric +678.90 +~~END~~ + + +-- Test Case 4 +SELECT CASE + WHEN 1=1 THEN + (SELECT AVG(v) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))), + (CAST(456.78 AS NUMERIC(10,2))) + ) AS value(v)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +419.710000 +~~END~~ + + +-- Test Case 5 +SELECT CASE + WHEN (SELECT COUNT(*) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))), + (CAST(456.78 AS NUMERIC(10,2))) + ) AS value(v) WHERE v > 500) > 1 + THEN CAST(1 AS NUMERIC(1,0)) + ELSE CAST(0 AS DECIMAL(1,0)) +END AS result; +GO +~~START~~ +numeric +0 +~~END~~ + + +-- T_CaseTestExpr +-- Test Case 1 +SELECT CASE CAST(2 AS NUMERIC(1,0)) + WHEN 1 THEN CAST(100.00 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(200.00 AS DECIMAL(12,2)) + ELSE CAST(0 AS NUMERIC(10,2)) +END AS result; +GO +~~START~~ +numeric +200.00 +~~END~~ + + +-- Test Case 2 +DECLARE @test DECIMAL(2,0) = 3; +SELECT CASE @test + WHEN 1 THEN CAST(100.00 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(200.00 AS DECIMAL(12,2)) + WHEN 3 THEN CAST(300.00 AS NUMERIC(10,2)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +300.00 +~~END~~ + + +-- Test Case 3 +DECLARE @value NUMERIC(3,1) = 10.5; +SELECT CASE CAST(@value AS NUMERIC(3,0)) + WHEN 9 THEN CAST(90.00 AS NUMERIC(10,2)) + WHEN 10 THEN CAST(100.00 AS DECIMAL(10,2)) + ELSE CAST(0 AS NUMERIC(10,2)) +END AS result; +GO +~~START~~ +numeric +0.00 +~~END~~ + + +-- T_ArrayCoerceExpr: +-- Test Case 1 +DECLARE @values TABLE (val NUMERIC(10,2)); +INSERT INTO @values VALUES (123.45), (678.90), (456.78); +SELECT CASE + WHEN 1 = 1 THEN CAST(val AS DECIMAL(12,2)) + ELSE val +END AS result +FROM @values; +GO +~~ROW COUNT: 3~~ + +~~START~~ +numeric +123.45 +678.90 +456.78 +~~END~~ + + +-- Test Case 2 +DECLARE @values TABLE (val DECIMAL(12,2)); +INSERT INTO @values VALUES (123.45), (678.90), (456.78); +SELECT CASE + WHEN 1 = 1 THEN CAST(val AS NUMERIC(10,2)) + ELSE val +END AS result +FROM @values; +GO +~~ROW COUNT: 3~~ + +~~START~~ +numeric +123.45 +678.90 +456.78 +~~END~~ + + +-- Test Case 3 +DECLARE @values TABLE (val NUMERIC(10,2)); +INSERT INTO @values VALUES (123.45), (678.90), (456.78); +SELECT CASE + WHEN val > 500 THEN CAST(val AS DECIMAL(12,2)) + ELSE val +END AS result +FROM @values; +GO +~~ROW COUNT: 3~~ + +~~START~~ +numeric +123.45 +678.90 +456.78 +~~END~~ + + +-- Test Case 4 +DECLARE @values TABLE (val DECIMAL(12,2)); +INSERT INTO @values VALUES (123.45), (678.90), (456.78); +SELECT CASE + WHEN val < 500 THEN CAST(val AS NUMERIC(10,2)) + ELSE val +END AS result +FROM @values; +GO +~~ROW COUNT: 3~~ + +~~START~~ +numeric +123.45 +678.90 +456.78 +~~END~~ + + +-- T_FieldSelect: +-- Setup +CREATE TABLE MyTable ( + id INT PRIMARY KEY, + num_col NUMERIC(10,2), + dec_col DECIMAL(12,2) +); +GO + +INSERT INTO MyTable (id, num_col, dec_col) VALUES +(1, 1234.56, 9876.54), +(2, 2345.67, 8765.43), +(3, 3456.78, 7654.32); +GO +~~ROW COUNT: 3~~ + + +-- Test Case 1 +SELECT CASE + WHEN t.num_col > 2000 THEN t.num_col + ELSE t.dec_col +END AS result +FROM MyTable t; +GO +~~START~~ +numeric +9876.54 +2345.67 +3456.78 +~~END~~ + + +-- Test Case 2 +SELECT CASE + WHEN t.dec_col < 8000 THEN t.num_col + ELSE t.dec_col +END AS result +FROM MyTable t +WHERE t.id = 2; +GO +~~START~~ +numeric +8765.43 +~~END~~ + + +-- Test Case 3 +DECLARE @id INT = 3; +SELECT CASE + WHEN (SELECT num_col FROM MyTable WHERE id = @id) > 3000 THEN (SELECT num_col FROM MyTable WHERE id = @id) + ELSE (SELECT dec_col FROM MyTable WHERE id = @id) +END AS result; +GO +~~START~~ +numeric +3456.78 +~~END~~ + + +-- Test Case 4 +SELECT CASE + WHEN (SELECT AVG(num_col) FROM MyTable) > 2500 THEN (SELECT MAX(num_col) FROM MyTable) + ELSE (SELECT MIN(dec_col) FROM MyTable) +END AS result; +GO +~~START~~ +numeric +7654.32 +~~END~~ + + +-- Test Case 5 +SELECT CASE + WHEN (SELECT COUNT(*) FROM MyTable WHERE num_col > 3000) > 1 THEN (SELECT SUM(num_col) FROM MyTable) + ELSE (SELECT AVG(dec_col) FROM MyTable) +END AS result; +GO +~~START~~ +numeric +8765.43 +~~END~~ + + + +-- T_AlternativeSubPlan: +-- This is typically an internal optimization structure, but we can simulate with a UNION ALL. +-- Test Case 1 +SELECT CASE + WHEN 1 = 1 THEN + (SELECT CAST(123.45 AS NUMERIC(10,2)) WHERE 1 = 1 + UNION ALL + SELECT CAST(678.90 AS DECIMAL(12,2)) WHERE 1 = 0) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +123.45 +~~END~~ + + +-- Test Case 2 +DECLARE @flag BIT = 1; +SELECT CASE + WHEN @flag = 1 THEN + (SELECT CAST(123.45 AS NUMERIC(10,2)) WHERE @flag = 1 + UNION ALL + SELECT CAST(678.90 AS DECIMAL(12,2)) WHERE @flag = 0) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +123.45 +~~END~~ + + +-- Test Case 3 +SELECT CASE + WHEN (SELECT COUNT(*) FROM ( + SELECT CAST(123.45 AS NUMERIC(10,2)) WHERE 1 = 1 + UNION ALL + SELECT CAST(678.90 AS DECIMAL(12,2)) WHERE 1 = 0 + ) t) > 0 THEN CAST(1 AS NUMERIC(1,0)) + ELSE CAST(0 AS DECIMAL(1,0)) +END AS result; +GO +~~START~~ +numeric +1 +~~END~~ + + +-- Test Case 4 +DECLARE @condition BIT = 1; +SELECT CASE + WHEN @condition = 1 THEN + (SELECT CAST(123.45 AS NUMERIC(10,2)) WHERE @condition = 1 + UNION ALL + SELECT CAST(678.90 AS DECIMAL(12,2)) WHERE @condition = 0) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +123.45 +~~END~~ + + +-- T_SubPlan: +-- Test Case 1 +SELECT CASE + WHEN 1 = 1 THEN (SELECT TOP 1 CAST(123.45 AS NUMERIC(10,2)) FROM MyTable) + ELSE (SELECT TOP 1 CAST(678.90 AS DECIMAL(12,2)) FROM MyTable) +END AS result; +GO +~~START~~ +numeric +123.45 +~~END~~ + + +-- Test Case 2 +SELECT CASE + WHEN (SELECT COUNT(*) FROM MyTable WHERE num_col > 2000) > 0 + THEN (SELECT AVG(CAST(num_col AS NUMERIC(10,2))) FROM MyTable) + ELSE (SELECT AVG(CAST(dec_col AS DECIMAL(12,2))) FROM MyTable) +END AS result; +GO +~~START~~ +numeric +2345.670000 +~~END~~ + + +-- Test Case 3 +SELECT CASE + WHEN (SELECT MAX(num_col) FROM MyTable) > (SELECT MIN(dec_col) FROM MyTable) + THEN (SELECT SUM(CAST(num_col AS NUMERIC(15,2))) FROM MyTable) + ELSE (SELECT SUM(CAST(dec_col AS DECIMAL(15,2))) FROM MyTable) +END AS result; +GO +~~START~~ +numeric +26296.29 +~~END~~ + + +-- Test Case 4 +SELECT CASE + WHEN EXISTS (SELECT 1 FROM MyTable WHERE num_col > 3000) + THEN (SELECT CAST(num_col AS NUMERIC(10,2)) FROM MyTable WHERE id = 1) + ELSE (SELECT CAST(dec_col AS DECIMAL(12,2)) FROM MyTable WHERE id = 2) +END AS result; +GO +~~START~~ +numeric +1234.56 +~~END~~ + + +-- Test Case 5 +SELECT CASE + WHEN (SELECT COUNT(*) FROM MyTable WHERE num_col > (SELECT AVG(num_col) FROM MyTable)) > 1 + THEN (SELECT CAST(SUM(num_col) AS NUMERIC(18,2)) FROM MyTable) + ELSE (SELECT CAST(SUM(dec_col) AS DECIMAL(18,2)) FROM MyTable) +END AS result; +GO +~~START~~ +numeric +26296.29 +~~END~~ + + +DROP TABLE MyTable +GO + +-- T_SubscriptingRef: +-- Test Case 1 +DECLARE @json NVARCHAR(MAX) = N'{"num": 123.45, "dec": 678.90}'; +SELECT CASE + WHEN CAST(JSON_VALUE(@json, '$.num') AS NUMERIC(10,2)) > 100 + THEN CAST(JSON_VALUE(@json, '$.num') AS NUMERIC(10,2)) + ELSE CAST(JSON_VALUE(@json, '$.dec') AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +123.45 +~~END~~ + + +-- Test Case 2 +DECLARE @data TABLE (id INT, num_col NUMERIC(10,2), dec_col DECIMAL(12,2)); +INSERT INTO @data VALUES (1, 123.45, 678.90), (2, 234.56, 567.89); +SELECT CASE + WHEN @data.num_col > 200 THEN @data.num_col + ELSE @data.dec_col +END AS result +FROM @data +WHERE id = 2; +GO +~~ROW COUNT: 2~~ + +~~START~~ +numeric +234.56 +~~END~~ + + +-- Test Case 3 +DECLARE @json NVARCHAR(MAX) = N'{"values": [123.45, 678.90, 456.78]}'; +SELECT CASE + WHEN CAST(JSON_VALUE(@json, '$.values[0]') AS NUMERIC(10,2)) > 500 + THEN CAST(JSON_VALUE(@json, '$.values[1]') AS DECIMAL(12,2)) + ELSE CAST(JSON_VALUE(@json, '$.values[2]') AS NUMERIC(10,2)) +END AS result; +GO +~~START~~ +numeric +456.78 +~~END~~ + + +-- Test Case 4 +DECLARE @data TABLE (id INT, num_col NUMERIC(10,2), dec_col DECIMAL(12,2)); +INSERT INTO @data VALUES (1, 123.45, 678.90), (2, 234.56, 567.89); +SELECT CASE + WHEN (SELECT num_col FROM @data WHERE id = 2) > 200 + THEN (SELECT num_col FROM @data WHERE id = 2) + ELSE (SELECT dec_col FROM @data WHERE id = 2) +END AS result; +GO +~~ROW COUNT: 2~~ + +~~START~~ +numeric +234.56 +~~END~~ + + +-- Test Case 5 +DECLARE @json NVARCHAR(MAX) = N'{"nums": [123.45, 234.56, 345.67], "decs": [678.90, 567.89, 456.78]}'; +SELECT CASE + WHEN CAST(JSON_VALUE(@json, '$.nums[0]') AS NUMERIC(10,2)) > 200 + THEN CAST(JSON_VALUE(@json, '$.decs[1]') AS DECIMAL(12,2)) + ELSE CAST(JSON_VALUE(@json, '$.nums[2]') AS NUMERIC(10,2)) +END AS result; +GO +~~START~~ +numeric +345.67 +~~END~~ + + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- Money datatypes testing +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN 1=1 + THEN CAST(1234.56 AS NUMERIC(10,2)) * cast(5.5 as smallmoney) + ELSE CAST(9876.54 AS DECIMAL(12,2)) / cast(6.43 as smallmoney) + END + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +6790.080000 +~~END~~ + + +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN 1=1 + THEN CAST(1234.56 AS NUMERIC(10,2)) * cast(5.5 as money) + ELSE CAST(9876.54 AS DECIMAL(12,2)) / cast(6.43 as smallmoney) + END + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +6790.080000 +~~END~~ + + +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN 1=1 + THEN CAST(1234.56 AS NUMERIC(10,2)) * cast(5.5 as money) + ELSE CAST(9876.54 AS DECIMAL(12,2)) / cast(6.43 as money) + END + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +6790.080000 +~~END~~ + + +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN 1=1 + THEN CAST(1234.56 AS NUMERIC(10,2)) * cast(5.5 as smallmoney) + ELSE CAST(9876.54 AS DECIMAL(12,2)) / cast(6.43 as money) + END + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO +~~START~~ +numeric +6790.080000 +~~END~~ + + + +-- TODO FIX: Output diff between TSQL and BBF. +-- T_Param (Function parameter) +DROP FUNCTION IF EXISTS dbo.TestParam +GO + +CREATE FUNCTION dbo.TestParam (@param1 NUMERIC(10,4), @param2 DECIMAL(12,2)) +RETURNS TABLE +AS +RETURN +( + SELECT CASE + WHEN 1 = 1 THEN @param1 + ELSE @param2 + END AS result +); +GO + +SELECT * FROM dbo.TestParam(1234.5678, 9876.54); +GO +~~START~~ +numeric +1234.56780000 +~~END~~ + + +DROP FUNCTION dbo.TestParam +GO + +-- T_Param (Function parameter) +DROP FUNCTION IF EXISTS dbo.TestParam +GO + +CREATE FUNCTION dbo.TestParam (@param1 NUMERIC(10,4), @param2 DECIMAL(12,2)) +RETURNS TABLE +AS +RETURN +( + SELECT @param1 AS result + UNION ALL + SELECT @param2 + ORDER BY result +); +GO + +SELECT * FROM dbo.TestParam(1234.5678, 9876.54); +GO +~~START~~ +numeric +1234.56780000 +9876.54000000 +~~END~~ + + +DROP FUNCTION dbo.TestParam +GO + +-- T_NamedArgExpr (Named argument in a function call) +DROP FUNCTION IF EXISTS dbo.TestNamedArg +GO + +CREATE FUNCTION dbo.TestNamedArg (@param1 NUMERIC(10,4) = 0, @param2 DECIMAL(12,2) = 0) +RETURNS TABLE +AS +RETURN +( + SELECT @param1 AS result + UNION ALL + SELECT @param2 + ORDER BY result +); +GO + +SELECT * FROM dbo.TestNamedArg(1234.56, 7890.1234); +GO +~~START~~ +numeric +1234.56000000 +7890.12000000 +~~END~~ + + +DROP FUNCTION dbo.TestNamedArg; +GO + +-- Setup +DROP FUNCTION IF EXISTS dbo.TestFunction; +GO + +CREATE FUNCTION dbo.TestFunction (@num NUMERIC(10,2), @dec DECIMAL(12,2)) +RETURNS TABLE +AS +RETURN +( + SELECT CASE + WHEN @num > @dec THEN @num + ELSE @dec + END AS result +); +GO + +-- T_NamedArgExpr: +-- Test Case 1 +SELECT * FROM dbo.TestFunction(123.45, 678.90); +GO +~~START~~ +numeric +678.90000000 +~~END~~ + + +-- Test Case 2 +SELECT * FROM dbo.TestFunction(678.90, 123.45); +GO +~~START~~ +numeric +678.90000000 +~~END~~ + + +-- Test Case 3 +DECLARE @n NUMERIC(10,2) = 123.45; +DECLARE @d DECIMAL(12,2) = 678.90; +SELECT * FROM dbo.TestFunction(@n, @d); +GO +~~START~~ +numeric +678.90000000 +~~END~~ + + +-- Test Case 4 +SELECT * FROM dbo.TestFunction(678.90, CAST(123.45 AS NUMERIC(10,2))); +GO +~~START~~ +numeric +678.90000000 +~~END~~ + + +-- Test Case 5 +SELECT * FROM dbo.TestFunction(CAST(123.45 AS NUMERIC(10,2)), CAST(678.90 AS DECIMAL(12,2))); +GO +~~START~~ +numeric +678.90000000 +~~END~~ + + +DROP FUNCTION dbo.TestFunction; +go + + + +-- TODO FIX: SQRT function returns float in TSQL. while +-- selecting commontype between flaot ansd numeric, +-- is selected. where as in BBF SQRT function returns numeric. +-- Test Case: T_SubPlan with different numeric operations +SELECT CASE + WHEN (SELECT POWER(CAST(2 AS NUMERIC(5,2)), 3)) > 7 + THEN (SELECT SQRT(CAST(100 AS NUMERIC(10,4)))) + ELSE (SELECT CAST(PI() AS DECIMAL(10,8))) +END AS result; +GO +~~START~~ +numeric +10.00000000 +~~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/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 48250a5087..1256aaff92 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,1646 @@ 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~~ + + +-- 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(1 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 + +-- 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.23 +4.56 +7.89 +~~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~~ + + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- 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~~ + + +-- Test Case 93: to get scale and precision of views from system metadata +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V1' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v1#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V2' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v2#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V3' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v3#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V4' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v4#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V5' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v5#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V6' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v6#!#RESULT#!#numeric#!#38#!#38 +~~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..b7e1dd79ab --- /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,14659 @@ +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~~ +nvarchar +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~~ +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' 比尔·拉莫斯 ' 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~~ +nvarchar +بطاقة التسجيل - قياسية +~~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~~ +nvarchar + 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~~ +nvarchar +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +بطاقة التسجيل - قياسية +~~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~~ +ntext +登録カード–標準 +~~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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +بطاقة التسجيل - قياسية +~~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~~ +ntext +登録カード–標準 +~~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~~ +ntext +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~~ +ntext +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(1 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 + +-- 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.23 +4.56 +7.89 +~~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~~ + + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- 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~~ + + +-- Test Case 93: to get scale and precision of views from system metadata +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V1' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v1#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V2' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v2#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V3' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v3#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V4' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v4#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V5' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v5#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V6' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v6#!#RESULT#!#numeric#!#38#!#38 +~~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 8851f6b1a1..5c610c1961 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,1646 @@ 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~~ + + +-- 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(1 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 + +-- 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.23 +4.56 +7.89 +~~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~~ + + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- 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~~ + + +-- Test Case 93: to get scale and precision of views from system metadata +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V1' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v1#!#RESULT#!#numeric#!#10#!#2 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V2' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v2#!#RESULT#!#numeric#!#14#!#4 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V3' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v3#!#RESULT#!#numeric#!#20#!#0 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V4' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v4#!#RESULT#!#numeric#!#10#!#4 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V5' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v5#!#RESULT#!#numeric#!#10#!#2 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V6' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v6#!#RESULT#!#numeric#!#10#!#2 +~~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 76db9b06e9..146399764f 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,1647 @@ 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~~ + + +-- 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(1 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 + +-- 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.23 +4.56 +7.89 +~~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~~ + + + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- 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~~ + + +-- Test Case 93: to get scale and precision of views from system metadata +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V1' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v1#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V2' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v2#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V3' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v3#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V4' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v4#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V5' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v5#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V6' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v6#!#RESULT#!#numeric#!#38#!#38 +~~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..483f41ccf1 --- /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,14659 @@ +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~~ +nvarchar +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~~ +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' 比尔·拉莫斯 ' 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~~ +nvarchar +بطاقة التسجيل - قياسية +~~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~~ +nvarchar + 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~~ +nvarchar +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +بطاقة التسجيل - قياسية +~~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~~ +ntext +登録カード–標準 +~~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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +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~~ +ntext +بطاقة التسجيل - قياسية +~~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~~ +ntext +登録カード–標準 +~~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~~ +ntext +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~~ +ntext +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(1 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 + +-- 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.23 +4.56 +7.89 +~~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~~ + + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- 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~~ + + +-- Test Case 93: to get scale and precision of views from system metadata +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V1' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v1#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V2' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v2#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V3' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v3#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V4' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v4#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V5' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v5#!#RESULT#!#numeric#!#38#!#38 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V6' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v6#!#RESULT#!#numeric#!#38#!#38 +~~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 57ab735b4d..d3a8325fd8 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,1646 @@ 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~~ + + +-- 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(1 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 + +-- 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.23 +4.56 +7.89 +~~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~~ + + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- 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~~ + + +-- Test Case 93: to get scale and precision of views from system metadata +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V1' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v1#!#RESULT#!#numeric#!#10#!#2 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V2' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v2#!#RESULT#!#numeric#!#14#!#4 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V3' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v3#!#RESULT#!#numeric#!#20#!#0 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V4' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v4#!#RESULT#!#numeric#!#10#!#4 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V5' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v5#!#RESULT#!#numeric#!#10#!#2 +~~END~~ + + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V6' + AND c.[name] = 'RESULT'; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#tinyint#!#tinyint +babel_5341_v6#!#RESULT#!#numeric#!#10#!#2 +~~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 1c7e215b30..61c1332e78 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,31 @@ 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 + +DROP TABLE BABEL_5341_T2; +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..36caa40dc3 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,112 @@ 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 + +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 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..acb969d183 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,992 @@ 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 + +-- 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(1 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 + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- 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 + +-- Test Case 93: to get scale and precision of views from system metadata +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V1' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V2' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V3' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V4' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V5' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V6' + AND c.[name] = 'RESULT'; +GO 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..61c1332e78 --- /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 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..36caa40dc3 --- /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 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..dd6a93a901 --- /dev/null +++ b/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-verify.sql @@ -0,0 +1,8395 @@ +-- 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(1 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 + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- 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 + +-- Test Case 93: to get scale and precision of views from system metadata +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V1' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V2' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V3' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V4' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V5' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V6' + AND c.[name] = 'RESULT'; +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..61c1332e78 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-vu-cleanup.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-vu-cleanup.sql @@ -9,4 +9,31 @@ 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 + +DROP TABLE BABEL_5341_T2; +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..36caa40dc3 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-vu-prepare.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-vu-prepare.sql @@ -45,4 +45,112 @@ 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 + +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 diff --git a/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql b/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql index 8d4c246d38..dd6a93a901 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,992 @@ 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 + +-- 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(1 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 + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- 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 + +-- Test Case 93: to get scale and precision of views from system metadata +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V1' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V2' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V3' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V4' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V5' + AND c.[name] = 'RESULT'; +GO + +SELECT + o.[name] AS view_name, + c.[name] AS column_name, + t.[name] AS data_type, + c.[precision], + c.[scale] +FROM + sys.views o + INNER JOIN sys.columns c ON o.[object_id] = c.[object_id] + INNER JOIN sys.types t ON c.[user_type_id] = t.[user_type_id] +WHERE + o.[name] = 'BABEL_5341_V6' + AND c.[name] = 'RESULT'; +GO diff --git a/test/JDBC/input/NUMERIC_TYPMOD.sql b/test/JDBC/input/NUMERIC_TYPMOD.sql new file mode 100644 index 0000000000..7b786674ad --- /dev/null +++ b/test/JDBC/input/NUMERIC_TYPMOD.sql @@ -0,0 +1,1231 @@ +-- T_Var (Variable reference) +DECLARE @num1 NUMERIC(10,4) = 1234.5678; +DECLARE @dec1 DECIMAL(12,2) = 9876.54; + +SELECT CASE + WHEN 1 = 1 THEN @num1 + ELSE @dec1 +END AS result; +GO + +-- T_Const (Constant value) +SELECT CASE 1 + WHEN 1 THEN CAST(1234.5678 AS NUMERIC(10,4)) + WHEN 2 THEN CAST(9876.54 AS DECIMAL(12,2)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS result; +GO + +-- T_SubscriptingRef (Array or json subscripting) +DECLARE @jsonVar NVARCHAR(MAX) = N'{"a": 123.45, "b": 678.90}'; +SELECT CASE + WHEN 1 = 1 THEN CAST(JSON_VALUE(@jsonVar, '$.a') AS NUMERIC(10,2)) + ELSE CAST(JSON_VALUE(@jsonVar, '$.b') AS DECIMAL(10,2)) +END AS result; +GO + +-- T_NamedArgExpr (Named argument in a function call) +CREATE FUNCTION dbo.TestNamedArg (@param1 NUMERIC(10,4) = 0, @param2 DECIMAL(12,2) = 0) +RETURNS DECIMAL(15,4) +AS +BEGIN + RETURN CASE + WHEN 1 = 1 THEN @param1 + ELSE @param2 + END; +END; +GO + +SELECT dbo.TestNamedArg(1234.56, 7890.1234) AS result; +GO + +DROP FUNCTION dbo.TestNamedArg +GO + +-- T_NullIfExpr (NULLIF expression) +SELECT CASE + WHEN 1 = 1 THEN NULLIF(CAST(1234.56 AS NUMERIC(10,2)), CAST(1234.56 AS DECIMAL(12,2))) + ELSE CAST(9999.99 AS DECIMAL(10,2)) +END AS result; +GO + +-- T_SubLink (Subquery expressions) +SELECT CASE + WHEN 1 = 1 THEN (SELECT AVG(CAST(1234.56 AS NUMERIC(10,2)))) + ELSE CAST(9876.54 AS DECIMAL(12,2)) +END AS result; +GO + +-- T_SubPlan (Subplan expression) +SELECT CASE + WHEN 1 = 1 THEN (SELECT TOP 1 CAST(1234.56 AS NUMERIC(10,2)) WHERE 1=1) + ELSE CAST(9876.54 AS DECIMAL(12,2)) +END AS result; +GO + +-- T_AlternativeSubPlan (Alternative subplan) +SELECT CASE + WHEN 1 = 1 THEN ( + SELECT CAST(1234.56 AS NUMERIC(10,2)) WHERE 1=1 + UNION ALL + SELECT CAST(9876.54 AS DECIMAL(12,2)) WHERE 1=0 + ) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- T_FieldSelect (Field selection) +DECLARE @myTable TABLE (id INT, num_col NUMERIC(10,2), dec_col DECIMAL(12,2)); +INSERT INTO @myTable VALUES (1, 1234.56, 7890.12); +SELECT CASE + WHEN 1 = 1 THEN t.num_col + ELSE t.dec_col +END AS result +FROM @myTable t; +GO + +-- T_RelabelType (Relabel Type) +SELECT CASE + WHEN 1 = 1 THEN CAST(CAST(1234.56 AS NUMERIC(10,2)) AS DECIMAL(12,2)) + ELSE CAST(9876.54 AS NUMERIC(10,2)) +END AS result; +GO + +-- T_ArrayCoerceExpr (Array Coerce Expression) +DECLARE @myArray TABLE (val NUMERIC(10,2)); +INSERT INTO @myArray VALUES (1234.56), (7890.12), (5678.90); + +SELECT CASE + WHEN 1 = 1 THEN CAST(val AS DECIMAL(12,2)) + ELSE val +END AS result +FROM @myArray; +GO + +-- T_CollateExpr (Collate Expression) +SELECT CASE + WHEN 1 = 1 THEN CAST(1234.56 AS NUMERIC(10,2)) COLLATE Latin1_General_CI_AS + ELSE CAST(9876.54 AS DECIMAL(12,2)) +END AS result; +GO + +-- T_CaseExpr (Nested CASE expression) +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN 9876.54 > 5000 THEN CAST(9876.54 AS DECIMAL(12,2)) + ELSE CAST(1234.56 AS NUMERIC(10,2)) + END + ELSE CAST(5678.90 AS DECIMAL(10,2)) +END AS result; +GO + +-- T_CaseTestExpr (CASE test expression) +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)) + ELSE CAST(0 AS DECIMAL(9,4)) +END AS RESULT; +GO + +-- T_CoalesceExpr (COALESCE expression) +SELECT CASE + WHEN 1 = 1 THEN COALESCE(CAST(NULL AS NUMERIC(10,2)), CAST(1234.56 AS DECIMAL(12,2)), CAST(7890.12 AS NUMERIC(10,2))) + ELSE CAST(1111.11 AS NUMERIC(10,2)) +END AS result; +GO + +-- T_MinMaxExpr (GREATEST and LEAST expressions) +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN CAST(1234.56 AS NUMERIC(10,2)) > CAST(7890.12 AS DECIMAL(12,2)) + THEN CAST(1234.56 AS NUMERIC(10,2)) + ELSE CAST(7890.12 AS DECIMAL(12,2)) + END + ELSE CAST(0 AS DECIMAL(12,2)) +END AS greatest_result; +GO + +-- T_JsonValueExpr (JSON Value Expression) +DECLARE @json NVARCHAR(MAX) = N'{"value": 1234.56}'; +SELECT CASE + WHEN 1 = 1 THEN CAST(JSON_VALUE(@json, '$.value') AS DECIMAL(10,2)) + ELSE CAST(1111.11 AS NUMERIC(10,2)) +END AS result; +GO + +-- T_JsonConstructorExpr (JSON Constructor Expression) +SELECT CASE + WHEN 1 = 1 THEN CAST(JSON_VALUE(JSON_MODIFY('{}', '$.num', CAST(1234.56 AS NUMERIC(10,2))), '$.num') AS DECIMAL(10,3)) + ELSE CAST(1111.11 AS NUMERIC(10,2)) +END AS result; +GO + +-- T_CoerceToDomain (Coerce to Domain) +CREATE TABLE dbo.MyDomainTable ( + id INT PRIMARY KEY, + value DECIMAL(10,2) CHECK (value BETWEEN 0 AND 10000) +); + +INSERT INTO dbo.MyDomainTable (id, value) +SELECT 1, CASE + WHEN 1 = 1 THEN CAST(1234.56 AS NUMERIC(10,2)) + ELSE CAST(9999.99 AS DECIMAL(10,2)) +END; + +SELECT * FROM dbo.MyDomainTable; +GO + +DROP TABLE dbo.MyDomainTable; +GO + +-- T_CoerceToDomainValue (Coerce to Domain Value) +SELECT CASE + WHEN 1 = 1 THEN CAST(1234.56 AS NUMERIC(10,2)) + ELSE CAST(9999.99 AS DECIMAL(10,2)) +END AS result; +GO + +-- T_SetToDefault (Set to Default) +CREATE TABLE dbo.DefaultTable ( + id INT PRIMARY KEY, + num_col NUMERIC(10,2) DEFAULT 100.00, + dec_col DECIMAL(12,2) DEFAULT 200.00 +); + +INSERT INTO dbo.DefaultTable (id, num_col, dec_col) +VALUES (1, DEFAULT, DEFAULT); + +SELECT CASE + WHEN 1 = 1 THEN num_col + ELSE dec_col +END AS result +FROM dbo.DefaultTable; +GO + +DROP TABLE dbo.DefaultTable; +GO + +-- T_PlaceHolderVar (Placeholder Variable) +WITH cte AS ( + SELECT CAST(1234.56 AS NUMERIC(10,2)) AS num_val, CAST(7890.12 AS DECIMAL(12,2)) AS dec_val +) +SELECT CASE + WHEN 1 = 1 THEN num_val + ELSE dec_val +END AS result +FROM cte; +GO + +-- For union +-- T_Var (Variable reference) +DECLARE @num1 NUMERIC(10,4) = 1234.5678; +DECLARE @dec1 DECIMAL(12,2) = 9876.54; +SELECT @num1 AS result +UNION ALL +SELECT @dec1 +ORDER BY result; +GO + +-- T_Const (Constant value) +SELECT CAST(1234.5678 AS NUMERIC(10,4)) AS result +UNION ALL +SELECT CAST(9876.54 AS DECIMAL(12,2)) +UNION ALL +SELECT CAST(0 AS DECIMAL(9,4)) +ORDER BY result; +GO + +-- T_SubscriptingRef (Array or json subscripting) +DECLARE @jsonVar NVARCHAR(MAX) = N'{"a": 123.45, "b": 678.90}'; +SELECT CAST(JSON_VALUE(@jsonVar, '$.a') AS NUMERIC(10,2)) AS result +UNION ALL +SELECT CAST(JSON_VALUE(@jsonVar, '$.b') AS DECIMAL(10,2)) +ORDER BY result; +GO + +-- T_NullIfExpr (NULLIF expression) +SELECT NULLIF(CAST(1234.56 AS NUMERIC(10,2)), CAST(1234.56 AS DECIMAL(12,2))) AS result +UNION ALL +SELECT CAST(9999.99 AS DECIMAL(10,2)) +ORDER BY result; +GO + +-- T_SubLink (Subquery expressions) +SELECT (SELECT AVG(CAST(1234.56 AS NUMERIC(10,2)))) AS result +UNION ALL +SELECT CAST(9876.54 AS DECIMAL(12,2)) +ORDER BY result; +GO + +-- T_SubPlan (Subplan expression) +SELECT (SELECT TOP 1 CAST(1234.56 AS NUMERIC(10,2)) WHERE 1=1) AS result +UNION ALL +SELECT CAST(9876.54 AS DECIMAL(12,2)) +ORDER BY result; +GO + +-- T_AlternativeSubPlan (Alternative subplan) +SELECT CAST(1234.56 AS NUMERIC(10,2)) AS result WHERE 1=1 +UNION ALL +SELECT CAST(9876.54 AS DECIMAL(12,2)) WHERE 1=1 +UNION ALL +SELECT CAST(0 AS DECIMAL(12,2)) +ORDER BY result; +GO + +-- T_FieldSelect (Field selection) +DECLARE @myTable TABLE (id INT, num_col NUMERIC(10,2), dec_col DECIMAL(12,2)); +INSERT INTO @myTable VALUES (1, 1234.56, 7890.12); +SELECT t.num_col AS result +FROM @myTable t +UNION ALL +SELECT t.dec_col +FROM @myTable t +ORDER BY result; +GO + + + +-- T_RelabelType (Relabel Type) +SELECT CAST(CAST(1234.56 AS NUMERIC(10,2)) AS DECIMAL(12,2)) AS result +UNION ALL +SELECT CAST(9876.54 AS NUMERIC(10,2)) +ORDER BY result; +GO + +-- T_ArrayCoerceExpr (Array Coerce Expression) +DECLARE @myArray TABLE (val NUMERIC(10,2)); +INSERT INTO @myArray VALUES (1234.56), (7890.12), (5678.90); +SELECT CAST(val AS DECIMAL(12,2)) AS result +FROM @myArray +UNION ALL +SELECT val +FROM @myArray +ORDER BY result; +GO + +-- T_CollateExpr (Collate Expression) +SELECT CAST(1234.56 AS NUMERIC(10,2)) COLLATE Latin1_General_CI_AS AS result +UNION ALL +SELECT CAST(9876.54 AS DECIMAL(12,2)) +ORDER BY result; +GO + +-- T_CaseExpr (Nested CASE expression) +SELECT CASE + WHEN 9876.54 > 5000 THEN CAST(9876.54 AS DECIMAL(12,2)) + ELSE CAST(1234.56 AS NUMERIC(10,2)) +END AS result +UNION ALL +SELECT CAST(5678.90 AS DECIMAL(10,2)) +ORDER BY result; +GO + +-- T_CaseTestExpr (CASE test expression) +SELECT CAST(99999.9999 AS DECIMAL(9,4)) AS result +UNION ALL +SELECT CAST(999999.999 AS NUMERIC(9,3)) +UNION ALL +SELECT CAST(9999999.99 AS DECIMAL(9,2)) +UNION ALL +SELECT CAST(0 AS DECIMAL(9,4)) +ORDER BY result; +GO + +-- T_ArrayExpr (Array constructor) +SELECT v +FROM (VALUES (CAST(1234.56 AS DECIMAL(12,2))), (CAST(7890.12 AS NUMERIC(10,2)))) AS t(v) +UNION ALL +SELECT CAST(1111.11 AS NUMERIC(10,2)) +ORDER BY v; +GO + +-- T_CoalesceExpr (COALESCE expression) +SELECT COALESCE(CAST(NULL AS NUMERIC(10,2)), CAST(1234.56 AS DECIMAL(12,2)), CAST(7890.12 AS NUMERIC(10,2))) AS result +UNION ALL +SELECT CAST(1111.11 AS NUMERIC(10,2)) +ORDER BY result; +GO + +-- T_MinMaxExpr (GREATEST and LEAST expressions) +SELECT CASE + WHEN CAST(1234.56 AS NUMERIC(10,2)) > CAST(7890.12 AS DECIMAL(12,2)) + THEN CAST(1234.56 AS NUMERIC(10,2)) + ELSE CAST(7890.12 AS DECIMAL(12,2)) +END AS result +UNION ALL +SELECT CAST(0 AS DECIMAL(12,2)) +ORDER BY result; +GO + +-- T_JsonValueExpr (JSON Value Expression) +DECLARE @json NVARCHAR(MAX) = N'{"value": 1234.56}'; +SELECT CAST(JSON_VALUE(@json, '$.value') AS DECIMAL(10,2)) AS result +UNION ALL +SELECT CAST(1111.11 AS NUMERIC(10,2)) +ORDER BY result; +GO + +-- T_JsonConstructorExpr (JSON Constructor Expression) +SELECT CASE + WHEN 1 = 1 THEN CAST(JSON_VALUE(JSON_MODIFY('{}', '$.num', CAST(1234.56 AS NUMERIC(10,2))), '$.num') AS DECIMAL(10,2)) + ELSE CAST(1111.11 AS NUMERIC(10,2)) +END AS result; +GO + +-- T_CoerceToDomain (Coerce to Domain) +CREATE TABLE dbo.MyDomainTable ( + id INT PRIMARY KEY, + value DECIMAL(10,2) CHECK (value BETWEEN 0 AND 10000) +); + +INSERT INTO dbo.MyDomainTable (id, value) +VALUES (1, CAST(1234.56 AS NUMERIC(10,2))); + +SELECT value AS result FROM dbo.MyDomainTable +UNION ALL +SELECT CAST(9999.99 AS DECIMAL(10,2)) +ORDER BY result; +GO + +DROP TABLE dbo.MyDomainTable; +GO + +-- T_CoerceToDomainValue (Coerce to Domain Value) +SELECT CAST(1234.56 AS NUMERIC(10,2)) AS result +UNION ALL +SELECT CAST(9999.99 AS DECIMAL(10,2)) +ORDER BY result; +GO + +-- T_SetToDefault (Set to Default) +CREATE TABLE dbo.DefaultTable ( + id INT PRIMARY KEY, + num_col NUMERIC(10,2) DEFAULT 100.00, + dec_col DECIMAL(12,2) DEFAULT 200.00 +); + +INSERT INTO dbo.DefaultTable (id, num_col, dec_col) +VALUES (1, DEFAULT, DEFAULT); + +SELECT num_col AS result +FROM dbo.DefaultTable +UNION ALL +SELECT dec_col +FROM dbo.DefaultTable +ORDER BY result; +GO + +DROP TABLE dbo.DefaultTable; +GO + +-- T_PlaceHolderVar (Placeholder Variable) +WITH cte AS ( + SELECT CAST(1234.56 AS NUMERIC(10,2)) AS num_val, CAST(7890.12 AS DECIMAL(12,2)) AS dec_val +) +SELECT num_val AS result +FROM cte +UNION ALL +SELECT dec_val +FROM cte +ORDER BY result; +GO + +-- Test Case 1: Basic T_SubPlan in CASE +SELECT CASE + WHEN 1 = 1 THEN (SELECT CAST(1234.5678 AS NUMERIC(10,4))) + ELSE (SELECT CAST(9876.54 AS DECIMAL(12,2))) +END AS result; +GO + +-- Test Case 2: T_SubPlan with different precisions and scales +SELECT CASE + WHEN (SELECT value FROM (VALUES (1), (2), (3)) AS t(value) WHERE value = 2) = 2 + THEN (SELECT CAST(123456.789 AS NUMERIC(9,3))) + ELSE (SELECT CAST(987.654321 AS DECIMAL(12,6))) +END AS result; +GO + +-- Test Case 3: T_SubPlan with aggregation +SELECT CASE + WHEN (SELECT AVG(value) FROM (VALUES (1), (2), (3)) AS t(value)) > 1 + THEN (SELECT SUM(value) FROM (VALUES (10.1), (20.2), (30.3)) AS t(value)) + ELSE (SELECT AVG(value) FROM (VALUES (1.1), (2.2), (3.3)) AS t(value)) +END AS result; +GO + +-- Test Case 4: Multiple T_SubPlans in one CASE +SELECT CASE + WHEN (SELECT CAST(1000.00 AS NUMERIC(10,2))) > + (SELECT CAST(999.99 AS DECIMAL(10,2))) + THEN (SELECT MAX(value) FROM (VALUES (1), (2), (3)) AS t(value)) + ELSE (SELECT MIN(value) FROM (VALUES (4), (5), (6)) AS t(value)) +END AS result; +GO + +-- Test Case 5: Nested CASE with T_SubPlan +SELECT CASE + WHEN (SELECT CAST(100 AS NUMERIC(10,0))) > 50 + THEN + CASE + WHEN (SELECT CAST(5.25 AS DECIMAL(5,2))) < 10 + THEN (SELECT AVG(value) FROM (VALUES (1.1111), (2.2222), (3.3333)) AS t(value)) + ELSE (SELECT AVG(value) FROM (VALUES (4.444444), (5.555555), (6.666666)) AS t(value)) + END + ELSE (SELECT CAST(1000.00 AS NUMERIC(12,2))) +END AS result; +GO + +-- Test Case 6: T_SubPlan with arithmetic operations +SELECT CASE + WHEN 1 = 1 + THEN (SELECT CAST(1000.00 AS NUMERIC(10,2)) / 2) + ELSE (SELECT CAST(500.5555 AS DECIMAL(8,4)) * 3) +END AS result; +GO + +-- Test Case 8: T_SubPlan with multiple values +SELECT CASE + WHEN (SELECT value FROM (VALUES (1.23), (4.56), (7.89)) AS t(value) WHERE value = 4.56) = 4.56 + THEN (SELECT CAST(123.456 AS NUMERIC(10,3))) + ELSE (SELECT CAST(789.012 AS DECIMAL(10,3))) +END AS result; +GO + +-- Test Case 10: T_SubPlan with conditional aggregation +SELECT CASE + WHEN EXISTS ( + SELECT 1 FROM (VALUES (1), (2), (3)) AS t(value) + WHERE value > 2 + ) + THEN ( + SELECT AVG(CAST(value AS DECIMAL(10,4))) + FROM (VALUES (10.1111), (20.2222), (30.3333)) AS t(value) + WHERE value > 15 + ) + ELSE CAST(0 AS DECIMAL(10,4)) +END AS result; +GO + +-- Test Case 1: Basic GREATEST simulation in CASE +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN CAST(1234.5678 AS NUMERIC(10,4)) > CAST(9876.54 AS DECIMAL(12,2)) + THEN CAST(1234.5678 AS NUMERIC(10,4)) + ELSE CAST(9876.54 AS DECIMAL(12,2)) + END + ELSE CAST(0 AS DECIMAL(12,4)) +END AS result; +GO + +-- Test Case 2: LEAST simulation with different precisions and scales +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN CAST(123.456 AS NUMERIC(6,3)) < CAST(789.12 AS DECIMAL(8,2)) + THEN CAST(123.456 AS NUMERIC(6,3)) + ELSE CAST(789.12 AS DECIMAL(8,2)) + END + ELSE CAST(999.999 AS DECIMAL(6,3)) +END AS result; +GO + +-- Test Case 3: GREATEST with multiple values +SELECT CASE + WHEN 1 = 1 THEN + (SELECT MAX(v) FROM (VALUES + (CAST(1234.56 AS NUMERIC(10,2))), + (CAST(7890.12 AS DECIMAL(12,2))), + (CAST(4567.89 AS NUMERIC(8,2))) + ) AS value(v)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- Test Case 4: LEAST with multiple values and different scales +SELECT CASE + WHEN 1 = 1 THEN + (SELECT MIN(v) FROM (VALUES + (CAST(123.4567 AS NUMERIC(10,4))), + (CAST(789.12 AS DECIMAL(8,2))), + (CAST(456.789 AS NUMERIC(6,3))) + ) AS value(v)) + ELSE CAST(999.9999 AS DECIMAL(10,4)) +END AS result; +GO + +-- Test Case 5: GREATEST with arithmetic operations +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN CAST(1234.56 AS NUMERIC(10,2)) * 2 > CAST(9876.54 AS DECIMAL(12,2)) / 2 + THEN CAST(1234.56 AS NUMERIC(10,2)) * 2 + ELSE CAST(9876.54 AS DECIMAL(12,2)) / 2 + END + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- Test Case 6: LEAST with NULL values +SELECT CASE + WHEN 1 = 1 THEN + (SELECT MIN(v) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(NULL AS DECIMAL(12,2))), + (CAST(789.12 AS NUMERIC(8,2))) + ) AS value(v)) + ELSE CAST(999.99 AS DECIMAL(10,2)) +END AS result; +GO + +-- Test Case 7: GREATEST with all NULL values +SELECT CASE + WHEN 1 = 1 THEN + (SELECT MAX(v) FROM (VALUES + (CAST(NULL AS NUMERIC(10,2))), + (CAST(NULL AS DECIMAL(12,2))), + (CAST(NULL AS NUMERIC(8,2))) + ) AS value(v)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- Test Case 8: LEAST with very small and very large numbers +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN CAST(0.00000001 AS NUMERIC(16,8)) < CAST(99999999.99 AS DECIMAL(10,2)) + THEN CAST(0.00000001 AS NUMERIC(16,8)) + ELSE CAST(99999999.99 AS DECIMAL(10,2)) + END + ELSE CAST(1 AS DECIMAL(16,8)) +END AS result; +GO + +-- Test Case 9: GREATEST with negative numbers +SELECT CASE + WHEN 1 = 1 THEN + (SELECT MAX(v) FROM (VALUES + (CAST(-1234.56 AS NUMERIC(10,2))), + (CAST(-7890.12 AS DECIMAL(12,2))), + (CAST(-4567.89 AS NUMERIC(8,2))) + ) AS value(v)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- Test Case 10: Complex CASE with multiple GREATEST/LEAST simulations +SELECT CASE + WHEN (SELECT MAX(v) FROM (VALUES + (CAST(1234.56 AS NUMERIC(10,2))), + (CAST(7890.12 AS DECIMAL(12,2))) + ) AS value(v)) > 5000 + THEN + (SELECT MIN(v) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(789.12 AS DECIMAL(12,2))) + ) AS value(v)) + ELSE + (SELECT MAX(v) FROM (VALUES + (CAST(4567.89 AS NUMERIC(10,2))), + (CAST(9876.54 AS DECIMAL(12,2))) + ) AS value(v)) +END AS result; +GO + +-- T_CoerceToDomainValue: +-- Setup +CREATE TYPE NumericDomain FROM NUMERIC(10,4); +CREATE TYPE DecimalDomain FROM DECIMAL(12,2); +GO + +-- Test Case 1 +SELECT CASE WHEN 1=1 THEN CAST(123.4567 AS NumericDomain) ELSE CAST(9876.54 AS DecimalDomain) END AS result; +GO + +-- Test Case 2 +SELECT CASE WHEN 1=0 THEN CAST(123.4567 AS NumericDomain) ELSE CAST(9876.54 AS DecimalDomain) END AS result; +GO + +-- Test Case 3 +DECLARE @n NumericDomain = 123.4567; +DECLARE @d DecimalDomain = 9876.54; +SELECT CASE WHEN @n > 100 THEN @n ELSE @d END AS result; +GO + +-- Test Case 4 +SELECT CASE + WHEN CAST(123.4567 AS NumericDomain) > CAST(100 AS NumericDomain) THEN CAST(123.4567 AS NumericDomain) + ELSE CAST(9876.54 AS DecimalDomain) +END AS result; +GO + +-- Test Case 5 +SELECT CASE + WHEN 1=1 THEN CAST(CAST(123.4567 AS NUMERIC(10,4)) AS NumericDomain) + ELSE CAST(CAST(9876.54 AS DECIMAL(12,2)) AS DecimalDomain) +END AS result; +GO + +DROP TYPE NumericDomain +GO + +DROP TYPE DecimalDomain +GO + +-- T_SQLValueFunction: +-- Test Case 1 +SELECT CASE + WHEN SERVERPROPERTY('Edition') = 'Express Edition' THEN CAST(1 AS NUMERIC(1,0)) + ELSE CAST(0 AS DECIMAL(1,0)) +END AS result; +GO + + +-- T_MinMaxExpr: +-- Test Case 1 +SELECT CASE + WHEN 1=1 THEN + (SELECT MAX(v) FR FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))) + ) AS value(v)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- Test Case 2 +SELECT CASE + WHEN 1=1 THEN + (SELECT MIN(v) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))), + (CAST(456.78 AS NUMERIC(8,2))) + ) AS value(v)) + ELSE CAST(999.99 AS DECIMAL(10,2)) +END AS result; +GO + +-- Test Case 3 +DECLARE @num1 NUMERIC(10,4) = 123.4567; +DECLARE @num2 DECIMAL(12,2) = 9876.54; +SELECT CASE + WHEN @num1 > @num2 THEN @num1 + ELSE @num2 +END AS result; +GO + +-- Test Case 4 +SELECT CASE + WHEN 1=1 THEN + (SELECT MAX(v) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2)) * 2), + (CAST(678.90 AS DECIMAL(12,2)) / 2) + ) AS value(v)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- Test Case 5 +SELECT CASE + WHEN (SELECT MAX(v) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))) + ) AS value(v)) > 500 + THEN CAST(1 AS NUMERIC(1,0)) + ELSE CAST(0 AS DECIMAL(1,0)) +END AS result; +GO + +-- T_ArrayExpr: +-- Test Case 1 +SELECT CASE + WHEN 1=1 THEN + (SELECT v FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))) + ) AS value(v) WHERE v > 500) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- Test Case 2 +SELECT CASE + WHEN EXISTS(SELECT 1 FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))) + ) AS value(v) WHERE v > 500) + THEN CAST(1 AS NUMERIC(1,0)) + ELSE CAST(0 AS DECIMAL(1,0)) +END AS result; +GO + +-- Test Case 3 +DECLARE @values TABLE (v NUMERIC(10,2)); +INSERT INTO @values VALUES (123.45), (678.90), (456.78); +SELECT CASE + WHEN EXISTS(SELECT 1 FROM @values WHERE v > 500) + THEN (SELECT MAX(v) FROM @values) + ELSE (SELECT MIN(v) FROM @values) +END AS result; +GO + +-- Test Case 4 +SELECT CASE + WHEN 1=1 THEN + (SELECT AVG(v) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))), + (CAST(456.78 AS NUMERIC(10,2))) + ) AS value(v)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- Test Case 5 +SELECT CASE + WHEN (SELECT COUNT(*) FROM (VALUES + (CAST(123.45 AS NUMERIC(10,2))), + (CAST(678.90 AS DECIMAL(12,2))), + (CAST(456.78 AS NUMERIC(10,2))) + ) AS value(v) WHERE v > 500) > 1 + THEN CAST(1 AS NUMERIC(1,0)) + ELSE CAST(0 AS DECIMAL(1,0)) +END AS result; +GO + +-- T_CaseTestExpr +-- Test Case 1 +SELECT CASE CAST(2 AS NUMERIC(1,0)) + WHEN 1 THEN CAST(100.00 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(200.00 AS DECIMAL(12,2)) + ELSE CAST(0 AS NUMERIC(10,2)) +END AS result; +GO + +-- Test Case 2 +DECLARE @test DECIMAL(2,0) = 3; +SELECT CASE @test + WHEN 1 THEN CAST(100.00 AS NUMERIC(10,2)) + WHEN 2 THEN CAST(200.00 AS DECIMAL(12,2)) + WHEN 3 THEN CAST(300.00 AS NUMERIC(10,2)) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- Test Case 3 +DECLARE @value NUMERIC(3,1) = 10.5; +SELECT CASE CAST(@value AS NUMERIC(3,0)) + WHEN 9 THEN CAST(90.00 AS NUMERIC(10,2)) + WHEN 10 THEN CAST(100.00 AS DECIMAL(10,2)) + ELSE CAST(0 AS NUMERIC(10,2)) +END AS result; +GO + +-- T_ArrayCoerceExpr: +-- Test Case 1 +DECLARE @values TABLE (val NUMERIC(10,2)); +INSERT INTO @values VALUES (123.45), (678.90), (456.78); +SELECT CASE + WHEN 1 = 1 THEN CAST(val AS DECIMAL(12,2)) + ELSE val +END AS result +FROM @values; +GO + +-- Test Case 2 +DECLARE @values TABLE (val DECIMAL(12,2)); +INSERT INTO @values VALUES (123.45), (678.90), (456.78); +SELECT CASE + WHEN 1 = 1 THEN CAST(val AS NUMERIC(10,2)) + ELSE val +END AS result +FROM @values; +GO + +-- Test Case 3 +DECLARE @values TABLE (val NUMERIC(10,2)); +INSERT INTO @values VALUES (123.45), (678.90), (456.78); +SELECT CASE + WHEN val > 500 THEN CAST(val AS DECIMAL(12,2)) + ELSE val +END AS result +FROM @values; +GO + +-- Test Case 4 +DECLARE @values TABLE (val DECIMAL(12,2)); +INSERT INTO @values VALUES (123.45), (678.90), (456.78); +SELECT CASE + WHEN val < 500 THEN CAST(val AS NUMERIC(10,2)) + ELSE val +END AS result +FROM @values; +GO + +-- T_FieldSelect: +-- Setup +CREATE TABLE MyTable ( + id INT PRIMARY KEY, + num_col NUMERIC(10,2), + dec_col DECIMAL(12,2) +); +GO + +INSERT INTO MyTable (id, num_col, dec_col) VALUES +(1, 1234.56, 9876.54), +(2, 2345.67, 8765.43), +(3, 3456.78, 7654.32); +GO + +-- Test Case 1 +SELECT CASE + WHEN t.num_col > 2000 THEN t.num_col + ELSE t.dec_col +END AS result +FROM MyTable t; +GO + +-- Test Case 2 +SELECT CASE + WHEN t.dec_col < 8000 THEN t.num_col + ELSE t.dec_col +END AS result +FROM MyTable t +WHERE t.id = 2; +GO + +-- Test Case 3 +DECLARE @id INT = 3; +SELECT CASE + WHEN (SELECT num_col FROM MyTable WHERE id = @id) > 3000 THEN (SELECT num_col FROM MyTable WHERE id = @id) + ELSE (SELECT dec_col FROM MyTable WHERE id = @id) +END AS result; +GO + +-- Test Case 4 +SELECT CASE + WHEN (SELECT AVG(num_col) FROM MyTable) > 2500 THEN (SELECT MAX(num_col) FROM MyTable) + ELSE (SELECT MIN(dec_col) FROM MyTable) +END AS result; +GO + +-- Test Case 5 +SELECT CASE + WHEN (SELECT COUNT(*) FROM MyTable WHERE num_col > 3000) > 1 THEN (SELECT SUM(num_col) FROM MyTable) + ELSE (SELECT AVG(dec_col) FROM MyTable) +END AS result; +GO + +-- T_AlternativeSubPlan: +-- This is typically an internal optimization structure, but we can simulate with a UNION ALL. + +-- Test Case 1 +SELECT CASE + WHEN 1 = 1 THEN + (SELECT CAST(123.45 AS NUMERIC(10,2)) WHERE 1 = 1 + UNION ALL + SELECT CAST(678.90 AS DECIMAL(12,2)) WHERE 1 = 0) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- Test Case 2 +DECLARE @flag BIT = 1; +SELECT CASE + WHEN @flag = 1 THEN + (SELECT CAST(123.45 AS NUMERIC(10,2)) WHERE @flag = 1 + UNION ALL + SELECT CAST(678.90 AS DECIMAL(12,2)) WHERE @flag = 0) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- Test Case 3 +SELECT CASE + WHEN (SELECT COUNT(*) FROM ( + SELECT CAST(123.45 AS NUMERIC(10,2)) WHERE 1 = 1 + UNION ALL + SELECT CAST(678.90 AS DECIMAL(12,2)) WHERE 1 = 0 + ) t) > 0 THEN CAST(1 AS NUMERIC(1,0)) + ELSE CAST(0 AS DECIMAL(1,0)) +END AS result; +GO + +-- Test Case 4 +DECLARE @condition BIT = 1; +SELECT CASE + WHEN @condition = 1 THEN + (SELECT CAST(123.45 AS NUMERIC(10,2)) WHERE @condition = 1 + UNION ALL + SELECT CAST(678.90 AS DECIMAL(12,2)) WHERE @condition = 0) + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +-- T_SubPlan: +-- Test Case 1 +SELECT CASE + WHEN 1 = 1 THEN (SELECT TOP 1 CAST(123.45 AS NUMERIC(10,2)) FROM MyTable) + ELSE (SELECT TOP 1 CAST(678.90 AS DECIMAL(12,2)) FROM MyTable) +END AS result; +GO + +-- Test Case 2 +SELECT CASE + WHEN (SELECT COUNT(*) FROM MyTable WHERE num_col > 2000) > 0 + THEN (SELECT AVG(CAST(num_col AS NUMERIC(10,2))) FROM MyTable) + ELSE (SELECT AVG(CAST(dec_col AS DECIMAL(12,2))) FROM MyTable) +END AS result; +GO + +-- Test Case 3 +SELECT CASE + WHEN (SELECT MAX(num_col) FROM MyTable) > (SELECT MIN(dec_col) FROM MyTable) + THEN (SELECT SUM(CAST(num_col AS NUMERIC(15,2))) FROM MyTable) + ELSE (SELECT SUM(CAST(dec_col AS DECIMAL(15,2))) FROM MyTable) +END AS result; +GO + +-- Test Case 4 +SELECT CASE + WHEN EXISTS (SELECT 1 FROM MyTable WHERE num_col > 3000) + THEN (SELECT CAST(num_col AS NUMERIC(10,2)) FROM MyTable WHERE id = 1) + ELSE (SELECT CAST(dec_col AS DECIMAL(12,2)) FROM MyTable WHERE id = 2) +END AS result; +GO + +-- Test Case 5 +SELECT CASE + WHEN (SELECT COUNT(*) FROM MyTable WHERE num_col > (SELECT AVG(num_col) FROM MyTable)) > 1 + THEN (SELECT CAST(SUM(num_col) AS NUMERIC(18,2)) FROM MyTable) + ELSE (SELECT CAST(SUM(dec_col) AS DECIMAL(18,2)) FROM MyTable) +END AS result; +GO + +DROP TABLE MyTable +GO + +-- T_SubscriptingRef: +-- Test Case 1 +DECLARE @json NVARCHAR(MAX) = N'{"num": 123.45, "dec": 678.90}'; +SELECT CASE + WHEN CAST(JSON_VALUE(@json, '$.num') AS NUMERIC(10,2)) > 100 + THEN CAST(JSON_VALUE(@json, '$.num') AS NUMERIC(10,2)) + ELSE CAST(JSON_VALUE(@json, '$.dec') AS DECIMAL(12,2)) +END AS result; +GO + +-- Test Case 2 +DECLARE @data TABLE (id INT, num_col NUMERIC(10,2), dec_col DECIMAL(12,2)); +INSERT INTO @data VALUES (1, 123.45, 678.90), (2, 234.56, 567.89); +SELECT CASE + WHEN @data.num_col > 200 THEN @data.num_col + ELSE @data.dec_col +END AS result +FROM @data +WHERE id = 2; +GO + +-- Test Case 3 +DECLARE @json NVARCHAR(MAX) = N'{"values": [123.45, 678.90, 456.78]}'; +SELECT CASE + WHEN CAST(JSON_VALUE(@json, '$.values[0]') AS NUMERIC(10,2)) > 500 + THEN CAST(JSON_VALUE(@json, '$.values[1]') AS DECIMAL(12,2)) + ELSE CAST(JSON_VALUE(@json, '$.values[2]') AS NUMERIC(10,2)) +END AS result; +GO + +-- Test Case 4 +DECLARE @data TABLE (id INT, num_col NUMERIC(10,2), dec_col DECIMAL(12,2)); +INSERT INTO @data VALUES (1, 123.45, 678.90), (2, 234.56, 567.89); +SELECT CASE + WHEN (SELECT num_col FROM @data WHERE id = 2) > 200 + THEN (SELECT num_col FROM @data WHERE id = 2) + ELSE (SELECT dec_col FROM @data WHERE id = 2) +END AS result; +GO + +-- Test Case 5 +DECLARE @json NVARCHAR(MAX) = N'{"nums": [123.45, 234.56, 345.67], "decs": [678.90, 567.89, 456.78]}'; +SELECT CASE + WHEN CAST(JSON_VALUE(@json, '$.nums[0]') AS NUMERIC(10,2)) > 200 + THEN CAST(JSON_VALUE(@json, '$.decs[1]') AS DECIMAL(12,2)) + ELSE CAST(JSON_VALUE(@json, '$.nums[2]') AS NUMERIC(10,2)) +END AS result; +GO + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. +-- Money datatypes testing +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN 1=1 + THEN CAST(1234.56 AS NUMERIC(10,2)) * cast(5.5 as smallmoney) + ELSE CAST(9876.54 AS DECIMAL(12,2)) / cast(6.43 as smallmoney) + END + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN 1=1 + THEN CAST(1234.56 AS NUMERIC(10,2)) * cast(5.5 as money) + ELSE CAST(9876.54 AS DECIMAL(12,2)) / cast(6.43 as smallmoney) + END + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN 1=1 + THEN CAST(1234.56 AS NUMERIC(10,2)) * cast(5.5 as money) + ELSE CAST(9876.54 AS DECIMAL(12,2)) / cast(6.43 as money) + END + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + +SELECT CASE + WHEN 1 = 1 THEN + CASE + WHEN 1=1 + THEN CAST(1234.56 AS NUMERIC(10,2)) * cast(5.5 as smallmoney) + ELSE CAST(9876.54 AS DECIMAL(12,2)) / cast(6.43 as money) + END + ELSE CAST(0 AS DECIMAL(12,2)) +END AS result; +GO + + +-- TODO FIX: Output diff between TSQL and BBF. +-- T_Param (Function parameter) +DROP FUNCTION IF EXISTS dbo.TestParam +GO + +CREATE FUNCTION dbo.TestParam (@param1 NUMERIC(10,4), @param2 DECIMAL(12,2)) +RETURNS TABLE +AS +RETURN +( + SELECT CASE + WHEN 1 = 1 THEN @param1 + ELSE @param2 + END AS result +); +GO + +SELECT * FROM dbo.TestParam(1234.5678, 9876.54); +GO + +DROP FUNCTION dbo.TestParam +GO + +-- T_Param (Function parameter) +DROP FUNCTION IF EXISTS dbo.TestParam +GO + +CREATE FUNCTION dbo.TestParam (@param1 NUMERIC(10,4), @param2 DECIMAL(12,2)) +RETURNS TABLE +AS +RETURN +( + SELECT @param1 AS result + UNION ALL + SELECT @param2 + ORDER BY result +); +GO + +SELECT * FROM dbo.TestParam(1234.5678, 9876.54); +GO + +DROP FUNCTION dbo.TestParam +GO + +-- T_NamedArgExpr (Named argument in a function call) +DROP FUNCTION IF EXISTS dbo.TestNamedArg +GO + +CREATE FUNCTION dbo.TestNamedArg (@param1 NUMERIC(10,4) = 0, @param2 DECIMAL(12,2) = 0) +RETURNS TABLE +AS +RETURN +( + SELECT @param1 AS result + UNION ALL + SELECT @param2 + ORDER BY result +); +GO + +SELECT * FROM dbo.TestNamedArg(1234.56, 7890.1234); +GO + +DROP FUNCTION dbo.TestNamedArg; +GO + +-- Setup +DROP FUNCTION IF EXISTS dbo.TestFunction; +GO + +CREATE FUNCTION dbo.TestFunction (@num NUMERIC(10,2), @dec DECIMAL(12,2)) +RETURNS TABLE +AS +RETURN +( + SELECT CASE + WHEN @num > @dec THEN @num + ELSE @dec + END AS result +); +GO + +-- T_NamedArgExpr: +-- Test Case 1 +SELECT * FROM dbo.TestFunction(123.45, 678.90); +GO + +-- Test Case 2 +SELECT * FROM dbo.TestFunction(678.90, 123.45); +GO + +-- Test Case 3 +DECLARE @n NUMERIC(10,2) = 123.45; +DECLARE @d DECIMAL(12,2) = 678.90; +SELECT * FROM dbo.TestFunction(@n, @d); +GO + +-- Test Case 4 +SELECT * FROM dbo.TestFunction(678.90, CAST(123.45 AS NUMERIC(10,2))); +GO + +-- Test Case 5 +SELECT * FROM dbo.TestFunction(CAST(123.45 AS NUMERIC(10,2)), CAST(678.90 AS DECIMAL(12,2))); +GO + +DROP FUNCTION dbo.TestFunction; +go + + + +-- TODO FIX: SQRT function returns float in TSQL. while +-- selecting commontype between flaot ansd numeric, +-- is selected. where as in BBF SQRT function returns numeric. +-- Test Case: T_SubPlan with different numeric operations +SELECT CASE + WHEN (SELECT POWER(CAST(2 AS NUMERIC(5,2)), 3)) > 7 + THEN (SELECT SQRT(CAST(100 AS NUMERIC(10,4)))) + ELSE (SELECT CAST(PI() AS DECIMAL(10,8))) +END AS result; +GO \ No newline at end of file diff --git a/test/JDBC/jdbc_schedule b/test/JDBC/jdbc_schedule index 2c45e94728..1b81b17e90 100644 --- a/test/JDBC/jdbc_schedule +++ b/test/JDBC/jdbc_schedule @@ -74,6 +74,9 @@ ignore#!#objectpropertyex-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 48c85322a5..3b3f6a2964 100644 --- a/test/JDBC/upgrade/15_10/schedule +++ b/test/JDBC/upgrade/15_10/schedule @@ -567,7 +567,7 @@ cast-varchar-to-time SELECT_INTO_TEST BABEL-5119 BABEL-5129 -BABEL-CASE_EXPR +BABEL-CASE_EXPR-before-16_6 charindex_replace_patindex BABEL-5186 BABEL-2736 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