[HELP] Invoke-Sqlcmd

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Olaf Soyk Olaf Soyk 7 months, 2 weeks ago.

  • Author
    Posts
  • #59941
    Profile photo of Justin
    Justin
    Participant

    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
    Profile photo of Olaf Soyk
    Olaf Soyk
    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

You must be logged in to reply to this topic.