如何将小于、大于、等于、=转换为SQL Server
如何将小于、大于、等于<、>、=转换为SQL Server 表1 资料如何将小于、大于、等于、=转换为SQL Server,sql,sql-server,Sql,Sql Server,如何将小于、大于、等于、=转换为SQL Server 表1 资料 为什么@Condition无效?您可以使用一个大的布尔表达式: if ( (@condition = 'greater than' and 1 > 2) or (@condition = 'less than' and 1 < 2) or . . . ) 您也可以使用动态SQL执行此操作,但仍然需要一个大小写表达式将单词转换为符号,这样只会增加复杂性。请您解释一下您要执行的操作好吗?特别是如
为什么@Condition无效?您可以使用一个大的布尔表达式:
if ( (@condition = 'greater than' and 1 > 2) or
(@condition = 'less than' and 1 < 2) or
. . .
)
您也可以使用动态SQL执行此操作,但仍然需要一个大小写表达式将单词转换为符号,这样只会增加复杂性。请您解释一下您要执行的操作好吗?特别是如果1@Condition 2意味着什么?这感觉像是一个。同样的原因是声明@table sysname=N'foo';从@table中选择*;无效。SQL Server不能从变量中计算编程元素和实体——它不像OO语言那样在两个过程中进行计算。
Declare @Condition nvarchar(10)
SET @Condition =
(SELECT CASE WHEN Condition = 'less than' THEN '<'
WHEN Condition = 'greater than' THEN '>'
ELSE '=' END AS Condition FROM Temp1 where Condition = 'less than')
IF (1 @Condition 2 )
BEGIN
SELECT * FROM Temp1
END
if ( (@condition = 'greater than' and 1 > 2) or
(@condition = 'less than' and 1 < 2) or
. . .
)