Showing posts with label execute. Show all posts
Showing posts with label execute. Show all posts

Wednesday, March 28, 2012

How to get the Task name inside your custom task

I have a custom task, and during the Execute method I'd like to get hold of the task's name. It appears that this is held on the TaskHost, but I cannot see how to obtain that from within the task itself. Anyone got any ideas?

Thanks

DarrenSystem::TaskName|||or better still, System::SourceName Smile|||Kirk

really?

You go out to the variables collection to get your own name?

Could you explain the reasoning?
Allan|||Hello KirkHaselden@.discussions.microsoft.com, Thanks Kirk. I saw that the property only appears on the TaskHost but thought it a little long winded to get your own name. Thanks Allan
> Well, yes. Since Name is on the TaskHost, it's not available anywhere
> else.
> K|||Well, yes. Since Name is on the TaskHost, it's not available anywhere else.
K|||Jamie.

I think SourceName is only added to the Variables list if your package has Event Handlers.
Allan

How to get the results when executing extended stored procedures.

Hi. Does anyone know how to display the results if i execute "xp_fixeddrives, xp_availablemedia and xp_subdirs" commands with VC++ 6.0? I can't obtained the results using Recordset class. Can someone help me? Thank you.

|_N_T_|

See if the following works for you:

create table #FreeSpace(

Drive char(1),

MB_Free int)

insert into #FreeSpace exec xp_fixeddrives

select * from #freespace

|||

For some reason, that didn't work for me but this did:

Declare @.FreeSpace TABLE (

Drive char(1),

MB_Free int)

insert into @.FreeSpace exec xp_fixeddrives

select * from @.freespace

Go figure...

How to get the results when executing extended stored procedures.

Hi. Does anyone know how to display the results if i execute "xp_fixeddrives, xp_availablemedia and xp_subdirs" commands with VC++ 6.0? I can't obtained the results using Recordset class. Can someone help me? Thank you.

|_N_T_|

See if the following works for you:

create table #FreeSpace(

Drive char(1),

MB_Free int)

insert into #FreeSpace exec xp_fixeddrives

select * from #freespace

|||

For some reason, that didn't work for me but this did:

Declare @.FreeSpace TABLE (

Drive char(1),

MB_Free int)

insert into @.FreeSpace exec xp_fixeddrives

select * from @.freespace

Go figure...

Monday, March 26, 2012

How to get the Out put from the Stored Procedure

Hi Every body,

i am trying to execute a stored procedure and want the out put to be passed to another database table.

I tried to create a OLEDB Source and gave the Exec Procedure Statement. I tried to see the preview and able to see the out put results. But when i am clicking on the columns to map to the destination i am not able to see the metadata.

Can you guys pls let me know how to do this.

thanx in advance..

Regards,

Dev

If your stored procedure is complex, you may need to insert a SELECT that returns the expected columns as the first statement in your stored proc. You can add a WHERE clause like WHERE 0 = 1 to ensure that no rows are returned.

When you are using a multiple operation stored procedures, a lot of tools (SSIS included) use the first resultset to determine the metadata for the stored proc. You can add a "dummy" resultset to ensure that it gets the right metadata.

|||

Hi,

I really appreciate your early reply. i will give a try and let you know the out come.

Thanx & Regards,

Dev

|||

hi,

can you pls let me know how to write a dummy SQL Statement for the out put, as i am not able to get the table dosent existsin the Database

Dev

|||

Hi,

I tried a sample like this

1. Created a SP

ALTERprocedure [dbo].[usp_test]

as

begin

declare @.error_number int,

@.row_count int

CREATETABLE #temp (

test1 varchar(50),

test2 varchar(50)

)

SELECT*from #temp where 0=1;

end

2. Added OLEDB SOURCE -- > added as a SQL Command EXEC usp_test.

3. now when i click on the metadata it's not showing up the coloumns

Please suggest what i am doing wrong

Regds,

Dev

|||

SELECT '' AS mystringcolumn, 1 as myintcolumn WHERE 1 = 0

The columns here need to match your expected resultset, both in name and type.

|||You need to put the select before the create table. See my post above.|||

Add this t-sql at the end of the storedproc

declare @.sql varchar (50 )

selelct @.sql='select * from #temp where 0=1'

Exec (@.sql)

give it a try

Monday, March 19, 2012

How to get source by execution oracle sp using ref cursor

Hi,

I need to get recordset returned by oracle sp in execute sql task to process futher in For Each Loop container and on same lines i want to use oracle sp for extraction data in Data Flow Task. Could anybody suggest if it how we could do it in SSIS?

All suggestions will be highly appreciated.

Thanks,

Lalit

You should be able to do this. Is there a specific problem you are encountering?|||There is no variable type in SSIS that maps to refcursor type in Oracle. I don't think a variable of type object can be used for this either. So I guess you cannot execute Oracle SP using Execute SQL task to get the recordset.

Monday, March 12, 2012

How to get results from a storedprocedure

To all,
I looked at the MS-SQL pubs sample database and execute the examplestored procedure reptq2 and I got 17 results set back. Where can I findan example using Visual Studio DataGrid or any means to get all theseresults from this SP.
Thanks,

Frank
Try this link for a two part tutorial in C# that can return 100 rows. Hope this helps.
http://www.dotnetjunkies.com/Tutorial/EA868776-D71E-448A-BC23-B64B871F967F.dcik|||I just remembered that Stored proc in Pubs used COMPUTE which is a none relational aggregate function in SQL Server so you have to make the code in the link work with the stored proc and Pubs. Hope this helps.|||Here's the same data from that stored procedure, in a single result set... Avoid COMPUTE BY.

use pubs
go

select
t.type,
t.pub_id,
t.title_id,
ta.au_ord,
Name = substring (a.au_lname, 1,15),
t.ytd_sales,
avg_pub.salessum as avg_pub,
avg_pub_type.salessum as avg_pub_type
from titles t
join titleauthor ta on t.title_id = ta.title_id
join authors a on a.au_id = ta.au_id
join
(
select
t.pub_id,
avg(t.ytd_sales)
from titles t
join titleauthor ta on t.title_id = ta.title_id
where
t.pub_id is NOT NULL
group by
t.pub_id
) avg_pub (pub_id, salessum) on avg_pub.pub_id = t.pub_id
join
(
select
t.pub_id,
t.type,
avg(t.ytd_sales)
from titles t
join titleauthor ta on t.title_id = ta.title_id
where
t.pub_id is NOT NULL
group by
t.pub_id,
t.type
) avg_pub_type (pub_id, type, salessum) on avg_pub_type.pub_id = t.pub_id and avg_pub_type.type = t.type
where
t.pub_id is NOT NULL
order by
t.type,
t.pub_id

Sunday, February 19, 2012

How to get Extended error information from stored procedure

Hi

I have a stored procedure in SQL server 2005. It works fine when I execute it from the Management Studio.
But when executing it from ASP.NET code like this:

.... Of course more code is executed before this call ....
int retVal =this.odbcCreateDataBaseCommand.ExecuteNonQuery();

retVal is -1. But -1 doesn't really tell me what the problem is?

Is there anyway to get extended error information so I can figure out whats going wrong?

(The stored procedure was working fine in SQL server 2000 before I upgraded to SQL server 2005. I use .NET Framework 1.1 and ODBC Sql Native Client to access the 2005 server.)

Regards

Tomas

My own thought...
Maybe .NET Framework 1.1 and SQL Server 2005 and ODBC SQL Native Client have poor compatibility...

Anyone out there with experience/insight?

Thanks
Tomas