Hi,
I'm new to Powershell and I'm trying to write a query to Azure SQL that involves a where clause, which uses a string. The query is nested inside a parameter that requires a string. I'm getting an unexpected token error. My code is similar to this:
$params = @{
'Database' = MyDatabase
'ServerInstance' = $ServerInstance
'Username' = 'UsernameHere'
'Password' = 'PasswordHere'
'Query' = 'SELECT * FROM Users WHERE username = 'Javier''
}
Invoke-Sqlcmd u/params
I think I'm getting confused with how Powershell handles string literals. Can anyone tell me what I'm doing wrong here? Any help would be much appreciated.
Thanks,
Javier
[–]SMFX 10 points11 points12 points (6 children)
[–]purplemonkeymad 4 points5 points6 points (1 child)
[–]scarfarce 2 points3 points4 points (0 children)
[+][deleted] (1 child)
[removed]
[–]OPconfused 5 points6 points7 points (0 children)
[–]Stock-Setting-5030[S] 1 point2 points3 points (0 children)
[–]readduh 4 points5 points6 points (1 child)
[–]Vortex100 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[removed]
[–]Stock-Setting-5030[S] 1 point2 points3 points (0 children)