boolean value

  • hi,

    i have 1 Boolean parameter ,if i select true the other parameter value should include + infront fo fit.if i select no ,it should be same

    how to do that?

  • can you add in what you have so far please so much easier to help you when we know what your looking at 🙂

    ***The first step is always the hardest *******

  • CASE @BooleanParameter WHEN 1 THEN '+' + @OtherParameterValue ELSE @OtherParameterValue END

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • where i need to put this statement,in sp or in the report,if in the report where?

  • Whereever you need that parameter to have it's value as set as requested. In the query though, not the report.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • do i need to put any variable,how can i put just this statement

    suppose i declare @boolean bit,

    now case

    it wont wokr

  • If you bother to show me what the query is, I might be able to answer that.

    But no, you wouldn't declare a new variable, you would use that boolean parameter that you said you have, you know, the one that has a value that defines whether the other value gets a + or not.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • ALTER procedure[pPortfolioDashboard]

    ------Required parameter----------------

    @SessionGuid nvarchar(48),

    @FromDate datetime,

    @consolidate bit,

    ---optional parameter-------------------

    @Portfolios nvarchar(max) = null,

    i need to use here?

    if consolidate =1 then @Portfolio = +@Portfolio

    help me

  • NO -> if consolidate =1 then @Portfolio = +@Portfolio

    YES -> IF @consolidate = 1 THEN SET @Portfolios = '+' + @Portfolios

  • Well that bears no resemblance to the code I gave you but still.

    Yes, you can do it there.

    if (consolidate = 1)

    set @Portfolio = '+' + @Portfolio

    You really, really, really need basic T-SQL training, and don't tell me you know T-SQL, because anyone who knows T-SQL would know that IF statements don't have a THEN and that setting a variable requires SET.

    So please, get some basic SQL training and come back when you can write a basic T-SQL statement without 20 syntax errors in it.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (4/26/2012)


    Well that bears no resemblance to the code I gave you but still.

    Yes, you can do it there.

    if (consolidate = 1)

    set @Portfolio = '+' + @Portfolio

    You really, really, really need basic T-SQL training, and don't tell me you know T-SQL, because anyone who knows T-SQL would know that IF statements don't have a THEN and that setting a variable requires SET.

    So please, get some basic SQL training and come back when you can write a basic T-SQL statement without 20 syntax errors in it.

    I'm so sorry, after looking at all his code I forgot we were using T-SQL.

  • that was not code,i was just explaining you.

    anyways so it will take + in portfolio after that

  • post withdrawn

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • post withdrawn

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • post withdrawn

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic. Login to reply