|
|
|
Как заменить iif от Access в MsSQLServer
|
|||
|---|---|---|---|
|
#18+
Как заменить iif от Access в MsSQLServer Если в Access было : SELECT "Клиенты".Id FROM "Клиенты" WHERE iif("Клиенты".Id=1,1,0)="Клиенты"."Инн" То в MsSQLServer2000: SELECT "Клиенты".Id FROM "Клиенты" WHERE CASE WHEN [Клиенты].Id=1 THEN [Клиенты].[Инн]=1 ELSE [Клиенты].[Инн]=0 END не проходит Как правильно ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.11.2004, 15:30:59 |
|
||
|
Как заменить iif от Access в MsSQLServer
|
|||
|---|---|---|---|
|
#18+
Код: plaintext 1. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.11.2004, 15:33:34 |
|
||
|
Как заменить iif от Access в MsSQLServer
|
|||
|---|---|---|---|
|
#18+
ошибки тут: SELECT "Клиенты".Id FROM "Клиенты" WHERE CASE WHEN [Клиенты].Id=1 THEN [Клиенты].[Инн]=1 ELSE [Клиенты].[Инн]=0 END наверное, нужно SELECT "Клиенты".Id FROM "Клиенты" WHERE "Клиенты"."Инн"=CASE WHEN [Клиенты].Id=1 THEN 1 ELSE 0 END ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.11.2004, 15:34:12 |
|
||
|
Как заменить iif от Access в MsSQLServer
|
|||
|---|---|---|---|
|
#18+
Код: plaintext 1. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.11.2004, 15:35:31 |
|
||
|
Как заменить iif от Access в MsSQLServer
|
|||
|---|---|---|---|
|
#18+
А почему не проходит : SELECT "Клиенты".Id FROM "Клиенты" WHERE CASE WHEN [Клиенты].Id=1 THEN 1=0 ELSE 0=0 END ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.11.2004, 15:40:01 |
|
||
|
Как заменить iif от Access в MsSQLServer
|
|||
|---|---|---|---|
|
#18+
потому что синтаксис неправильный! ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.11.2004, 15:43:48 |
|
||
|
Как заменить iif от Access в MsSQLServer
|
|||
|---|---|---|---|
|
#18+
Ну спасибо, а Ваш SELECT "Клиенты".Id FROM "Клиенты" WHERE CASE WHEN [Клиенты].Id=1 THEN 1 ELSE 0 END почему не проходит ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.11.2004, 15:58:57 |
|
||
|
Как заменить iif от Access в MsSQLServer
|
|||
|---|---|---|---|
|
#18+
Вообще , как я понял в MsSQL boolean нет , и как удобнее тогда работать с логическими выражениями ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.11.2004, 15:59:55 |
|
||
|
Как заменить iif от Access в MsSQLServer
|
|||
|---|---|---|---|
|
#18+
yunikiНу спасибо, а Ваш SELECT "Клиенты".Id FROM "Клиенты" WHERE CASE WHEN [Клиенты].Id=1 THEN 1 ELSE 0 END почему не проходит ? потому что тоже ошибка синтаксиса правильно так Код: plaintext 1. CASE WHEN [Клиенты].Id=1 THEN 1 ELSE 0 END - это выражение нельзя писать where выражение надо писать where выражение = выражение ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.11.2004, 16:37:51 |
|
||
|
Как заменить iif от Access в MsSQLServer
|
|||
|---|---|---|---|
|
#18+
yunikiВообще , как я понял в MsSQL boolean нет , и как удобнее тогда работать с логическими выражениями ? Скорее, не так. В MSSQL boolean есть, но нет, как в jet-SQL неявного преобразования, например, числа, в boolean. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.11.2004, 16:43:01 |
|
||
|
Как заменить iif от Access в MsSQLServer
|
|||
|---|---|---|---|
|
#18+
Да вот пока непонятно - есть или нет : С одной стороны типа данных такого нет С другой стороны выражение может быть booolean типа Expression Results For a simple expression built of a single constant, variable, scalar function, or column name, the data type, collation, precision, scale, and value of the expression is the data type, collation, precision, scale, and value of the referenced element. When two expressions are combined using comparison or logical operators, the resulting data type is Boolean and the value is one of three values: TRUE, FALSE, or UNKNOWN. For more information about Boolean data types, see Operators. When two expressions are combined using arithmetic, bitwise, or string operators, the operator determines the resulting data type. Complex expressions made up of many symbols and operators evaluate to a single-valued result. The data type, collation, precision, and value of the resulting expression is determined by combining the component expressions, two at a time, until a final result is reached. The sequence in which the expressions are combined is defined by the precedence of the operators in the expression. С третьей стороны CASE, являясь функцией, возвращает результат : Syntax Simple CASE function: CASE input_expression WHEN when_expression THEN result_expression [ ...n ] [ ELSE else_result_expression ] END Searched CASE function: CASE WHEN Boolean_expression THEN result_expression [ ...n ] [ ELSE else_result_expression ] END Result Types Returns the highest precedence type from the set of types in result_expressions and the optional else_result_expression. For more information, see Data Type Precedence. Result Values Simple CASE function: Evaluates input_expression, and then, in the order specified, evaluates input_expression = when_expression for each WHEN clause. Returns the result_expression of the first (input_expression = when_expression) that evaluates to TRUE. If no input_expression = when_expression evaluates to TRUE, SQL Server returns the else_result_expression if an ELSE clause is specified, or a NULL value if no ELSE clause is specified. Searched CASE function: Evaluates, in the order specified, Boolean_expression for each WHEN clause. Returns result_expression of the first Boolean_expression that evaluates to TRUE. If no Boolean_expression evaluates to TRUE, SQL Server returns the else_result_expression if an ELSE clause is specified, or a NULL value if no ELSE clause is specified. Ну и почему нельзя оцененное CASE как boolean выражение использовать в Where условии ???????? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.11.2004, 18:44:37 |
|
||
|
Как заменить iif от Access в MsSQLServer
|
|||
|---|---|---|---|
|
#18+
Можно попробовать так Код: plaintext 1. 2. 3. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 19.11.2004, 18:53:09 |
|
||
|
|

start [/forum/topic.php?fid=45&msg=32791728&tid=1670234]: |
0ms |
get settings: |
7ms |
get forum list: |
17ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
42ms |
get topic data: |
11ms |
get forum data: |
3ms |
get page messages: |
57ms |
get tp. blocked users: |
1ms |
| others: | 212ms |
| total: | 356ms |

| 0 / 0 |
