You are viewing limited content. For full access, please sign in.

Question

Question

assistance with SQL query

asked on January 22, 2016

I feel like the organization I'm working for has a table for everything, but nothing is joined :-) :-)  Logically, I would like to think that the medical record number (MRN) - which is unique for each patient would be somewhere with patient last name and first name, but nope!!  So!! Below is the query and it works fine against the database and it works fine in workflow IF I give it a specific MRN to check.  Once I update it to the ? so that it will look up based on the number supplied by the user, I get no results, but no error message either.  Any thoughts for those of you that know queries and SQL much better than me???  I have tried updating the "parameter" to string/default/integer; tried putting in quotes - all the tricks people have been teaching me along the way :-)

 

Thank you for your assistance!!

 

SELECT
       substring(pa.med_rec_nbr, patindex('%[^0]%', pa.med_rec_nbr +'.'), LEN(pa.med_rec_nbr)) as [med_rec_nbr],
       pe.last_name,
       pe.First_name
FROM LSIDW_DATALAKE.dbo.patient pa WITH(NOLOCK)
INNER JOIN LSIDW_DATALAKE.dbo.person pe WITH(NOLOCK)
ON PE.Person_id = PA.Person_id
where med_rec_nbr = ?
 

 

**Note - I have also done it without the "locking" info.  Our DBA wanted it in there because these tables are constantly being updated.

0 0

Replies

replied on January 22, 2016

where are you looking for errors? log files are our best friends. seems like parameter that you are providing is not what sql is expecting. 

1 0
replied on January 22, 2016

I get that, but the logs I've checked aren't telling me anything. I bit more information would be helpful :-)  I've checked information on both the wf server and sql server and haven't seen anything related to this issue.  I will say I might not be checking in the right spot...blush

0 0
replied on January 22, 2016

I'm assuming you've tracked the token value going in and it's what you'd expect, so next I'd check the instance details to make sure there were not errors or warnings.

You can look into ODBC tracing on the WF server to see what the query is at that point (assuming you are using an ODBC data source) or SQL Profiler to see what the query looks like when it hits SQL server.

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.