Showing posts with label display. Show all posts
Showing posts with label display. Show all posts

Friday, March 30, 2012

how to control a column limited to display?

Hi,

Can I control a column to displayed to a specifal user or specifal role?

If not the specifal user or specifal role, the column will can not be displayed.

Thank you.

Jeffers

You can set a conditional column visibility using User!UserID. For more involved scenarios, you may need to whip out some code to find the role/group the user belongs to given the user logon name.

Monday, March 12, 2012

How to conditionally move field?

User enters a starting quarter and a year. I need to display 10 quarters and their years in line:
2005 . . . 2006
Q3 Q4 Q1 Q2 Q3 Q4 ...
Obviously, position of a year field will change based on whether we start from Q1 or from Q4.
Is there a way to do it?I'd probably put each variation in different sections and suppress each section accordingly.
Alternatively, use a non-proportional font and build up a string to display the year values with front space padding as required.

Friday, March 9, 2012

How to Concatinate results to display results in a list from Left - Right instead of Top -

Hi,
I am creating a report using SQL Server Reporting Services 2000. My
report displays values in datatable. Say, the table looks like this
EmpName Emp# Address Phone#
..... ... ...... ...
I want all phone # for an employee to be displayed in a single row.
This can be acheived by displaying phone numbers in a group footer
(group by emp#). But I want all phone# to be displayed horizontally
(Left - Right) not vertically (Top - Bottom).
Instead of displaying results like this
EmpName Emp# Address
..... ... ......
Phones
###
###
###
###
I want to display results like below -
EmpName Emp# Address Phone#
..... ... ...... ...
Phones ### , ### , ####, ###, ###, ###
..... ... ...... ...
Phones ### , ###
..... ... ...... ...
Phones ### , ###, ### , ###
How can I concatinate the phone# ? I tried using a sub report in the
footer to retrive all phone# for an employee but how to concatinate
them ?
I tried to query like this
SELECT @.STRCON = EmpPhone + ', ' FROM EMPLOYEE WHERE EMPID = ###
But I'm not sure about the length of the return value (may be more than
8000 characters).
So is there any way in concatinating values in Report ? Or is there any
way in acheiving this in a Listbox or Table ?
Regards,
ChiroI think Chris Hays has something that will work for you.
http://blogs.msdn.com/chrishays/archive/2004/07/23/HorizontalTables.aspx
Steve MunLeeuw
"Chiro" <chirangv@.hotmail.com> wrote in message
news:1161268089.076044.227180@.e3g2000cwe.googlegroups.com...
> Hi,
> I am creating a report using SQL Server Reporting Services 2000. My
> report displays values in datatable. Say, the table looks like this
> EmpName Emp# Address Phone#
> ..... ... ...... ...
> I want all phone # for an employee to be displayed in a single row.
> This can be acheived by displaying phone numbers in a group footer
> (group by emp#). But I want all phone# to be displayed horizontally
> (Left - Right) not vertically (Top - Bottom).
> Instead of displaying results like this
> EmpName Emp# Address
> ..... ... ......
> Phones
> ###
> ###
> ###
> ###
> I want to display results like below -
> EmpName Emp# Address Phone#
> ..... ... ...... ...
> Phones ### , ### , ####, ###, ###, ###
> ..... ... ...... ...
> Phones ### , ###
> ..... ... ...... ...
> Phones ### , ###, ### , ###
>
> How can I concatinate the phone# ? I tried using a sub report in the
> footer to retrive all phone# for an employee but how to concatinate
> them ?
> I tried to query like this
> SELECT @.STRCON = EmpPhone + ', ' FROM EMPLOYEE WHERE EMPID = ###
> But I'm not sure about the length of the return value (may be more than
> 8000 characters).
> So is there any way in concatinating values in Report ? Or is there any
> way in acheiving this in a Listbox or Table ?
> Regards,
> Chiro
>|||Hi,
Thank You.
I was able to acheive this as follows -
1. Add a Matrix control. Add Phone# in column grouping of matrix.
2. Add a ListBox control. Include Matrix inside the Listbox.
3. Edit details of Listbox to add a group expression
=RowNumber(Nothing) / 15. (15 is number of columns to be displayed)
4. Add a Matrix column group expression as your Listbox group
expression.
=RowNumber("list1_Details_Group"). Now your matrix should contain 2
group expressions. (1 for Phone # and other for controling no. of
columns).
Regards,
Chiro
Steve MunLeeuw wrote:
> I think Chris Hays has something that will work for you.
> http://blogs.msdn.com/chrishays/archive/2004/07/23/HorizontalTables.aspx
> Steve MunLeeuw
> "Chiro" <chirangv@.hotmail.com> wrote in message
> news:1161268089.076044.227180@.e3g2000cwe.googlegroups.com...
> > Hi,
> > I am creating a report using SQL Server Reporting Services 2000. My
> > report displays values in datatable. Say, the table looks like this
> >
> > EmpName Emp# Address Phone#
> > ..... ... ...... ...
> > I want all phone # for an employee to be displayed in a single row.
> > This can be acheived by displaying phone numbers in a group footer
> > (group by emp#). But I want all phone# to be displayed horizontally
> > (Left - Right) not vertically (Top - Bottom).
> > Instead of displaying results like this
> > EmpName Emp# Address
> > ..... ... ......
> > Phones
> > ###
> > ###
> > ###
> > ###
> > I want to display results like below -
> > EmpName Emp# Address Phone#
> > ..... ... ...... ...
> > Phones ### , ### , ####, ###, ###, ###
> > ..... ... ...... ...
> > Phones ### , ###
> > ..... ... ...... ...
> > Phones ### , ###, ### , ###
> >
> >
> > How can I concatinate the phone# ? I tried using a sub report in the
> > footer to retrive all phone# for an employee but how to concatinate
> > them ?
> > I tried to query like this
> > SELECT @.STRCON = EmpPhone + ', ' FROM EMPLOYEE WHERE EMPID = ###
> > But I'm not sure about the length of the return value (may be more than
> >
> > 8000 characters).
> > So is there any way in concatinating values in Report ? Or is there any
> >
> > way in acheiving this in a Listbox or Table ?
> > Regards,
> > Chiro
> >

