IF RTRIM(@GLDD_LEDGER_CODE)= '00'
BEGIN
SELECT @SYS_REM =GLMA_ACCT_NAME
FROM GLAS_GL_MASTERS
WHERE GLMA_COMP_CODE = @COMP_CODE
AND GLMA_LDGR_CODE = '00'
AND GLMA_DEPT_NO = SUBSTRING(@GLDD_ACCT_CODE, 2, 2)
AND GLMA_ACCT_CODE = SUBSTRING(@GLDD_ACCT_CODE, 4, 4)
AND GLMA_YEAR = DATEPART(YYYY, GETDATE())
END
ELSE
BEGIN
SELECT @SYS_REM = A.COAD_PTY_FULL_NAME AS NAME
FROM GLAS_PTY_ADDRESS A,
GLAS_SBLGR_MASTERS B
WHERE A.COAD_COMP_CODE = @COMP_CODE
AND A.COAD_COMP_CODE = B.SLMA_COMP_CODE
AND A.COAD_ADDR_ID = B.SLMA_ADDR_ID
AND B.SLMA_LDGRCTL_CODE = @GLDD_LEDGER_CODE
AND B.SLMA_LDGRCTL_YEAR = DATEPART(YYYY, GETDATE())
AND B.SLMA_STATUS = 'A'
AND B.SLMA_ACNO = @GLDD_ACCT_CODE
END
如何为两个select语句设置别名以选择名称?
答案 0 :(得分:0)
如何为两者设置别名 select语句用于选择 命名
你不能,因为你将它存储在一个变量中。
使用OUTPUT参数(如果此代码在存储过程中)或
SELECT @SYS_REM AS MyName
将其作为结果集返回