[HELP] Invoke-Sqlcmd

Welcome Forums General PowerShell Q&A [HELP] Invoke-Sqlcmd

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
1 year, 11 months ago.

  • Author
    Posts
  • #59941

    Participant
    Points: 0
    Rank: Member

    Hey all,

    I'm having an issue getting my command the way I desire.

    The working command I am using is as follows: 'SELECT [Document Type], Type, [Document No_], No_, Description FROM dbo.[company.here] WHERE [Document Type] = 1 AND Type = 2 AND [Document No_] = 'WSO-0108111"

    I need to have the command have it like this the followng but I don't know how to get it to work with a variable:

    The working command I am using is as follows: 'SELECT [Document Type], Type, [Document No_], No_, Description FROM dbo.[company.here] WHERE [Document Type] = 1 AND Type = 2 AND [Document No_] = '$wso"

    $wso = Whatever the user inputs.

    In order for the command to properly work, it needs to be surrounded by the quotes '$wso"

  • #59955

    Participant
    Points: 154
    Helping Hand
    Rank: Participant
    "'SELECT [Document Type], Type, [Document No_], No_, Description FROM dbo.[company.here] WHERE [Document Type] = 1 AND Type = 2 AND [Document No_] = '$wso"""

    ... looks weird for me, but if it's this you want it should work actually.

    BTW: Do yourself and us a favor and format your code as code here in the forum, thanks

The topic ‘[HELP] Invoke-Sqlcmd’ is closed to new replies.