Showing posts with label services. Show all posts
Showing posts with label services. Show all posts

Wednesday, March 21, 2012

Retrieving multiple values from one field in SQL Server for use in multiple columsn in Reports

I am trying to create a report using Reporting Services.

My problem right now is that the way the table is constructed, I am trying to pull 3 seperate values i.e. One is the number of Hours, One is the type of work, and the 3rd is the Grade, out of one column and place them in 3 seperate columns in the report.

I can currently get one value but how to get the information I need to be able to use in my reports.

So far what I've been working with SQL Reporting Services 2005 I love it and have made several reports, but this one has got me stumped.

Any help would be appreciated.

Thanks.

I might not have made my problem quite clear enough. My table has one column labeled value. The value in that table is linked through an ID field to another table where the ID's are broken down to one ID =Number of Hours, One ID = Grade and One ID= type of work.

What I'm trying to do is when using these ID's and seperate the value related to those ID's into 3 seperate columns in a query for using in Reporting Services to create the report

As you can see, I'm attempting to change the name of the same column 3 times to reflect the correct information and then link them all to the person, where one person might have several entries in the other fields.

As you can see I can change the names individually in queries and pull the information seperately, it's when roll them altogether is where I'm running into my problem

Thanks for the suggestions that were made, I apoligize for not making the problem clearer.

Here is a copy of what I'm attempting to accomplish. I didn't have it with me last night when posting.

--Pulls the Service Opportunity

SELECT cs.value AS "Service Opportunity"

FROM Cstudent cs

INNER JOIN cattribute ca ON ca.attributeid = cs.attributeid

WHERE ca.name = 'Service Opportunity'

--Pulls the Number of Hours

SELECT cs.value AS 'Number of Hours'

FROM Cstudent cs

INNER JOIN cattribute ca ON ca.attributeid =cs.attributeid

WHERE ca.name ='Num of Hours'

--Pulls the Person Grade Level

SELECT cs.value AS 'Grade'

FROM Cstudent cs

INNER JOIN cattribute ca ON ca.attributeid =cs.attributeid

WHERE ca.name ='Grade'

--Pulls the Person Number, First and Last Name and Grade Level

SELECT s.personnumber, s.lastname, s.firstname, cs.value as "Grade"

FROM student s

INNER JOIN cperson cs ON cs.personid = s.personid

INNER JOIN cattribute ca ON ca.attributeid = cs.attributeid

WHERE cs.value =(SELECT cs.value AS 'Grade'

WHERE ca.attributeid = cs.attributeid AND ca.name='Grade')

There are a number of ways to solve this. Here are a few options:

If each value is in its own row, like this:

Name Value

Hours 100

Type AAA

Grade C

the SQL Pivot statement can be used in your query to pivot the rows to columns, so the result looks like:

Hours Type Grade

100 AAA C

If the values are concatenated in a single column, like:

Column

100;AAA;C

then you can use the Split VB function in the report to split the string into its component parts, and put them into fields. To get the values, you can use the following:

=Split(Fields!Column.Value, ";")(0)

=Split(Fields!Column.Value, ";")(1)

=Split(Fields!Column.Value, ";")(2)

|||

It is quite clear from your post that you have all the data in one column in a database table. If you have access to the query or the stored procedure, try to accomplish this in the SQL query level itself because calculating it in reporting service is costlier than doing it in the query level (better if there is a stored procedure becasue it is compiled and faster). Try using this sql query (assuming that your field separator is "," and the order is hours, type and then grade):

CASE WHEN CHARINDEX(',', Column1) > 0

SUBSTRING(Column1, 1, CHARINDEX(',', Column1)-1) AS 'Hours'

END,

CASE WHEN CHARINDEX(',', Column1) > 0

CASE WHEN CHARINDEX(',', SUBSTRING(Column1, CHARINDEX(',', Column1)+1, LEN(Column1)-CHARINDEX(',', Column1))) > 0

SUBSTRING(Column1, CHARINDEX(',', Column1)+1, CHARINDEX(',', SUBSTRING(Column1, CHARINDEX(',', Column1)+1, LEN(Column1)-CHARINDEX(',', Column1)))-1) AS 'Type'

END

END,

CASE WHEN CHARINDEX(',', SUBSTRING(Column1, CHARINDEX(',', Column1)+1, LEN(Column1)-CHARINDEX(',', Column1))) > 0

