New-DbaSqlParameter set varchar parameter value to Default instead '' using Invoke-DbaQuery #9452
Closed
mchuc7719
started this conversation in
Contributors
Replies: 1 comment
-
After some tests, due in powershell '' is not equal ' ', setting with -value to ' ', works for me |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Please Any help will be appreciated, this is my issue
My code:
$sFullName = New-DbaSqlParameter -ParameterName "@sFullName" -SqlDbType VarChar -Size 60 -Direction Input -Value ""
or
$sFullName = New-DbaSqlParameter -ParameterName "@sFullName" -SqlDbType VarChar -Size 60 -Direction Input -Value ''
Invoke-DbaQuery -SqlInstance 'xxx,0005' -Database 'xxxx' -Query 'dbo.spAddUserWithRole2' -SqlParameter @($iResult, $sResult, $sLogin, $sFullName, $sRole) -CommandType StoredProcedure
Throws this message "WARNING: [22:37:56][Invoke-DbaQuery] [sqlqas,2705] Failed during execution | Procedure or function 'spAddUserWithRole2' expects parameter '@sFullName', which was not supplied."
Inspectig the code using sql server profiler, this is execution in the server, the parameter @sFullName is set to "Default" instead of "" or ''
declare @p1 int
set @p1=NULL
declare @p2 nvarchar(200)
set @p2=NULL
exec dbo.spAddUserWithRole2 @iResult=@p1 output,@sresult=@p2 output,@slogin='VDI-MMykoo',@sFullName=default,@Srole='drViewCcInfooooo'
select @p1, @p2
Please, how to set "" or '' parameter New-DbaSqlParameter when the code runs, get:
declare @p1 int
set @p1=NULL
declare @p2 nvarchar(200)
set @p2=NULL
exec dbo.spAddUserWithRole2 @iResult=@p1 output,@sresult=@p2 output,@slogin='VDI-MMykoo',@sFullName='',@Srole='drViewCcInfooooo'
select @p1, @p2
Any help will be appreciated
Regards.
Beta Was this translation helpful? Give feedback.
All reactions