how to concatenate 2 recordsets

is it possible to concatenate 2 recordsets ?
i have 2 selects and i want to display all results from the first
select and then the results from the second select query
with paging.
if i use union, all the results will be mixed.
thanks for the help!Post the queries you intend to combine and I'd be willing to take a shot at it for you.

-PatP|||if i use union, all the results will be mixed.not if you use UNION ALL with an ORDER BY clause|||if i use UNION ALL i get duplicated rows

here is one example of a full query i need to be gathered:

0 select * from view_veiculos where ativo='1' and ( nome_marc like
'%aa%' or nome_mod like '%aa%' or estado like '%aa%' or cidade like
'%aa%' or ano like '%aa%' ) and ( nome_marc like '%bb%' or nome_mod
like '%bb%' or estado like '%bb%' or cidade like '%bb%' or ano like
'%bb%' ) and ( nome_marc like '%cc%' or nome_mod like '%cc%' or estado
like '%cc%' or cidade like '%cc%' or ano like '%cc%' ) and ( nome_marc
like '%dd%' or nome_mod like '%dd%' or estado like '%dd%' or cidade
like '%dd%' or ano like '%dd%' ) and ( nome_marc like '%ee%' or
nome_mod like '%ee%' or estado like '%ee%' or cidade like '%ee%' or
ano like '%ee%' ) and ( nome_marc like '%ff%' or nome_mod like '%ff%'
or estado like '%ff%' or cidade like '%ff%' or ano like '%ff%' ) union
all

1 select * from view_veiculos where ativo='1' and ( nome_marc like
'%aa%' or nome_mod like '%aa%' or estado like '%aa%' or cidade like
'%aa%' or ano like '%aa%' ) and ( nome_marc like '%bb%' or nome_mod
like '%bb%' or estado like '%bb%' or cidade like '%bb%' or ano like
'%bb%' ) and ( nome_marc like '%cc%' or nome_mod like '%cc%' or estado
like '%cc%' or cidade like '%cc%' or ano like '%cc%' ) and ( nome_marc
like '%dd%' or nome_mod like '%dd%' or estado like '%dd%' or cidade
like '%dd%' or ano like '%dd%' ) and ( nome_marc like '%ee%' or
nome_mod like '%ee%' or estado like '%ee%' or cidade like '%ee%' or
ano like '%ee%' ) union all

