存储过程If / Then语句

时间:2016-12-06 16:14:31

标签: sql-server stored-procedures

我们正在尝试实施密码间隔(如果有)。

如果sm_Setting(PasswordExpireDays)有值,我们就会使用它。如果没有,请继续

WHERE

我遇到了CASE条款的问题。我试过了Value。底线是,这一行(基于PK和设置),我想从<?php foreach($subs_email as $email){ $mail->addAddress($email); $mail->Body = '<p>This is the body text</p><a href="http://www.website.com/unsubscribe.php?email='.$email.'">Unsubscribe</a>'; $mail->send(); $mail->clearAddresses(); } 列中获取值。

1 个答案:

答案 0 :(得分:3)

CREATE Procedure user_password_date_interval_check
    @ua_pk uniqueidentifier
AS
    DECLARE @PasswordExpireDays int

    SELECT
      --sm_Setting, 
      @PasswordExpireDays =COALESCE(sm_Value,0)

    FROM
      Setting_Misc AS sm
    INNER JOIN
      Syndicates As syn 
      ON sm.syn_fk = syn.syn_pk
    INNER JOIN
      Company As c
      ON c.syn_fk = syn.syn_pk
    INNER JOIN
      User_Accounts As ua
      ON ua.c_fk = c.c_pk

    WHERE sm.sm_Setting = 'PasswordExpireDays'


    --@PasswordExpireDays is either default 0 or the value from the table if not null.