powershell execute sql and return a datareader
$strConn="Data Source=.;Initial Catalog=AdventureWorksDW2008R2;Integrated Security=True;"
$conn=New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString=$strConn
$conn.Open()
$comm=$conn.CreateCommand()
$comm.CommandText="SELECT TOP 1000 [FullDateAlternateKey],[WeekNumberOfYear],[MonthNumberOfYear],[CalendarYear] FROM [DimDate]"
$dr=$comm.ExecuteReader()
while ($dr.Read())
{
write-output $dr[0].ToString()
}
$conn=New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString=$strConn
$conn.Open()
$comm=$conn.CreateCommand()
$comm.CommandText="SELECT TOP 1000 [FullDateAlternateKey],[WeekNumberOfYear],[MonthNumberOfYear],[CalendarYear] FROM [DimDate]"
$dr=$comm.ExecuteReader()
while ($dr.Read())
{
write-output $dr[0].ToString()
}
---------------------------------------------------------------
aspnetx的BI笔记系列索引:
使用SQL Server Analysis Services数据挖掘的关联规则实现商品推荐功能
---------------------------------------------------------------