sql 預存函數
DECLARE @Account AS VARCHAR(10)
DECLARE @Password AS VARCHAR(10)
DECLARE @Catagory AS VARCHAR(10)
SET @Account = 'admin'
SET @Password = 'admin'
/**將傳入結果指派給@Catagory變數**/
SET @Catagory = (
SELECT CASE Catagory
WHEN 'admin' THEN 'admin'
ELSE 'company'
END
FROM UserRole WHERE Account=@Account AND [Password]=@Password
)
/**if else**/
IF(@Catagory) like '%company%'
BEGIN
SELECT * FROM UserRole WHERE [Year] = 101 AND Account=@Account AND [Password]=@Password
END
ELSE
BEGIN
SELECT * FROM UserRole WHERE Account=@Account AND [Password]=@Password
END
/**輸出@Catagory變數字串**/
PRINT @Catagory
標籤: SQL
0 個意見:
張貼留言
訂閱 張貼留言 [Atom]
<< 首頁