Showing posts with label contains. Show all posts
Showing posts with label contains. Show all posts

Monday, March 26, 2012

Formatting/Returning stored proc results as XML

I have a stored proc that contains a simple select statement. The select statement does not use the 'FOR XML' clause, nor can the select statement be modified to use the 'FOR XML' clause (for compatibility reasons)

Is there a way to execute the stored proc such that it returns its output in XML? I'm looking for something similar to this:

Code Snippet

exec spGetUserDetails @.ID = 1234 for xml raw

Thanks.

I found an approach that would preserve backwards compatibility while allowing me to manipulate results retrieved by a stored proc. It has to do with Table-valued user-defined functions:

Move the select statement from the stored proc into a user--defined function that returns TABLE:

Code Snippet

-- Example from Books Online

CREATE FUNCTION fn_SalesByStore (@.storeid int)
RETURNS TABLE
AS
RETURN ( SELECT * from Products where StoedID = @.storeid );

Modify the original stored proc to call this user-defined function, i.e., the stored proc wraps the UDF hence preserving backwards compatibility:

Code Snippet

-- Inside the stored proc comment the select statement and call the UDF

-- SELECT * from Products where StoedID = @.storeid -- No longer needed

select * from fn_SalesByStore (@.storeid);

Now I can call the UDF to retreive the same results that would have been retrieved by the original stroed proc, and more importantly, manipulate them as required.

Code Snippet

select * from fn_SalesByStore (@.storeid) for xml raw

Yazan

Wednesday, March 21, 2012

formatting issures using tables and mutiple matrixes

Hi. I have a report that pulls all info from a single dataset. However, one
field "type" contains either "a" or "b". I have two matrixes, One for the
description and count of type a and another for type b. I also have data
from the dataset that needs to be both before and after each matrix.
When i layout the tables and matrixes, I measure them EXACTLY next to each
other by adding the position of one item and the width of it to determin the
position of the next. Also put them all in a header of another table with
zero padding. I also make the cangrow and canshrink atrributes to false to
keep all my rows aligned.
No matter what I do, the report always comes out unaligned. I've tried
rectangles already and they didnt work either. sometimes the report will
break on the tables for x number of rows and break for the matrixes at y
number of rows.
Does anyone know how to make matrixes and tables line up side by side,
return the same number of rows per page (this hsould be a no brainer because
its getting its data from the same dataset and there are no forced breaks)
AND make sure all the rows are the same width to ensure what is really four
tables looks like one?
I can provied the rdl if anyone wants to see it.Sorry, forgot to mention. SQL2005, Reporting Services 2005
"cr" wrote:
> Hi. I have a report that pulls all info from a single dataset. However, one
> field "type" contains either "a" or "b". I have two matrixes, One for the
> description and count of type a and another for type b. I also have data
> from the dataset that needs to be both before and after each matrix.
> When i layout the tables and matrixes, I measure them EXACTLY next to each
> other by adding the position of one item and the width of it to determin the
> position of the next. Also put them all in a header of another table with
> zero padding. I also make the cangrow and canshrink atrributes to false to
> keep all my rows aligned.
> No matter what I do, the report always comes out unaligned. I've tried
> rectangles already and they didnt work either. sometimes the report will
> break on the tables for x number of rows and break for the matrixes at y
> number of rows.
> Does anyone know how to make matrixes and tables line up side by side,
> return the same number of rows per page (this hsould be a no brainer because
> its getting its data from the same dataset and there are no forced breaks)
> AND make sure all the rows are the same width to ensure what is really four
> tables looks like one?
> I can provied the rdl if anyone wants to see it.
>

Monday, March 19, 2012

Formatting Data Output

In a report that has a table that contains a number field, how do you
format the output to contain commas between thousands?On Mar 7, 10:15 am, robin9...@.hotmail.com wrote:
> In a report that has a table that contains a number field, how do you
> format the output to contain commas between thousands?
Select the cell(s) that need the thousands format (in Layout view) and
in the 'Format' field of the Properties window, enter: #,0
Regards,
Enrique Martinez
Sr. SQL Server Developer|||i already set the format to the fields, but even my windows regional
settings configuration is SPANISH MEXICO (wich means comma for thousands an
a period for decimals) im still seeing my reports with periods for thousands
and comma for decimals
what else i should check?
"EMartinez" <emartinez.pr1@.gmail.com> wrote in message
news:1173303498.820749.284820@.n33g2000cwc.googlegroups.com...
> On Mar 7, 10:15 am, robin9...@.hotmail.com wrote:
>> In a report that has a table that contains a number field, how do you
>> format the output to contain commas between thousands?
>
> Select the cell(s) that need the thousands format (in Layout view) and
> in the 'Format' field of the Properties window, enter: #,0
> Regards,
> Enrique Martinez
> Sr. SQL Server Developer
>|||Thanks, that worked.
On 7 Mar, 21:38, "EMartinez" <emartinez...@.gmail.com> wrote:
> On Mar 7, 10:15 am, robin9...@.hotmail.com wrote:
> > In a report that has a table that contains a number field, how do you
> > format the output to contain commas between thousands?
> Select the cell(s) that need the thousands format (in Layout view) and
> in the 'Format' field of the Properties window, enter: #,0
> Regards,
> Enrique Martinez
> Sr. SQL Server Developer|||On Mar 8, 3:56 am, robin9...@.hotmail.com wrote:
> Thanks, that worked.
> On 7 Mar, 21:38, "EMartinez" <emartinez...@.gmail.com> wrote:
> > On Mar 7, 10:15 am, robin9...@.hotmail.com wrote:
> > > In a report that has a table that contains a number field, how do you
> > > format the output to contain commas between thousands?
> > Select the cell(s) that need the thousands format (in Layout view) and
> > in the 'Format' field of the Properties window, enter: #,0
> > Regards,
> > Enrique Martinez
> > Sr. SQL Server Developer
You're welcome.
Regards,
Enrique Martinez
Sr. SQL Server Developer

Sunday, February 26, 2012

Format measure from milliseconds to HH:MM:SS

Hi,

I have a measure that contains milliseconds, I want to display it in the HH:MM:SS format.

How to specify the format string?

please help.

Regards

Vijay R

Hi Vijay,

This thread from the public SQL Server OLAP Newgroup discusses some approaches:

http://groups.google.com/group/microsoft.public.sqlserver.olap/msg/37b9ae771bc762bc

>>

microsoft.public.sqlserver.olap > How to format & display a measure which is in seconds to HH:MM:SS

This MSDN link discusses FORMAT_STRING options for cube measures:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/olapdma
d/agmdxadvanced_2aur.asp

This earlier post shows how to format hh:mm:ss

http://groups-beta.google.com/group/microsoft.public.sqlserver.olap/msg/
13d3af02580a7257

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/olapdma
d/agmdxadvanced_2aur.asp

This earlier post shows how to format hh:mm:ss

http://groups-beta.google.com/group/microsoft.public.sqlserver.olap/msg/
13d3af02580a7257


From: Deepak Puri (d...@.progressive.com)
Subject: Time format Measure
This is the only article in this thread
View: Original Format
Newsgroups: microsoft.public.sqlserver.olap
Date: 2004-04-24 21:53:31 PST

Try the following format, if time is < 32K seconds:

With Member [Measures].[FormattedASA] as
'TimeSerial(0,0,[Measures].[AvgSpeedAnswer])',
FORMAT_STRING = 'hh:nn:ss'
>>