# Powershell SQL stored procedure with return\_value

**URL:** <https://forums.powershell.org/t/powershell-sql-stored-procedure-with-return-value/12282>\
**Category:** PowerShell Help\
**Created:** [March 28, 2019, 6:51am UTC](https://forums.powershell.org/t/powershell-sql-stored-procedure-with-return-value/12282 "2019-03-28T06:51:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdevogt](https://avatars.discourse-cdn.com/v4/letter/b/eada6e/32.png) [@bdevogt](https://forums.powershell.org/u/bdevogt)\
**Post date:** [March 28, 2019, 6:51am UTC](https://forums.powershell.org/t/powershell-sql-stored-procedure-with-return-value/12282/1 "2019-03-28T06:51:35Z")

</div>

I’ve been stuck with this issue,

I start a stored function in sql that gives me a returned value,

When I use this value in a IF statement I can compare it against another value,

Now I want to store is in an other $var but now it becomes a ‘table’ and I cannot get the value out

if i do

[pre]

PS C:\Users\bdv\> $dataset.Tables

Return Value ------------ 980

[/pre]

i get the following values.

How can I get only the 980 returned as a string ?

if i use the out-string I get 'table' in there

---

<div class="post-metadata">

**Author:** ![bdevogt](https://avatars.discourse-cdn.com/v4/letter/b/eada6e/32.png) [@bdevogt](https://forums.powershell.org/u/bdevogt)\
**Post date:** [March 28, 2019, 7:20am UTC](https://forums.powershell.org/t/powershell-sql-stored-procedure-with-return-value/12282/2 "2019-03-28T07:20:32Z")

</div>

Well after some more testing I have the result I want,

[pre]

$dataset.Tables.‘return value’  
[/pre]

I’ll leave it here for if someone needs it

---

<div class="post-metadata">

**Author:** ![postanote](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@postanote](https://forums.powershell.org/u/postanote)\
**Post date:** [March 28, 2019, 5:41pm UTC](https://forums.powershell.org/t/powershell-sql-stored-procedure-with-return-value/12282/3 "2019-03-28T17:41:39Z")

</div>

Yeppers, spaces and special characters, in field names, file names, etc., are bad, just bad.  
So, you end up doing what you had to do. This sort of thing is notorious all over XML and HTML files, pages and datasets.  
So, what you had to do is really a common thing.

---

<div class="post-metadata">

**Author:** ![powershellmichael](https://avatars.discourse-cdn.com/v4/letter/p/87869e/32.png) [@powershellmichael](https://forums.powershell.org/u/powershellmichael)\
**Post date:** [March 29, 2019, 9:57pm UTC](https://forums.powershell.org/t/powershell-sql-stored-procedure-with-return-value/12282/4 "2019-03-29T21:57:44Z")

</div>

Hi There!

My colleague had the same issues. Yes you can $var.‘property name’ to specify properties that have spaces. However I would defiantly recommend perform a SELECT AS in the stored proc to simplify the PowerShell.

PS. To call variables with spaces ${variable name}. 🙂

PSM

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:33pm UTC](https://forums.powershell.org/t/powershell-sql-stored-procedure-with-return-value/12282/5 "2024-05-16T20:33:06Z")

</div>

Closed on May 16, 2024, 8:33pm UTC