2 select * from view_veiculos where ativo='1' and ( nome_marc like
'%aa%' or nome_mod like '%aa%' or estado like '%aa%' or cidade like
'%aa%' or ano like '%aa%' ) and ( nome_marc like '%bb%' or nome_mod
like '%bb%' or estado like '%bb%' or cidade like '%bb%' or ano like
'%bb%' ) and ( nome_marc like '%cc%' or nome_mod like '%cc%' or estado
like '%cc%' or cidade like '%cc%' or ano like '%cc%' ) and ( nome_marc
like '%dd%' or nome_mod like '%dd%' or estado like '%dd%' or cidade
like '%dd%' or ano like '%dd%' ) union all

3 select * from view_veiculos where ativo='1' and ( nome_marc like
'%aa%' or nome_mod like '%aa%' or estado like '%aa%' or cidade like
'%aa%' or ano like '%aa%' ) and ( nome_marc like '%bb%' or nome_mod
like '%bb%' or estado like '%bb%' or cidade like '%bb%' or ano like
'%bb%' ) and ( nome_marc like '%cc%' or nome_mod like '%cc%' or estado
like '%cc%' or cidade like '%cc%' or ano like '%cc%' ) union all

4 select * from view_veiculos where ativo='1' and ( nome_marc like
'%aa%' or nome_mod like '%aa%' or estado like '%aa%' or cidade like
'%aa%' or ano like '%aa%' ) and ( nome_marc like '%bb%' or nome_mod
like '%bb%' or estado like '%bb%' or cidade like '%bb%' or ano like
'%bb%' ) union all

5 select * from view_veiculos where ativo='1' and ( nome_marc like
'%aa%' or nome_mod like '%aa%' or estado like '%aa%' or cidade like
'%aa%' or ano like '%aa%' ) union all

6 select * from view_veiculos where ativo='1' and ( nome_marc like
'%bb%' or nome_mod like '%bb%' or estado like '%bb%' or cidade like
'%bb%' or ano like '%bb%' ) and ( nome_marc like '%cc%' or nome_mod
like '%cc%' or estado like '%cc%' or cidade like '%cc%' or ano like
'%cc%' ) and ( nome_marc like '%dd%' or nome_mod like '%dd%' or estado
like '%dd%' or cidade like '%dd%' or ano like '%dd%' ) and ( nome_marc
like '%ee%' or nome_mod like '%ee%' or estado like '%ee%' or cidade
like '%ee%' or ano like '%ee%' ) and ( nome_marc like '%ff%' or
nome_mod like '%ff%' or estado like '%ff%' or cidade like '%ff%' or
ano like '%ff%' ) union all

7 select * from view_veiculos where ativo='1' and ( nome_marc like
'%bb%' or nome_mod like '%bb%' or estado like '%bb%' or cidade like
'%bb%' or ano like '%bb%' ) and ( nome_marc like '%cc%' or nome_mod
like '%cc%' or estado like '%cc%' or cidade like '%cc%' or ano like
'%cc%' ) and ( nome_marc like '%dd%' or nome_mod like '%dd%' or estado
like '%dd%' or cidade like '%dd%' or ano like '%dd%' ) and ( nome_marc
like '%ee%' or nome_mod like '%ee%' or estado like '%ee%' or cidade
like '%ee%' or ano like '%ee%' ) union all

8 select * from view_veiculos where ativo='1' and ( nome_marc like
'%bb%' or nome_mod like '%bb%' or estado like '%bb%' or cidade like
'%bb%' or ano like '%bb%' ) and ( nome_marc like '%cc%' or nome_mod
like '%cc%' or estado like '%cc%' or cidade like '%cc%' or ano like
'%cc%' ) and ( nome_marc like '%dd%' or nome_mod like '%dd%' or estado
like '%dd%' or cidade like '%dd%' or ano like '%dd%' ) union all

9 select * from view_veiculos where ativo='1' and ( nome_marc like
'%bb%' or nome_mod like '%bb%' or estado like '%bb%' or cidade like
'%bb%' or ano like '%bb%' ) and ( nome_marc like '%cc%' or nome_mod
like '%cc%' or estado like '%cc%' or cidade like '%cc%' or ano like
'%cc%' ) union all

10 select * from view_veiculos where ativo='1' and ( nome_marc like
'%bb%' or nome_mod like '%bb%' or estado like '%bb%' or cidade like
'%bb%' or ano like '%bb%' ) union all

