|
Hello CP,
I'm messing around with SSIS and have run into a problem when trying to get the DataReader Source to work.
The problem is simple;
I'm trying to set the SqlCommand property to point to a stored procedure:
EXECUTE [dbo].[spMyProc] '20110101', '20110131'
The problem does not lie in calling the SP but rather with something in the SP.
My SP makes use of Temp table and it seems it cannot find it:
Error at Data Flow Taks[DataReader Source[1]]: System.Data.SqlClient.SqlException: Invalid object name '#tmpCalcTable'.
at System.Data.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
The Stored Procedure creates a temporary table and later deletes it, but it seems it's either not doing that or can't access the it.
I've tried making the temp table global by using a double hash (##) instead of one but without luck.
Does anyone have an idea how I can fix this?
|
|
|
|
|
|
The error you're getting back from SQL suggests that there's a temp table being referenced that is either not created, is dropped before it is called, or is otherwise orphaned somehow in the code. Can you run the SP through code (in SSMS) with the appropriate input parameters and it will execute correctly? If so, then it's something in your .NET code or some other setting/parameter within the SSIS package. If not, can you post your TSQL code? Thanks
modified on Friday, June 24, 2011 8:22 AM
|
|
|
|
|
It works fine in the Server manager.
I've got a workaround though, create the temp table once (outside of the query) and truncate it at the start of the query. This also means I'm no longer dropping it.
It's a strange little bug though.
The first rule of CListCtrl is you do not talk about CListCtrl - kornman
|
|
|
|
|
Ok, cool. Glad to assist if you should need further assistance.
|
|
|
|
|
This may be a stupid question but is there a way that I can a statement in mySQL.
I need to change how the SHOW statement works.
I realize I could do this with a different function of my own but I am needing to use the existing function if possible.
Any help is appreciated.
Humble Programmer
|
|
|
|
|
What excately is your question?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
Can I change what the SHOW statement does....
For example it runs a certain SQL statement that is defined somewhere in mySQL.
I wonder can I change that statement to do something different or maybe make it call a different statement.
Humble Programmer
|
|
|
|
|
It's an internal command - you can't modify the behaviour of the internal commands otherwise you could end up breaking other functionality that relied on that behaviour.
|
|
|
|
|
Could I maybe overload it with another parm?
Humble Programmer
|
|
|
|
|
|
Do you have the source-code of the function?
There's your answer
Bastard Programmer from Hell
|
|
|
|
|
Hello CP,
I've set up a job to perform a stored procedure at a given time, nothing special.
In the step (which triggers the SP) I've specified the output file in the 'advanced' section.
The output in the file is the execution time (moment) and the 'select' form the SP.
My problem is the output file format.
Does anyone know how to set it to CSV or perhaps another solution?
|
|
|
|
|
Is the goal to get the data output from the stored procedure into a CSV file? That is not possible (in a useable format anyway) in the job step's advanced properties. Specifying a file path and file name there allows SQL to save the detailed information regarding the job's execution to a text file. To get your stored proc output data into a CSV file, a different coding approach is needed (like SSIS, BCP, or the like). Or, did you actually want to get the detailed information about the job running into a CSV file?
Apologies if I've misunderstood your question.
modified on Thursday, June 23, 2011 5:41 PM
|
|
|
|
|
You understood it perfectly.
I had been looking at BCP and tried to format it correctly (from the command prompt, not sqlcmd), but it bugged on my nested stored procedures.
Haven't looked at SSIS yet, gonna do that now.
But I'm getting off-topic.
You answered my question.
|
|
|
|
|
Hi all,
Is there any difference between the following two sets of queries?
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
a.RESIDSTS, d.ROOM_DESC, d.ROOM_PHONE
from SMASTER a
join NMASTER b on a.ID_NUM = b.ID_NUM
join BMASTER c on a.ID_NUM = c.ID_NUM
join RMASTER d on a.LOC_CDE = d.LOC_CDE and a.BLDG_CDE = d.BLDG_CDE and a.ROOM_CDE = d.ROOM_CDE
where LOWER(b.LAST_NAME) like '%ram%'
and a.RESIDSTS = 'R' and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))
UNION
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
a.RESIDSTS as STATUS, '' , ''
from SMASTER a
join NMASTER b on a.ID_NUM = b.ID_NUM
join BMASTER c on a.ID_NUM = c.ID_NUM
join RMASTER d on a.ID_NUM = a.ID_NUM
where LOWER(b.LAST_NAME) like '%ram%'
and a.RESIDSTS <> 'R' and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))
and
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
a.RESIDSTS, d.ROOM_DESC, d.ROOM_PHONE
from SMASTER a
join NMASTER b on a.ID_NUM = b.ID_NUM
join BMASTER c on a.ID_NUM = c.ID_NUM
join RMASTER d on a.LOC_CDE = d.LOC_CDE and a.BLDG_CDE = d.BLDG_CDE and a.ROOM_CDE = d.ROOM_CDE
where LOWER(b.LAST_NAME) like '%ram%'
and (a.RESIDSTS = 'R' or a.RESIDSTS <> 'R') and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))
well in one there is "UNION" used but will there any difference in the output or are these both queries same as per the output is concered?
suchita
|
|
|
|
|
Yes, those should give the same result. They might be a bit different sorted I think, but in the end the same data should be in the output.
Edit: I oversaw one small thing. The second query in the union doesn't return the values of d.ROOM_DESC, d.ROOM_PHONE, but rather two empty strings in those columns. In your combined query these columns will be filled.
|
|
|
|
|
|
Hi all,
I have two sets of query which if run alone, runs without any errors but when i try to use UNION between these two queries, it gave me error like this:
Error converting data type varchar to numeric.
The sql queries are
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
a.RESIDSTS, d.ROOM_DESC, d.ROOM_PHONE
from SMASTER a
join NMASTER b on a.ID_NUM = b.ID_NUM
join BMASTER c on a.ID_NUM = c.ID_NUM
join RMASTER d on a.LOC_CDE = d.LOC_CDE and a.BLDG_CDE = d.BLDG_CDE and a.ROOM_CDE = d.ROOM_CDE
where LOWER(b.LAST_NAME) like '%ram%'
and a.RESIDSTS = 'R' and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))
UNION
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
a.RESIDSTS as STATUS, '' , ''
from SMASTER a
join NMASTER b on a.ID_NUM = b.ID_NUM
join BMASTER c on a.ID_NUM = c.ID_NUM
join RMASTER d on a.ID_NUM = a.ID_NUM
where LOWER(b.LAST_NAME) like '%ram%'
and a.RESIDSTS <> 'R' and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))
but when i run
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
a.RESIDSTS, d.ROOM_DESC, d.ROOM_PHONE
from SMASTER a
join NMASTER b on a.ID_NUM = b.ID_NUM
join BMASTER c on a.ID_NUM = c.ID_NUM
join RMASTER d on a.LOC_CDE = d.LOC_CDE and a.BLDG_CDE = d.BLDG_CDE and a.ROOM_CDE = d.ROOM_CDE
where LOWER(b.LAST_NAME) like '%ram%'
and a.RESIDSTS = 'R' and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))
or
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
a.RESIDSTS as STATUS, '' , ''
from SMASTER a
join NMASTER b on a.ID_NUM = b.ID_NUM
join BMASTER c on a.ID_NUM = c.ID_NUM
join RMASTER d on a.ID_NUM = a.ID_NUM
where LOWER(b.LAST_NAME) like '%ram%'
and a.RESIDSTS <> 'R' and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))
it runs.
Can anyone help me solve this out?
suchita
|
|
|
|
|
I figure out that if I take
d.ROOM_PHONE out from the code, it ran well. But why it gave error in there ? what if I need to keep that piece and get the result without error?
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
a.RESIDSTS, d.ROOM_DESC, d.ROOM_PHONE
from SMASTER a
join NMASTER b on a.ID_NUM = b.ID_NUM
join BMASTER c on a.ID_NUM = c.ID_NUM
join RMASTER d on a.LOC_CDE = d.LOC_CDE and a.BLDG_CDE = d.BLDG_CDE and a.ROOM_CDE = d.ROOM_CDE
where LOWER(b.LAST_NAME) like '%ram%'
and a.RESIDSTS = 'R' and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))
UNION
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
a.RESIDSTS as STATUS, '' ,''
from SMASTER a
join NMASTER b on a.ID_NUM = b.ID_NUM
join BMASTER c on a.ID_NUM = c.ID_NUM
join RMASTER d on a.ID_NUM = a.ID_NUM
where LOWER(b.LAST_NAME) like '%ram%'
and a.RESIDSTS <> 'R' and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))
suchita
|
|
|
|
|
What is the type for the column ROOM_PHONE. From your error, I bet it is numeric. In the second select change the final '' column to be to_number(NULL). That might make a difference.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
I have searched on the net for an answer to this, and in Code Project and I can't seem to find a definite answer. Plenty about data types in tables but little or nothing about stored procedure parameters.
I am converting an SQL Server based program to run with MySql and one of the tables accessed by a procedure (routine) has a field that is the char type that is used as one the parameter fields. In procedures in SQL Server there is the SqlDBType.Char but there does not appear to be any equivalent of that in MySql (5.5)
Should I just use VarChar?
|
|
|
|
|
char(10) will deliver a string 10 characters long, padded with spaces if there is no data, varchar will deliver just the data. You need to asses whether this change will affect your output. I only use char for single character fields.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for responding. I understand the differences between char and varchar but what I am trying to find out is what type I should give a parameter.
I have a char(1) field that accepts data in a routine. In an SQL Server stored procedure I would give this the SqlDBType.Char type. There seems to be no equivalent in MySQL so my question was do I just use MySqlDBType.VarChar?
|
|
|
|
|
I think you have to use a varchar, I have no experience with MySQL, but you need to be aware that the field could end up as a null or an empty string which it cannot do if it were a char. So your client needs to be aware of this and deal with it. Reality is that you are probably using the field as a flag and it wall ALWAYS have a value.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|