Hi ,I am using invoke-sqlcmd cmdlet to fetch the data initially then use that data to fetch other details (looping through these details)code:Import-module sqlpls$instance = <servername>$server = New-Object Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instance$values = Invoke-Sqlcmd -Query "select id from table1 " | Out-String#Values variable is array of ids, below code is to loop through the numbers$Values |foreach-object {$value = $_ | out-string$name = Invoke-Sqlcmd -Query "select name from table1 where id='$value'" | Out-Stringwrite-host "name for id $value is"write-host $name}Here in the above code , write-host $name displaying blank space instead of name for each id.Please provide your suggestions to correct the code.Thanks in advance.Thanks,Prathap SV.
↧