- Install Powershell 2
- Install SQL Server 2008 Feature Pack: Powershell Extensions http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=ceb4346f-657f-4d28-83f5-aae0c5c83d52
- Install SQL Powershell Extensions: http://sqlpsx.codeplex.com/
- Add this line to My Documents\WindowsPowerShell\profile.ps1: "add-pssnapin SqlServerCmdletSnapin100; add-pssnapin SqlServerProviderSnapin100;" (no quotes)
- Start Powershell and see if it works:
Set-ExecutionPolicy RemoteSigned (or
Invoke-Sqlcmd -query "select getdate(), @@version" -serverinstance "yourservername"|Export-Csv c:\testps.txt –notypeinformation
Put butter in your mixer, add sugar, set on low. Write a stored procedure to keep track of jobs that won't run. Add flour. Use a DMV to find unused indexes. Add eggs. Bake in an MDF with 20% free space.
Wednesday, April 6, 2011
[Powershell] Basics to run a SQL query
Putting this here for when the new guy starts. The learning curve can suck at certain points, like the installer. See my other post about it. Grr.
No comments:
Post a Comment