11 select * from view_veiculos where ativo='1' and ( nome_marc like
'%cc%' or nome_mod like '%cc%' or estado like '%cc%' or cidade like
'%cc%' or ano like '%cc%' ) and ( nome_marc like '%dd%' or nome_mod
like '%dd%' or estado like '%dd%' or cidade like '%dd%' or ano like
'%dd%' ) and ( nome_marc like '%ee%' or nome_mod like '%ee%' or estado
like '%ee%' or cidade like '%ee%' or ano like '%ee%' ) and ( nome_marc
like '%ff%' or nome_mod like '%ff%' or estado like '%ff%' or cidade
like '%ff%' or ano like '%ff%' ) union all

12 select * from view_veiculos where ativo='1' and ( nome_marc like
'%cc%' or nome_mod like '%cc%' or estado like '%cc%' or cidade like
'%cc%' or ano like '%cc%' ) and ( nome_marc like '%dd%' or nome_mod
like '%dd%' or estado like '%dd%' or cidade like '%dd%' or ano like
'%dd%' ) and ( nome_marc like '%ee%' or nome_mod like '%ee%' or estado
like '%ee%' or cidade like '%ee%' or ano like '%ee%' ) union all

13 select * from view_veiculos where ativo='1' and ( nome_marc like
'%cc%' or nome_mod like '%cc%' or estado like '%cc%' or cidade like
'%cc%' or ano like '%cc%' ) and ( nome_marc like '%dd%' or nome_mod
like '%dd%' or estado like '%dd%' or cidade like '%dd%' or ano like
'%dd%' ) union all

14 select * from view_veiculos where ativo='1' and ( nome_marc like
'%cc%' or nome_mod like '%cc%' or estado like '%cc%' or cidade like
'%cc%' or ano like '%cc%' ) union all

15 select * from view_veiculos where ativo='1' and ( nome_marc like
'%dd%' or nome_mod like '%dd%' or estado like '%dd%' or cidade like
'%dd%' or ano like '%dd%' ) and ( nome_marc like '%ee%' or nome_mod
like '%ee%' or estado like '%ee%' or cidade like '%ee%' or ano like
'%ee%' ) and ( nome_marc like '%ff%' or nome_mod like '%ff%' or estado
like '%ff%' or cidade like '%ff%' or ano like '%ff%' ) union all

16 select * from view_veiculos where ativo='1' and ( nome_marc like
'%dd%' or nome_mod like '%dd%' or estado like '%dd%' or cidade like
'%dd%' or ano like '%dd%' ) and ( nome_marc like '%ee%' or nome_mod
like '%ee%' or estado like '%ee%' or cidade like '%ee%' or ano like
'%ee%' ) union all

17 select * from view_veiculos where ativo='1' and ( nome_marc like
'%dd%' or nome_mod like '%dd%' or estado like '%dd%' or cidade like
'%dd%' or ano like '%dd%' ) union all

18 select * from view_veiculos where ativo='1' and ( nome_marc like
'%ee%' or nome_mod like '%ee%' or estado like '%ee%' or cidade like
'%ee%' or ano like '%ee%' ) and ( nome_marc like '%ff%' or nome_mod
like '%ff%' or estado like '%ff%' or cidade like '%ff%' or ano like
'%ff%' ) union all

19 select * from view_veiculos where ativo='1' and ( nome_marc like
'%ee%' or nome_mod like '%ee%' or estado like '%ee%' or cidade like
'%ee%' or ano like '%ee%' ) union all
- Hide quoted text -

20 select * from view_veiculos where ativo='1' and ( nome_marc like
'%ff%' or nome_mod like '%ff%' or estado like '%ff%' or cidade like
'%ff%' or ano like '%ff%' )

these numbers are here just to show us how many select statements it has
id like the final result to be ordered w all results from the first query,
then all results from second query and so on

when i use union on it, all results are mixed|||you have 20 select statements that are all doing the same thing!!

i have a feeling they should be just one query, and the WHERE clauses combined with ORs

no wonder UNION ALL returns dupes -- there are lots of dupes, and a given row might satisfy 10 of your queries

however, you forgot to add a row discriminator and an ORDER BY clause