RIGHT(Column1, CHARINDEX(',', SUBSTRING(Column1, CHARINDEX(',', Column1)+1, LEN(Column1)-CHARINDEX(',', Column1)))+1) AS 'Grade'

END

If your still want to use reporting services, create 3 calculated dataset fields as follows:

Hours: IIf(Split(Fields!Column1.Value, ",").UpperBound>=0, Split(Fields!Column1.Value, ",")(0), "")

Type: IIf(Split(Fields!Column1.Value, ",").UpperBound>=1, Split(Fields!Column1.Value, ",")(1), "")

Grade: IIf(Split(Fields!Column1.Value, ",").UpperBound>=2, Split(Fields!Column1.Value, ",")(2), "")

Shyam

|||

John,

Thanks for the suggestion. I guess I didn't make myself very clear on to what I was attempting. I modified my thread and enclosed a sample of what I am attempting to do.

Thanks again for the help

|||

Shyam,

Thanks for the advice. I guess I didn't make myself clear enough on what I was attempting to do. I have modifed my thread and enclosed a sample of the code I am trying to make work.

Thanks again

|||

Use the following query to get all values at one shot:

SELECT cs1.value AS 'Service Opportunity', cs2.value AS 'Number of Hours', cs3.value AS 'Grade'

FROM Cstudent cs1

INNER JOIN cattribute ca ON ca.attributeid = cs1.attributeid

AND ca.name = 'Service Opportunity'

INNER JOIN Cstudent cs2 ON ca.attributeid = cs2.attributeid

AND ca.name = 'Num of Hours'

INNER JOIN Cstudent cs3 ON ca.attributeid = cs3.attributeid

AND ca.name = 'Grade'

Thanks,

Shyam

|||

Shyam,

I've been working with what you suggested but so far with no luck. It pulls the column headings but there is no information in the columns. I'm looking to see if I'm missing something somewhere.

Thanks for the advice though, I'll keep working at it and see what I can come up with.

Thanks

Wayne

|||

Maybe not all records are available in Cstudent, so use this query:

SELECT cs1.value AS 'Service Opportunity', cs2.value AS 'Number of Hours', cs3.value AS 'Grade'

FROM cattribute ca

LEFT OUTER JOIN Cstudent cs1

ca ON ca.attributeid = cs1.attributeid

AND ca.name = 'Service Opportunity'

LEFT OUTER JOIN Cstudent cs2 ON ca.attributeid = cs2.attributeid

AND ca.name = 'Num of Hours'

LEFT OUTER JOIN Cstudent cs3 ON ca.attributeid = cs3.attributeid

AND ca.name = 'Grade'

Shyam

|||

Shyam

Thanks for the help, Just have to do some more tweaking on my end but looks like it might give me what I'm looking for.

Thanks Again for the Help

Wayne

|||

So, can you mark the post as answer?

Shyam

|||

Shyam

Thanks for all the help. This was the first post I had done one here so I apoligize for that. It's taken care of and I posted it answered.

Wednesday, March 7, 2012

Retrieve the .rdl file from the reporting services server

