April 26, 2012 at 12:03 pm
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?
April 26, 2012 at 12:13 pm
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 *******
April 26, 2012 at 12:33 pm
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
April 26, 2012 at 12:36 pm
where i need to put this statement,in sp or in the report,if in the report where?
April 26, 2012 at 12:39 pm
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
April 26, 2012 at 12:45 pm
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
April 26, 2012 at 12:51 pm
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
April 26, 2012 at 12:56 pm
NO -> if consolidate =1 then @Portfolio = +@Portfolio
YES -> IF @consolidate = 1 THEN SET @Portfolios = '+' + @Portfolios
April 26, 2012 at 12:56 pm
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
April 26, 2012 at 12:58 pm
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.
April 26, 2012 at 1:00 pm
that was not code,i was just explaining you.
anyways so it will take + in portfolio after that
April 26, 2012 at 1:03 pm
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/
April 26, 2012 at 9:29 pm
post withdrawn
--Jeff Moden
Change is inevitable... Change for the better is not.
April 27, 2012 at 7:20 am
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