Showing posts with label guys. Show all posts
Showing posts with label guys. Show all posts

Friday, March 23, 2012

PC shutdown while printing from report

Hi all,

I m new to SQL Server Reporting Service. I hope you guys can find some solutions to my problem.

When i try to print from report's toolbar, my pc suddenly restart. and I thought it may be some printer driver

conflict, and check my event logs also. but i can't find any error or warning message there at all.

Can anybody knows the source of the problem and solution.

Regards,
gakuci

Any luck with this? Are you aware of any special anti virus/spy software that could be causing this?

|||

Looks like this is a driver problem. Try this KB article

http://support.microsoft.com/kb/935843

Tuesday, March 20, 2012

Patient query... Pls help

Hi Guys,

I have got a table of patients where each patient has got a unique patient number.There are different services which a patient can undertake such as resthome, dementia etc.

Here is the sample data

Service patientNo startDate EndDate

resthome 12 01/04/2003 03/05/2003

resthome 13 12/9/2004 13/10/2006

Dementia 44 12/08/2002 13/01/2004

dementia 12 05/05/2003 06/12/2006

................................. ............ ................................

Each patient has got a start date when he started undertaking that service and end date when the service finished .

Now I need to count total patients for each catagory but here is the main issue....

A patient can move from one servcice to another but cant be in two services at the same time and I need to count the most recent service which the patient is currently enrolled in..

How do I do that?

Pls help me guys as you have always done:wow:

Thanks

This will get you a list of the most recent service by startdate that the patient was enrolled in

Code Snippet

select ps.*

from patientservice ps

inner join

(select patientno, max(startdate) as startdate

from patientservices

group by patientno) z

on z.patientno = ps.patientno

and z.startdate = ps.startdate

|||

Hi Cam

Thanks for your help

I ran this query but I dont know why is it giving me an error saying:

Invalid column name: startdate

Thanks

Saturday, February 25, 2012

Passing text parameters

Hello Guys,

create procedure spsCheckMsg(
@.sTyp as varchar(100),
@.tMsg as text) as
select @.tMsg = md_body from tbl_msgdef where msgname = @.sTyp

Parameters of the type text can be used in stored procedures. So I wanted to get the text data (md_body) by a select statement and pass it to the parameter @.tMsg. This code doesn't work. I always get the message "The assignment operation can't have a text datatype as argument" which refers to the select statement.

Does anyone have a solution for this?Howdy

If I have understood correctly, try :

-------------------
Create Procedure spsCheckMsg
(
@.sTyp as varchar(1000),
@.tMsg as varchar(1000)
)

AS

set @.tMsg =
( select convert(varchar(1000),md_body) from tbl_msgdef where msgname = @.sTyp )
-------------------

Cheers,

SG

Monday, February 20, 2012

Passing table name as parameter in stored procedure

Hey guys,
Im trying to create a store procedure that will perform certain duties on a
given table. The table name will be passed as a parameter.
The problem is I am not allowed to use the parameter as a tablename, so the
following queries are rejected:
SELECT #temp.[id] as SForceID, @.Table.[id] as OppID INTO #Temp2 FROM @.Table
LEFT OUTER JOIN #Temp ON #Temp.[id] = @.Table.[id]
DELETE FROM @.Table WHERE [id] IN (SELECT OppID FROM #Temp2 WHERE SForceID IS
NULL)
How do I achieve this? Is it doable? Is it perhaps a limitation?
Thank you in advance.Juan,
It is doable using dynamic sql but you may need to think about the
design.These are well discussed in the below article by Erland Sommarskog:
The Curse and Blessings of Dynamic SQL
http://www.algonet.se/~sommar/dynamic_sql.html#Dyn_table
Dinesh.
SQL Server FAQ at
http://www.tkdinesh.com
"Juan Romero" <juanja01@.optonline.net> wrote in message
news:%23M9Mi2iUDHA.1916@.TK2MSFTNGP12.phx.gbl...
> Hey guys,
> Im trying to create a store procedure that will perform certain duties on
a
> given table. The table name will be passed as a parameter.
> The problem is I am not allowed to use the parameter as a tablename, so
the
> following queries are rejected:
> SELECT #temp.[id] as SForceID, @.Table.[id] as OppID INTO #Temp2 FROM
@.Table
> LEFT OUTER JOIN #Temp ON #Temp.[id] = @.Table.[id]
> DELETE FROM @.Table WHERE [id] IN (SELECT OppID FROM #Temp2 WHERE SForceID
IS
> NULL)
> How do I achieve this? Is it doable? Is it perhaps a limitation?
> Thank you in advance.
>