Is it possible to retrieve the ".rdl" file published on the Reporting Services
server...
I made a stupid mistake and renamed a report from let say a.rdl to b.rdl
and started to revise the report. Then later on I needed to do some changes
to the published report a.rdl... Though, this file (a.rdl) doesn't exist on
my computer anymore...
Thanks in advance for any tipsHi Andreas:
I'd write an .RSS script file to pull the rdl with the web service.
Look in the books online at the GetReportDefinition method, it even
includes a sample to save the file to disk.
--
Scott
http://www.OdeToCode.com/blogs/scott
On 14 Oct 2004 09:24:17 -0700, akardell@.home.se (Andreas Kardell)
wrote:
>Is it possible to retrieve the ".rdl" file published on the Reporting Services
>server...
>I made a stupid mistake and renamed a report from let say a.rdl to b.rdl
>and started to revise the report. Then later on I needed to do some changes
>to the published report a.rdl... Though, this file (a.rdl) doesn't exist on
>my computer anymore...
>Thanks in advance for any tips|||Wherever the report is deployed, click on the report properties and then
click on the report, the properties tab, the edit link. You will be asked
where you want to save the rdl. Once you have saved the rdl then just add it
back to your project.
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Andreas Kardell" <akardell@.home.se> wrote in message
news:67424f9d.0410140824.27a8add8@.posting.google.com...
> Is it possible to retrieve the ".rdl" file published on the Reporting
Services
> server...
> I made a stupid mistake and renamed a report from let say a.rdl to b.rdl
> and started to revise the report. Then later on I needed to do some
changes
> to the published report a.rdl... Though, this file (a.rdl) doesn't exist
on
> my computer anymore...
> Thanks in advance for any tips|||Haha! Yep, I've been doing so much WS stuff lately it seems like it is
always the first solution that springs to mind. Thanks for pointing
that one out, Bruce.
--
Scott
http://www.OdeToCode.com/blogs/scott/
On Thu, 14 Oct 2004 14:19:19 -0500, "Bruce L-C [MVP]"
<bruce_lcNOSPAM@.hotmail.com> wrote:
>Wherever the report is deployed, click on the report properties and then
>click on the report, the properties tab, the edit link. You will be asked
>where you want to save the rdl. Once you have saved the rdl then just add it
>back to your project.|||Thank you Bruce and Scott!
That saved me a lot of trouble! And really simple solution too... those are
the best ones!
//Andreas
Scott Allen <bitmask@.[nospam].fred.net> wrote in message news:<8ueum0lit3nhpv83bs1jkajg4p1pmfj38s@.4ax.com>...
> Haha! Yep, I've been doing so much WS stuff lately it seems like it is
> always the first solution that springs to mind. Thanks for pointing
> that one out, Bruce.
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
> On Thu, 14 Oct 2004 14:19:19 -0500, "Bruce L-C [MVP]"
> <bruce_lcNOSPAM@.hotmail.com> wrote:
> >Wherever the report is deployed, click on the report properties and then
> >click on the report, the properties tab, the edit link. You will be asked
> >where you want to save the rdl. Once you have saved the rdl then just add it
> >back to your project.

Tuesday, February 21, 2012

Retrieve Data from Web Services Using DTS (SQL Server 2000)

The project I'm currently working on involves combining data from one SQL Server 2000 databases and XML returned from a web service into a 3rd SQL Server 2000 database.

This process must be scheduled to happen once a day. If it weren't for the Web Service, I'd say that this is a no-brainer and I'd use DTS. However, I'm not sure if I can even access a Web Service with DTS. Has anyone done this or have any tips?

Id try the microsoft.public.sqlserver.dts forum if I were you.

-Jamie

Retrieve data but with all the services stopped

Is that possible?
Thanks a lot,Are you talking about stopping SQL Server service, and still access the data
from the databases? In that case, it is not possible.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Enric" <Enric@.discussions.microsoft.com> wrote in message
news:572D7F2A-3307-4507-92E5-EDE88A66E285@.microsoft.com...
Is that possible?
Thanks a lot,|||Well, I meant not using "standard methods". Once all the services has been
stopped, SQL Server provides any kind of internal access using any dll or
interface?
In case that SQL "officially" doesn't provide any tool, in your opinion, it
would have any possibility to access?
Regards,
"Narayana Vyas Kondreddi" wrote:

> Are you talking about stopping SQL Server service, and still access the da
ta
> from the databases? In that case, it is not possible.
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "Enric" <Enric@.discussions.microsoft.com> wrote in message
> news:572D7F2A-3307-4507-92E5-EDE88A66E285@.microsoft.com...
> Is that possible?
> Thanks a lot,
>
>|||> Well, I meant not using "standard methods". Once all the services has been
> stopped, SQL Server provides any kind of internal access using any dll or
> interface?
No.

> In case that SQL "officially" doesn't provide any tool, in your opinion, i
t
> would have any possibility to access?
No. It isn't worth looking into. You would have to decode the database forma
t (most isn't
documented). It wouldn't be supported and you'd have to write a lot of low-l
evel code and you will
probably corrupt the data. I don't know anyone who has done this (after work
ing with SQL Server for
17 years now).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Enric" <Enric@.discussions.microsoft.com> wrote in message
news:1D32B125-D754-45FD-B0D5-179A734756D8@.microsoft.com...
> Well, I meant not using "standard methods". Once all the services has been
> stopped, SQL Server provides any kind of internal access using any dll or
> interface?
> In case that SQL "officially" doesn't provide any tool, in your opinion, i
t
> would have any possibility to access?
> Regards,
> "Narayana Vyas Kondreddi" wrote:
>|||Once the SQL Server service is stopped, the only way to access the data
would be to read the database files manually, provided you know the layout
of the files.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Enric" <Enric@.discussions.microsoft.com> wrote in message
news:1D32B125-D754-45FD-B0D5-179A734756D8@.microsoft.com...
Well, I meant not using "standard methods". Once all the services has been
stopped, SQL Server provides any kind of internal access using any dll or
interface?
In case that SQL "officially" doesn't provide any tool, in your opinion, it
would have any possibility to access?
Regards,
"Narayana Vyas Kondreddi" wrote:

> Are you talking about stopping SQL Server service, and still access the
data
> from the databases? In that case, it is not possible.
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "Enric" <Enric@.discussions.microsoft.com> wrote in message
> news:572D7F2A-3307-4507-92E5-EDE88A66E285@.microsoft.com...
> Is that possible?
> Thanks a lot,
>
>|||I am astonished myself because using a free editor (textpad) I can be able
to read layouts and real data inside of the MDF file.
Of course, these data are between a large amount of NULLS symbols, but...
Amazing or not?
"Narayana Vyas Kondreddi" wrote:

> Once the SQL Server service is stopped, the only way to access the data
> would be to read the database files manually, provided you know the layout
> of the files.
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "Enric" <Enric@.discussions.microsoft.com> wrote in message
> news:1D32B125-D754-45FD-B0D5-179A734756D8@.microsoft.com...
> Well, I meant not using "standard methods". Once all the services has been
> stopped, SQL Server provides any kind of internal access using any dll or
> interface?
> In case that SQL "officially" doesn't provide any tool, in your opinion, i
t
> would have any possibility to access?
> Regards,
> "Narayana Vyas Kondreddi" wrote:
>
> data
>
>|||Why would that be astonishing?
Yes, the data is inside the database files. So an editor will display some o
f the data (string
columns) as readable text.
Yes, the database format is complex and not documented.
Do you find anything of above astonishing? Perhaps I'm missing the point...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Enric" <Enric@.discussions.microsoft.com> wrote in message
news:299AA62B-188A-4DB3-BD8E-E06E53FFD35E@.microsoft.com...
>I am astonished myself because using a free editor (textpad) I can be able
> to read layouts and real data inside of the MDF file.
> Of course, these data are between a large amount of NULLS symbols, but...
> Amazing or not?
> "Narayana Vyas Kondreddi" wrote:
>|||Tibor,
At first I must say that I am just a newbie (only six years with SQL) and in
my humble point of view if my son (5 years) is be able to open doing
double-click
above MDF and read the data, so this way I was wondering, what would do a
expert programmer with that same file?
Regards,
"Tibor Karaszi" wrote:

> Why would that be astonishing?
> Yes, the data is inside the database files. So an editor will display some
of the data (string
> columns) as readable text.
> Yes, the database format is complex and not documented.
> Do you find anything of above astonishing? Perhaps I'm missing the point..
.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Enric" <Enric@.discussions.microsoft.com> wrote in message
> news:299AA62B-188A-4DB3-BD8E-E06E53FFD35E@.microsoft.com...
>|||I wouldn't say 5 years make you a newbie, Enric ;-).
Yes, an expert programmer can of course interpret the information, provided
enough time and
documentation. And indeed, that has been done. The product is called "Micros
oft SQL Server" ;-).
My point is that to my knowledge, no-one outside MS has ventured this path,
probably not enough
possible payback compared to the time needed to invest. And one should also
consider that MS can and
does change things in the file formats between versions.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Enric" <Enric@.discussions.microsoft.com> wrote in message
news:31798C46-4BB6-441C-A0D7-E5F992C98AA7@.microsoft.com...
> Tibor,
> At first I must say that I am just a newbie (only six years with SQL) and
in
> my humble point of view if my son (5 years) is be able to open doing
> double-click
> above MDF and read the data, so this way I was wondering, what would do a
> expert programmer with that same file?
> Regards,
> "Tibor Karaszi" wrote:
>|||Basically, what you are proposing is commonly refrred to as hacking ;) It
could be an intersting excercise, I suppose, but who has the time? What you
are talking about is no different than using a byte level file editor.
Anything is possible, but do you REALLY understand what happens when you
start twiddling your bits at that level?
Bob Castleman
DBA Poseur
"Enric" <Enric@.discussions.microsoft.com> wrote in message
news:31798C46-4BB6-441C-A0D7-E5F992C98AA7@.microsoft.com...
> Tibor,
> At first I must say that I am just a newbie (only six years with SQL) and
> in
> my humble point of view if my son (5 years) is be able to open doing
> double-click
> above MDF and read the data, so this way I was wondering, what would do a
> expert programmer with that same file?
> Regards,
> "Tibor Karaszi" wrote:
>