here is an example --select 1 as row_type
, foo
, bar
from table1
union all
select 2
, foo
, bar
from table2
order
by row_type
, foonotice that all the rows from the first select will have 1s in the first column of results, while all the rows from the second select will have 2s in the first column of results, so it is then not possible for a row from the first select to duplicate a row from the second select

this is the true concatenation of result sets

:)|||it gave me duplicated rows.

but thanks for helping

i think i must use one temporary table or a table variable|||In order to avoid many different problems with your original approach, I would suggest using:SELECT *
FROM (SELECT *
, CASE
WHEN 0 < CharIndex('aa', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('bb', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('cc', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('dd', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ee', nome_marc + nom_mod + estado + cidade + ano)
THEN 1
WHEN 0 < CharIndex('aa', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('bb', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('cc', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('dd', nome_marc + nom_mod + estado + cidade + ano)
THEN 2
WHEN 0 < CharIndex('aa', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('bb', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('cc', nome_marc + nom_mod + estado + cidade + ano)
THEN 3
WHEN 0 < CharIndex('aa', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('bb', nome_marc + nom_mod + estado + cidade + ano)
THEN 4
WHEN 0 < CharIndex('aa', nome_marc + nom_mod + estado + cidade + ano)
THEN 5
WHEN 0 < CharIndex('bb', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('cc', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('dd', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ee', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ff', nome_marc + nom_mod + estado + cidade + ano)
THEN 6
WHEN 0 < CharIndex('bb', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('cc', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('dd', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ee', nome_marc + nom_mod + estado + cidade + ano)
THEN 7
WHEN 0 < CharIndex('bb', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('cc', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('dd', nome_marc + nom_mod + estado + cidade + ano)
THEN 8
WHEN 0 < CharIndex('bb', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('cc', nome_marc + nom_mod + estado + cidade + ano)
THEN 9
WHEN 0 < CharIndex('bb', nome_marc + nom_mod + estado + cidade + ano)
THEN 10
WHEN 0 < CharIndex('cc', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('dd', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ee', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ff', nome_marc + nom_mod + estado + cidade + ano)
THEN 11
WHEN 0 < CharIndex('cc', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('dd', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ee', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ff', nome_marc + nom_mod + estado + cidade + ano)
THEN 11
WHEN 0 < CharIndex('cc', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('dd', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ee', nome_marc + nom_mod + estado + cidade + ano)
THEN 12
WHEN 0 < CharIndex('cc', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('dd', nome_marc + nom_mod + estado + cidade + ano)
THEN 13
WHEN 0 < CharIndex('cc', nome_marc + nom_mod + estado + cidade + ano)
THEN 14
WHEN 0 < CharIndex('dd', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ee', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ff', nome_marc + nom_mod + estado + cidade + ano)
THEN 15
WHEN 0 < CharIndex('dd', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ee', nome_marc + nom_mod + estado + cidade + ano)
THEN 16
WHEN 0 < CharIndex('dd', nome_marc + nom_mod + estado + cidade + ano)
THEN 17
WHEN 0 < CharIndex('ee', nome_marc + nom_mod + estado + cidade + ano)
AND 0 < CharIndex('ff', nome_marc + nom_mod + estado + cidade + ano)
THEN 18
WHEN 0 < CharIndex('ee', nome_marc + nom_mod + estado + cidade + ano)
THEN 19
WHEN 0 < CharIndex('ff', nome_marc + nom_mod + estado + cidade + ano)
THEN 20
ELSE 0
END AS DBForums) AS a
WHERE 0 <> DBForums
ORDER BY DBForums
-PatP|||to avoid duplicate rows use just UNION instead of UNION ALL.

Wednesday, March 7, 2012

how to compare current date with sql db datetime data type

Hi,

I am using one datetime data type ( name: date_added ) and getdate() as default value. I want to display only those records added today. How I can compare current date with date_added.

Thanks
ManojSELECT * FROM tablename WHERE CONVERT(varchar(10),date_added,112)=CONVERT(varchar(10),GetDate(),112)

This converts both dates to yyyymmdd format, and then compares them. A better alternative might be:

SELECT * FROM tablename WHERE date_added>=CONVERT(datetime,CONVERT(varchar(10),GetDate(),112))

This presumes that there are no records added later than today. It compares the date_added to getdate() return value, converted to yyyymmdd, then converted back to a date.