Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

SQL Server PowerShell Extensions (SQLPSX) Part 1 Expand / Collapse
Author
Message
Posted Monday, March 9, 2009 10:32 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, April 5, 2011 1:13 AM
Points: 3, Visits: 140
Great article. Just a small point being a complete beginner to Powershell....but I had a problem sourcing the scripts into Powershell. i think it came down to a syntax error in your example :

Launch PowerShell and source or dot the LibrarySmo.ps1 file using the following command:
. .\LibrarySmo.ps1

To get this step to work I had to swap the slash around i.e. . ./LibrarySmo.ps1

Just thought it was worth mentioning in case other beginners like me get stuck at that point.
Post #671722
Posted Thursday, March 12, 2009 9:21 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, August 12, 2010 6:29 AM
Points: 2, Visits: 8
Great stuff. I have no problems at all with get-sqldata, but I cant get set-sqldata to work...

Ok, so this works


Get-SqlData 'VISTA-LAPPY\SQLEXPRESS' Worldship 'SELECT top 3 * FROM
dbo.UPSData'


But this does not...


Get-SqlData 'VISTA-LAPPY\SQLEXPRESS' Worldship 'INSERT INTO dbo.UPSpod
(Sheet, User) VALUES (4, Jim)'


Nether does:

Set-SqlData 'VISTA-LAPPY\SQLEXPRESS' Worldship "INSERT INTO dbo.UPSpod
(Sheet, User) VALUES (4, 'Jim')"

The insert statement works in SQL, so I am not sure what i am
missing.... Hope you can help.


Post #674357
Posted Friday, March 13, 2009 1:28 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, November 24, 2014 2:02 PM
Points: 259, Visits: 716
jsimpson (3/12/2009)
Great stuff. I have no problems at all with get-sqldata, but I cant get set-sqldata to work...

Ok, so this works


Get-SqlData 'VISTA-LAPPY\SQLEXPRESS' Worldship 'SELECT top 3 * FROM
dbo.UPSData'


But this does not...


Get-SqlData 'VISTA-LAPPY\SQLEXPRESS' Worldship 'INSERT INTO dbo.UPSpod
(Sheet, User) VALUES (4, Jim)'


Nether does:

Set-SqlData 'VISTA-LAPPY\SQLEXPRESS' Worldship "INSERT INTO dbo.UPSpod
(Sheet, User) VALUES (4, 'Jim')"

The insert statement works in SQL, so I am not sure what i am
missing.... Hope you can help.




Thanks. I'm suprised the insert statement works in SQL for you. The column name "user" gives me an error message of "Incorrect syntax near the keyword 'user'". In both SQL Server Management Studio and Powershell I have to enclose the SQL reserved keyword "user" in brackets i.e. [user] and only then does the insert work.

Set-SqlData 'Z002\SQL2K8' dbautility "INSERT INTO dbo.UPSpod (Sheet, [User]) VALUES (4, 'Jim')"



Post #675533
Posted Friday, March 13, 2009 1:31 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, August 12, 2010 6:29 AM
Points: 2, Visits: 8
hehe I figured that out too... I had been removeing the []'s in posh, because I thought I couldn't use them. Live and learn. :) Thanks!!!
Post #675536
Posted Thursday, May 14, 2009 1:08 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 5:13 AM
Points: 14,031, Visits: 28,405
Just chiming in as someone getting started with PowerShell. Well done. Thanks for the work. I'm still just digging through it all & figuring it out.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server Query Performance Tuning
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #717304
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse