是否可以通过将参数保留在 where 子句中来获取值,如下所示:
DECLARE @COLUMNNAME VARCHAR(50)
-- setting required column name
SET @COLUMNNAME = (select name from sys.columns where OBJECT_ID =
(SELECT OBJECT_ID FROM SYS.objects WHERE name = 'BORVALIDATION') AND column_id = 2)
--PRINT @COLUMNNAME (we do get the column name)
SELECT * FROM BORVALIDATION WHERE @COLUMNNAME = 'BBNAME'
非常感谢您的知识和帮助。