|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, April 05, 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.
|
|
|
|
|
Forum 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.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Wednesday, June 05, 2013 5:01 AM
Points: 257,
Visits: 674
|
|
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')"
|
|
|
|
|
Forum 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!!!
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 9:14 AM
Points: 13,435,
Visits: 25,277
|
|
|
|
|