Danny Kon
asked on
SQL join in powershell
I want to make a SQL join in a powershell something like this
$dataSource = "XXX\SQLEXPRESS"
$user = "XXX"
$pwd = "XXX"
$database = "Test BV"
$connectionString = "Server=$dataSource;uid=$u ser; pwd=$pwd;Database=$databas e;Integrat ed Security=False;"
$query = select mwOrders.fldOrderID, dbo.tblRelatie.fldNaam, dbo.tblRelatie.fldAdres
from .dbo.mwOrders
inner join dbo.tblRelatie
on dbo.tblRelatie.fldRelatieI D = mwOrders.fldRelatieID
Thx Danny
$dataSource = "XXX\SQLEXPRESS"
$user = "XXX"
$pwd = "XXX"
$database = "Test BV"
$connectionString = "Server=$dataSource;uid=$u
$query = select mwOrders.fldOrderID, dbo.tblRelatie.fldNaam, dbo.tblRelatie.fldAdres
from .dbo.mwOrders
inner join dbo.tblRelatie
on dbo.tblRelatie.fldRelatieI
Thx Danny
ASKER
Rainer,
I am not good at this, i get the following error:
+ ... ecurity=False;"$connection = New-Object System.Data.SqlClient.SqlC onnection
+ ~~~~~~~~~~~
Unexpected token '$connection' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordE xception
+ FullyQualifiedErrorId : UnexpectedToken
I am not good at this, i get the following error:
+ ... ecurity=False;"$connection
+ ~~~~~~~~~~~
Unexpected token '$connection' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordE
+ FullyQualifiedErrorId : UnexpectedToken
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Rainer,
Perfect exactly what i needed the rest of the script is also working
Danny
Perfect exactly what i needed the rest of the script is also working
Danny
this should work:
Open in new window
(adapted from http://irisclasson.com/2013/10/16/how-do-i-query-a-sql-server-db-using-powershell-and-how-do-i-filter-format-and-output-to-a-file-stupid-question-251-255/)
HTH
Rainer