Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to obtain value from extended stored procedure

Author  Topic 

Wodzu
Yak Posting Veteran

58 Posts

Posted - 2007-12-30 : 07:27:20
Hello.

I guess this question aslo concerns regular stored procedures.

Let say I perfrom such command on the SQL Server:

exec master..MyProcedure

This procedure returns a row with 3 values such as:

Result ResultMSG Handle
0 It is ok. 25

Now I would like to assign those values to a variables or insert them to the table, but I am having problem with constructing a proper Query.

for example if I create a temporary table:

CREATE TABLE dbo.#tmpTable
(
tmpResult varchar(255),
tmpResultMSG varchar(255),
tmpHandle varchar(255)
)



And then:

INSERT INTO dbo.#tmpTable
exec master..MyProcedure


I get error that the result would be truncated. (I am sure that all the returned values from the procedure are the character strings type, thats why I've constructed tmpTable with varchars.)

How to trunc returned values to avoid such error?
And how to assign a return value to a variable?
Such command doesn't work:


DECLARE @MyVariavle varchar(255)
SELECT @MyVariable = Result FROM exec master..MyProcedure


I just don't know how to construct a proper command ;)


Thanks for your time.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-12-30 : 07:33:46
quote:
I get error that the result would be truncated.

Increase the length of the column in your temp table. Also check the stored procedure, for the max possible length of returned records.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Wodzu
Yak Posting Veteran

58 Posts

Posted - 2007-12-30 : 08:01:37
Increasing the length doesn't help and I don't know the max possible length of returned records.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-12-30 : 08:18:04
quote:
Originally posted by Wodzu

Increasing the length doesn't help and I don't know the max possible length of returned records.


can't you check the stored procedure ?

or just use varchar(max)


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Wodzu
Yak Posting Veteran

58 Posts

Posted - 2007-12-30 : 10:02:46
How can I check the length of returned data by extended stored procedure? It is bit different than stored procedure since it is runned from DLL.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-12-30 : 10:15:47
take a look at the source ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Wodzu
Yak Posting Veteran

58 Posts

Posted - 2007-12-31 : 03:44:10
at the source of compiled DLL? could be hard :P

Thanks for the 'max' tip it helped ;)
Go to Top of Page
   

- Advertisement -