Commits

Kevin Berridge  committed 0c810f5

sqlps: enhances select-from

  • Participants
  • Parent commits 8c9babd

Comments (0)

Files changed (1)

File Microsoft.SqlServer.Management.PowerShell.sqlps_profile.ps1

   if ($_.Schema -match $schemaRegex -and $_.Name -match $tableRegex) { $_ }
 }
 
-function select-from([string]$table) {
-  invoke-sqlcmd "select top 100 * from $table"
+function select-from([string]$table, [string[]]$cols='*', [string]$top=$nil) {
+  $colstr = $cols -join ','
+  $topstr = if ($top) {"top $top"} else {''}
+  $sql = "select $topstr $colstr from $table"
+  $sql
+  invoke-sqlcmd $sql
 }