< Back

Set-SavedQuery

Sat Jan 11, 2020 8:32 am

NAME Set-SavedQuery



SYNOPSIS

Adds a saved TSQL query to the module. If this module is installed in a global module path, it requires

administrator privileges to update queries or the saved queries path. If the module is installed in the current

users module path, current access rights suffice.





SYNTAX

Set-SavedQuery [-Query] <String[]> [-Force] -QueryName <String> [-UpdateQueryPath <DirectoryInfo>]

[<CommonParameters>]





DESCRIPTION

Adds a saved TSQL query to the module. Use '\\' to separate to different subfolders





PARAMETERS

-Query <String[]>

The query string to save. A string array with complex TSQL queries can be added.



Required? true

Position? 0

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Force [<SwitchParameter>]

If set, Force overwrites existing saved queries



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-QueryName <String>

The Name of your query.



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-UpdateQueryPath <DirectoryInfo>

Changes the path of saved SQL queries. When changed, existing uery files are copied to the new location.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

None







OUTPUTS

System.Object







NOTES









-------------------------- Example 1 --------------------------



PS C:\\> Set-SavedQuery -QueryName "GetAllLinesFromMyTable" -Query "Select * from MyTable"



This command saves the query "Select * from MyTable" in your module and can be retrieved in the Invoke-SdfCmd

inidiately

-------------------------- Example 2 --------------------------



PS C:\\> Set-SavedQuery -UpdateQueryPath C:\\Temp\\SQL



This command updates the path for saved queries to C:\\Temp\\SQL. If there are subfolders with queries, they are

moved to the same subfolders in the target directory.



RELATED LINKS