[Cialug] SQL question

Jerry Heiselman jweida at gmail.com
Wed Mar 15 13:52:46 CST 2006


I'm not very familiar with MSSQL but I know in Oracle or PostgreSQL you
could use some PL/SQL to handle this.  It would resemble something like
this:

DECALRE SalesID NUMBER;

BEGIN
    SELECT ID INTO SalesID FROM <table_name> WHERE <condition>;
    IF SalesID = NULL THEN
        UPDATE <table_name> SET Close=Now() WHERE ID=SalesID;
    END IF;
END;

I'm sure that MSSQL probably supports PL/SQL as well, but the verbage may be
different.  Hope this helps.

Jerry


On 3/15/06, David Stout <ragbrai65 at yahoo.com> wrote:
>
>  I am using SQL server and I have a column named
> SalesStatus and one Named Close in my in the SalesStatus field I have
> values like
> BTO, Model, ssip, and Spec  In the field named Close this is just a
> closing date.
> What I need to do is this:
>
> If SalesStatus='Spec' Then put the value of the closed field in here.
> else '<blank>'
>
> How do I write such a query?
>
> Thank you,
>  David Stout
> Ragbari65 at yahoo.com
>
> ------------------------------
> Brings words and photos together (easily) with
> PhotoMail
> <http://us.rd.yahoo.com/mail_us/taglines/PMall/*http://photomail.mail.yahoo.com>-
> it's free and works with Yahoo! Mail.
>
>
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cialug.org/pipermail/cialug/attachments/20060315/5573516a/attachment.html


More information about the Cialug mailing list