Showing posts with label knows. Show all posts
Showing posts with label knows. Show all posts

Thursday, March 22, 2012

Calling Joe Celko (or anyone else that knows)

(I think you were the one that posted this)
Someone asked how to count two different things in one select statement.
I had never seen it before and I was deeply impressed.
A coworker is asking me how to do two different counts grouped by different
things...
Some column called IVP can be 1, 0 or NULL. He wants to execute a statement
that generates a one-line result set of counts that looks like this
| 1Count | 0Count | NullCount |
| 47 | 23 | 5 |
Something like this:
SELECT
COUNT([?]) AS 1Count,
COUNT([?]) AS 0Count,
COUNT([?]) AS NullCount
FROM TheTable
-- GROUP BY [?] -- is this even required?
Peace & happy computing,
Mike Labosh, MCSD
"When you kill a man, you're a murderer.
Kill many, and you're a conqueror.
Kill them all and you're a god." -- Dave MustaneSELECT
SUM (CASE WHEN foo = 0 THEN 1 ELSE 0 END) AS tally_0,
SUM (CASE WHEN foo = 1 THEN 1 ELSE 0 END) AS tally_1,
SUM (CASE WHEN foo IS NULL THEN 1 ELSE 0 END) AS tally_null,
FROM TheTable;|||Try:
select
sum(case when c1 = 1 then 1 else 0 end) as count_1,
sum(case when c1 = 0 then 1 else 0 end) as count_0,
sum(case when c1 is null then 1 else 0 end) as count_null
from
t1
AMB
"Mike Labosh" wrote:

> (I think you were the one that posted this)
> Someone asked how to count two different things in one select statement.
> I had never seen it before and I was deeply impressed.
> A coworker is asking me how to do two different counts grouped by differen
t
> things...
> Some column called IVP can be 1, 0 or NULL. He wants to execute a stateme
nt
> that generates a one-line result set of counts that looks like this
> | 1Count | 0Count | NullCount |
> | 47 | 23 | 5 |
> Something like this:
> SELECT
> COUNT([?]) AS 1Count,
> COUNT([?]) AS 0Count,
> COUNT([?]) AS NullCount
> FROM TheTable
> -- GROUP BY [?] -- is this even required?
> --
> Peace & happy computing,
> Mike Labosh, MCSD
> "When you kill a man, you're a murderer.
> Kill many, and you're a conqueror.
> Kill them all and you're a god." -- Dave Mustane
>
>|||Thanks everyone; the coworker was quite impressed.
Peace & happy computing,
Mike Labosh, MCSD
"When you kill a man, you're a murderer.
Kill many, and you're a conquerer.
Kill them all and you're a god." -- Dave Mustane

Sunday, March 11, 2012

calling a function on a different server?

I was wondering if anyone knows the best way to call a function that is located in database on a different server then the database that is calling the function. Is it possible to do this with out linked servers? I am running SQL Server 2000. Any help in this matter would be greatly appreciated.

You can't use four part names to run function from a different server. However, You can use OpenQuery for Linkedserver to do the same

Select * from OpenQuery(LinkedServer , 'Select MyRemoteDB.dbo.udfFunction ( ''Parameter'' )')

Wednesday, March 7, 2012

call report directly in pdf

hi there,

i want to call a report directly in pdf not in rdl.

anyone knows this?

What do you mean 'call it'? Do you mean you want the report to display in PDF by default?
I think this is just a matter of calling it with the right paramters. Ibelieve if you look at the reporting services books online there issomething about passing what format the report is displayed in when itis called.
I am assuming you will have a link from someplace (application, email, etc) to this report?
|||

I just sent out an email concerning this - i hope this helps u out...

This is just an FYI for the Microsoft Reports:

We can suppress the parameters and exporting functionality of Microsoft reports via the command line.

We can hide parameters by appending &rc:Parameters=false to the url as shown below

/ReportServer?/samplereports/abc&rs:Command=Render&rs:Format=HTML4.0&rc:Parameters=false

And we can change the format by appending a format line as shown below:

We can change the format to PDF,Excel or any of the other supported file types.

/ReportServer?/samplereports/abc&rs:Command=Render&rs:Format=HTML4.0&rc:Parameters=false

Call As400 JobQ from SQL

I'm wondering if anyone knows of way you can call a certain jobq in the as400 and find out if a job is done running. So that an additional job in SQL can start!
Thanks for your help in advancewhat kind of job do you want to call?
from where do you want to call the job?|||sql's are running on as/400 or not?