I would like the data value of a text field in a table to based on the
value of another field (also used as a parameter). However, if I try
switch or iif, I get an 'expression expected' error.
For example, if car type is 'used' then output the 'salvage value'
data field. If car type is 'new' output 'retail value' data field.
Any suggestions?You can do this two ways. You can put in an expression or you can have it
done in SQL. iif should have worked. From BOL (search on iif).
=Iif(Fields!PctComplete.Value >= .8, "Green", Iif(Fields!PctComplete.Value
>= .5, "Amber", "Red"))a.. The following expression also returns one of
three values based on the value of PctComplete, but uses the Switch function
instead, which returns the value associated with the first expression in a
series that evaluates to true:
=Switch(Fields!PctComplete.Value >= .8, "Green", Fields!PctComplete.Value >=.5, "Amber", Fields!PctComplete.Value < .5, "Red")In the example it is
setting the color but it could just be a value in the table. If it said it
expected an expression my guess is that you did not have the equal sign.--
Bruce Loehle-Conger MVP SQL Server Reporting Services"ChrisL"
<chrispycrunch@.gmail.com> wrote in message
news:9e416a3e.0504120558.5cbdc793@.posting.google.com...
> I would like the data value of a text field in a table to based on the
> value of another field (also used as a parameter). However, if I try
> switch or iif, I get an 'expression expected' error.
> For example, if car type is 'used' then output the 'salvage value'
> data field. If car type is 'new' output 'retail value' data field.
> Any suggestions?|||Sorry for the crummy formatting. I copied and pasted in from Books On-Line.
This should look better.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Bruce L-C [MVP]" <bruce_lcNOSPAM@.hotmail.com> wrote in message
news:eehnli2PFHA.648@.TK2MSFTNGP14.phx.gbl...
You can do this two ways. You can put in an expression or you can have it
done in SQL. iif should have worked. From BOL (search on iif).
=Iif(Fields!PctComplete.Value >= .8, "Green", Iif(Fields!PctComplete.Value
= .5, "Amber", "Red"))
The following expression also returns one of three values based on the
value of PctComplete, but uses the Switch function instead, which returns
the value associated with the first expression in a series that evaluates to
true:
=Switch(Fields!PctComplete.Value >= .8, "Green", Fields!PctComplete.Value
>=> .5, "Amber", Fields!PctComplete.Value < .5, "Red")
In the example it is setting the color but it could just be a value in the
table. If it said it expected an expression my guess is that you did not
have the equal sign.
Bruce Loehle-Conger MVP SQL Server Reporting Services
>>"ChrisL" <chrispycrunch@.gmail.com> wrote in message
> news:9e416a3e.0504120558.5cbdc793@.posting.google.com...
> > I would like the data value of a text field in a table to based on the
> > value of another field (also used as a parameter). However, if I try
> > switch or iif, I get an 'expression expected' error.
> >
> > For example, if car type is 'used' then output the 'salvage value'
> > data field. If car type is 'new' output 'retail value' data field.
> >
> > Any suggestions?
>
Showing posts with label output. Show all posts
Showing posts with label output. Show all posts
Friday, March 30, 2012
Monday, March 26, 2012
Is it possible to get all the column values in a single column?
Hi
Is it possible to get all the column values in a single column from a
table?
For e.g.
a1 a2 a3
== == ==
1 2 3
4 5 6
I need the output like
Allcolums
***********
123
456
I am not ready to mention the column names in the query. It should be
generic.
Thanks in advance.Hi
You would be better of leaving this for the front end otherwise it would
mean resorting to cursors and dynamic SQL.
John
"KssKumar2000" wrote:
> Hi
> Is it possible to get all the column values in a single column from a
> table?
> For e.g.
> a1 a2 a3
> == == ==
> 1 2 3
> 4 5 6
> I need the output like
> Allcolums
> ***********
> 123
> 456
>
> I am not ready to mention the column names in the query. It should be
> generic.
> Thanks in advance.
>|||will this work
assuming that each column is of string data type
select a1+a2+a3 from table
or this one if you have nulls
select isnull(a1,'')+isnull(a1,'')+isnull(a1,''
)
thanks,
Jose de Jesus Jr. Mcp,Mcdba
MCP #2324787
"KssKumar2000" wrote:
> Hi
> Is it possible to get all the column values in a single column from a
> table?
> For e.g.
> a1 a2 a3
> == == ==
> 1 2 3
> 4 5 6
> I need the output like
> Allcolums
> ***********
> 123
> 456
>
> I am not ready to mention the column names in the query. It should be
> generic.
> Thanks in advance.
>|||You might want to learn about First Normal Form (1NF) and what a tiered
architecture is before you try SQL coding. You have missed the
foundations and are asking for kludges in Newsgroups when you need to
be studying.
If you **really** want to be a bad programmer, look up cursors and
always comment your code with a note that it needs to be replaced by a
good SQL programmer.|||You might want to find out why the poster wants to do this before you slag
him or her off.
Just because with your limited real industrial experience in programming
you've not come across a need for this doesn't make the poster a bad
programmer.
You need a serious lesson in maners - go back to school and learn how to
interact with society, perhaps you should just shut up with the dissing
people on here and take lessons on how to politly communicate with people!
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"--CELKO--" <jcelko212@.earthlink.net> wrote in message
news:1134740263.450919.20570@.g47g2000cwa.googlegroups.com...
> You might want to learn about First Normal Form (1NF) and what a tiered
> architecture is before you try SQL coding. You have missed the
> foundations and are asking for kludges in Newsgroups when you need to
> be studying.
> If you **really** want to be a bad programmer, look up cursors and
> always comment your code with a note that it needs to be replaced by a
> good SQL programmer.
>|||Yes BUT...the ng needs wits regardless of the adjective(s) or
quantity(s) that realistically apply :)
Happy Holidays to the full spectrum of wits...
www.rac4sql.net
"Tony Rogerson" <tonyrogerson@.sqlserverfaq.com> wrote in message
news:eLEMwGlAGHA.2040@.TK2MSFTNGP14.phx.gbl...
> You might want to find out why the poster wants to do this before you slag
> him or her off.
> Just because with your limited real industrial experience in programming
> you've not come across a need for this doesn't make the poster a bad
> programmer.
> You need a serious lesson in maners - go back to school and learn how to
> interact with society, perhaps you should just shut up with the dissing
> people on here and take lessons on how to politly communicate with people!
> --
> Tony Rogerson
> SQL Server MVP
> http://sqlserverfaq.com - free video tutorials
>
> "--CELKO--" <jcelko212@.earthlink.net> wrote in message
> news:1134740263.450919.20570@.g47g2000cwa.googlegroups.com...
>
Is it possible to get all the column values in a single column from a
table?
For e.g.
a1 a2 a3
== == ==
1 2 3
4 5 6
I need the output like
Allcolums
***********
123
456
I am not ready to mention the column names in the query. It should be
generic.
Thanks in advance.Hi
You would be better of leaving this for the front end otherwise it would
mean resorting to cursors and dynamic SQL.
John
"KssKumar2000" wrote:
> Hi
> Is it possible to get all the column values in a single column from a
> table?
> For e.g.
> a1 a2 a3
> == == ==
> 1 2 3
> 4 5 6
> I need the output like
> Allcolums
> ***********
> 123
> 456
>
> I am not ready to mention the column names in the query. It should be
> generic.
> Thanks in advance.
>|||will this work
assuming that each column is of string data type
select a1+a2+a3 from table
or this one if you have nulls
select isnull(a1,'')+isnull(a1,'')+isnull(a1,''
)
thanks,
Jose de Jesus Jr. Mcp,Mcdba
MCP #2324787
"KssKumar2000" wrote:
> Hi
> Is it possible to get all the column values in a single column from a
> table?
> For e.g.
> a1 a2 a3
> == == ==
> 1 2 3
> 4 5 6
> I need the output like
> Allcolums
> ***********
> 123
> 456
>
> I am not ready to mention the column names in the query. It should be
> generic.
> Thanks in advance.
>|||You might want to learn about First Normal Form (1NF) and what a tiered
architecture is before you try SQL coding. You have missed the
foundations and are asking for kludges in Newsgroups when you need to
be studying.
If you **really** want to be a bad programmer, look up cursors and
always comment your code with a note that it needs to be replaced by a
good SQL programmer.|||You might want to find out why the poster wants to do this before you slag
him or her off.
Just because with your limited real industrial experience in programming
you've not come across a need for this doesn't make the poster a bad
programmer.
You need a serious lesson in maners - go back to school and learn how to
interact with society, perhaps you should just shut up with the dissing
people on here and take lessons on how to politly communicate with people!
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"--CELKO--" <jcelko212@.earthlink.net> wrote in message
news:1134740263.450919.20570@.g47g2000cwa.googlegroups.com...
> You might want to learn about First Normal Form (1NF) and what a tiered
> architecture is before you try SQL coding. You have missed the
> foundations and are asking for kludges in Newsgroups when you need to
> be studying.
> If you **really** want to be a bad programmer, look up cursors and
> always comment your code with a note that it needs to be replaced by a
> good SQL programmer.
>|||Yes BUT...the ng needs wits regardless of the adjective(s) or
quantity(s) that realistically apply :)
Happy Holidays to the full spectrum of wits...
www.rac4sql.net
"Tony Rogerson" <tonyrogerson@.sqlserverfaq.com> wrote in message
news:eLEMwGlAGHA.2040@.TK2MSFTNGP14.phx.gbl...
> You might want to find out why the poster wants to do this before you slag
> him or her off.
> Just because with your limited real industrial experience in programming
> you've not come across a need for this doesn't make the poster a bad
> programmer.
> You need a serious lesson in maners - go back to school and learn how to
> interact with society, perhaps you should just shut up with the dissing
> people on here and take lessons on how to politly communicate with people!
> --
> Tony Rogerson
> SQL Server MVP
> http://sqlserverfaq.com - free video tutorials
>
> "--CELKO--" <jcelko212@.earthlink.net> wrote in message
> news:1134740263.450919.20570@.g47g2000cwa.googlegroups.com...
>
Monday, March 12, 2012
Is it possible pass to procedure open cursor from other procedure
No. A procedure can not have a input parameter of type cursor. You can call
a
second procedure that has an output parameter of type cursor.
Example:
use northwind
go
create procedure proc1
@.c cursor varying output
as
set nocount on
set @.c = cursor local fast_forward for select orderid from dbo.orders
open @.c
go
create procedure proc2
as
set nocount on
declare @.c cursor
declare @.i int
exec proc1 @.c output
if cursor_status('variable', '@.c') = 1
begin
while 1 = 1
begin
fetch next from @.c into @.i
if @.@.error != 0 or @.@.fetch_status != 0 break
print @.i
end
close @.c
deallocate @.c
end
go
exec proc2
go
drop procedure proc2, proc1
go
Try to find a set-based solution first, leave cursors as the last tool in
your pocket.
AMB
"JB via webservertalk.com" wrote:
> Is it possible pass to procedure open cursor from other procedure ?
> Any suggestions will be appreciated
> --
> Message posted via http://www.webservertalk.com
>thank you.
What di
vantages of using cursor rather then temp table?
Message posted via http://www.webservertalk.com
a
second procedure that has an output parameter of type cursor.
Example:
use northwind
go
create procedure proc1
@.c cursor varying output
as
set nocount on
set @.c = cursor local fast_forward for select orderid from dbo.orders
open @.c
go
create procedure proc2
as
set nocount on
declare @.c cursor
declare @.i int
exec proc1 @.c output
if cursor_status('variable', '@.c') = 1
begin
while 1 = 1
begin
fetch next from @.c into @.i
if @.@.error != 0 or @.@.fetch_status != 0 break
print @.i
end
close @.c
deallocate @.c
end
go
exec proc2
go
drop procedure proc2, proc1
go
Try to find a set-based solution first, leave cursors as the last tool in
your pocket.
AMB
"JB via webservertalk.com" wrote:
> Is it possible pass to procedure open cursor from other procedure ?
> Any suggestions will be appreciated
> --
> Message posted via http://www.webservertalk.com
>thank you.
What di
Message posted via http://www.webservertalk.com
Subscribe to:
Posts (Atom)