Skip to content

SQL Diary & my notes

A normal day in a life of SQL Professionals

  • Home
  • Blog
  • About

Category: Power Shell

How to rename all .sql files in a folder to have a new running sequence using PowerShell

$files = Get-ChildItem -Path . -Filter "*.sql"$counter = 5foreach ($file in $files) {$newName = "{0:D2}-$file" -f $counterRename-Item -Path $file.FullName -NewName $newName$counter++} Original sql files in a folder After execution of above script, files are renamed.

Posted on October 22, 2024October 22, 2024 by Manish KaushikPosted in Power ShellLeave a comment

How to execute TSQL using Power shell

Being a DBA many times it happens that we need to execute few queries in SQL Server, the following is one of the way to execute SQL Script in PowerShell. 1. Copy this entire script into a PS file ( say C:\Test\sample.ps1) 2. Please edit you Server,DB, and query details 3. Open power shell window … Continue reading How to execute TSQL using Power shell

Posted on February 11, 2013 by Manish KaushikPosted in Power ShellLeave a comment

Archives

  • Constraints
  • Power Shell
  • Python
  • Questions
  • Scripts
  • Stored procedure
  • Uncategorized
February 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
232425262728  
« Oct    

Python script Stored procedures

Follow SQL Diary & my notes on WordPress.com
Create a website or blog at WordPress.com
  • Subscribe Subscribed
    • SQL Diary & my notes
    • Already have a WordPress.com account? Log in now.
    • SQL Diary & my notes
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...