CleanCode logo
sitemap
SEARCH:

CleanCode PowerShell Libraries v1.2.08 API: CleanCode » SqlTools » Invoke-InferredSqlcmd

Invoke-InferredSqlcmd

NAME

Invoke-InferredSqlcmd

SYNOPSIS

Executes Invoke-Sqlcmd while attempting to supply a default context.

SYNTAX

Invoke-InferredSqlcmd [-ServerInstance <String>] [-Database <String>] [-EncryptConnection] [-Username <String>] [-Password <String>] [[-Query] <String>] [-QueryTimeout <Int32>] [-ConnectionTimeout <Int32>] [-ErrorLevel <Int32>] [-SeverityLevel <Int32>] [-MaxCharLength <Int32>] [-MaxBinaryLength <Int32>] [-AbortOnError] [-DedicatedAdministratorConnection] [-DisableVariables] [-DisableCommands] [-HostName <String>] [-NewPassword <String>] [-Variable <String[]>] [-InputFile <String>] [-OutputSqlErrors] [-SuppressProviderContextWarning] [-IgnoreProviderContext] [<CommonParameters>]

DESCRIPTION

This cmdlet is exactly equivalent to Invoke-Sqlcmd except that it extends the notion of default context. That is, you do not actually have to be on the SQLSERVER: drive, only to have set the current location on that drive to a server and database path.

PARAMETERS

-ServerInstance <String>
        A character string specifying the name of an instance of
        the Database Engine. For default instances, only specify the computer name:
        "MyComputer". For named instances, use the format "ComputerName\InstanceName".
        If -ServerInstance is not specified Invoke-InferredSqlcmd attempts to infer it:
        * If on a SQLSERVER: drive (or alias) and the path specifies the SQL folder,
        Invoke-InferredSqlcmd uses the server and instance specified in the path.
        * If not on a SQLSERVER: drive but the current location on your SQLSERVER:
        drive specifies the SQL folder, Invoke-InferredSqlcmd uses the server and instance
        specified in that path.
        This latter inference is the difference between Invoke-Sqlcmd
        and Invoke-InferredSqlcmd.

        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false

-Database <String>
        A character string specifying the name of a database.
        Invoke-InferredSqlcmd connects to this database in the instance specified by -ServerInstance.
        If -Database is not specified Invoke-InferredSqlcmd attempts to infer it:
        * If on a SQLSERVER: drive (or alias) and the path specifies both the SQL folder
        and a database name, Invoke-InferredSqlcmd uses the database specified in the path.
        * If not on a SQLSERVER: drive but the current location on your SQLSERVER:
        drive specifies both the SQL folder and a database name, Invoke-InferredSqlcmd uses
        the database specified in that path.
        This latter inference is the difference between Invoke-Sqlcmd
        and Invoke-InferredSqlcmd.

        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false

-EncryptConnection [<SwitchParameter>]
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                False
        Accept pipeline input?       false
        Accept wildcard characters?  false

-Username <String>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false

-Password <String>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false

-Query <String>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    1
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false

-QueryTimeout <Int32>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                0
        Accept pipeline input?       false
        Accept wildcard characters?  false

-ConnectionTimeout <Int32>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                0
        Accept pipeline input?       false
        Accept wildcard characters?  false

-ErrorLevel <Int32>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                0
        Accept pipeline input?       false
        Accept wildcard characters?  false

-SeverityLevel <Int32>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                0
        Accept pipeline input?       false
        Accept wildcard characters?  false

-MaxCharLength <Int32>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                0
        Accept pipeline input?       false
        Accept wildcard characters?  false

-MaxBinaryLength <Int32>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                0
        Accept pipeline input?       false
        Accept wildcard characters?  false

-AbortOnError [<SwitchParameter>]
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                False
        Accept pipeline input?       false
        Accept wildcard characters?  false

-DedicatedAdministratorConnection [<SwitchParameter>]
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                False
        Accept pipeline input?       false
        Accept wildcard characters?  false

-DisableVariables [<SwitchParameter>]
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                False
        Accept pipeline input?       false
        Accept wildcard characters?  false

-DisableCommands [<SwitchParameter>]
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                False
        Accept pipeline input?       false
        Accept wildcard characters?  false

-HostName <String>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false

-NewPassword <String>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false

-Variable <String[]>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false

-InputFile <String>
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false

-OutputSqlErrors [<SwitchParameter>]
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                False
        Accept pipeline input?       false
        Accept wildcard characters?  false

-SuppressProviderContextWarning [<SwitchParameter>]
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                False
        Accept pipeline input?       false
        Accept wildcard characters?  false

-IgnoreProviderContext [<SwitchParameter>]
        See Invoke-Sqlcmd.

        Required?                    false
        Position?                    named
        Default value                False
        Accept pipeline input?       false
        Accept wildcard characters?  false

<CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, see 
        about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 

INPUTS

None. You cannot pipe objects to Invoke-InferredSqlcmd.

OUTPUTS

Formatted table.

NOTES



        This function is part of the CleanCode toolbox
        from http://cleancode.sourceforge.net/.

        Since CleanCode 1.1.05.

EXAMPLES


-------------------------- EXAMPLE 1 --------------------------

C:\PS>Invoke-InferredSqlcmd -Query "SELECT GETDATE() AS TimeOfQuery;" -ServerInstance "MyComputer\MyInstance" -Database "MyDatabase"

Runs the basic T-SQL query on the explicitly provided server and database.

-------------------------- EXAMPLE 2 --------------------------

C:\PS>Invoke-InferredSqlcmd -Query "SELECT GETDATE() AS TimeOfQuery;"

Runs the basic T-SQL query using inferred values for ServerInstance and Database.

RELATED LINKS

-none-

This documentation set was created with CleanCode's DocTreeGenerator.

Valid XHTML 1.0!Valid CSS!Get CleanCode at SourceForge.net. Fast, secure and Free Open Source software downloads
Copyright © 2001-2015 Michael Sorens • Contact usPrivacy Policy
Usage governed by Mozilla Public License 1.1 and CleanCode Courtesy License
CleanCode -- The Website for Clean DesignRevised 2015.12.16