更新时间:2023-02-07 11:03:28
创建sql查询作为字符串,然后通过exe语句执行exexute你也可以在那里执行
create sql query as string then exexute by exe statement in sql you can do rnd on that as well
我从来没有尝试过相同但可以做到的。从我的观点来看下面的评论
1.使用If Else,因为你将从前端传递参数。
2.您也可以通过使用动态SQL来检查它。
查看此更新版....
Hi,
I have never tried the same but it can be done. From my point of view check below comments
1. Using "If Else" as you will pass parameter from front end.
2. You can also check the same by making use of dynamic SQLs.
Check this updated one....
--PR_DYNAMIC_OPERATORS '>'
ALTER PROC PR_DYNAMIC_OPERATORS
(
@PA_OPERATOR VARCHAR(100)
)
AS
BEGIN
--First Option
/*
IF @PA_OPERATOR = '='
BEGIN
SELECT 1 WHERE 1 = 1
END
IF @PA_OPERATOR = '>'
BEGIN
SELECT 1 WHERE 2 > 1
END
--.
--.
--.
--.
--.
--and So On
*/
--Second Option
DECLARE @SQL VARCHAR(200)
SET @SQL = 'SELECT 1 WHERE 2 ' + @PA_OPERATOR + ' 1'
PRINT(@SQL)
EXEC (@SQL)
END
希望这会对你有所帮助。
干杯
Hope this will help you.
Cheers