I have the following table inside SQL:-
/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP (1000) [ORG_UNIT]
,[Rollup_Business]
,[Rollup_Region]
FROM [Flavors_DevEx].[dbo].[BU_ROLLUP]
and when i execute the following Power Shell to retrieve all the data :-
Function ProcessSQLServerDataBU_ROLLUP([string]$DBServer, [string]$DBName, [string]$Query)
{
try
{
$conn = New-Object System.Data.SqlClient.SqlConnection("Data Source=$DBServer;Integrated Security=True;Initial Catalog=$DBName")
$conn.Open();
$query = $Query
$dap = new-object System.Data.SqlClient.SqlDataAdapter($query,$conn);
$dt = new-object System.Data.DataTable;
$dap.Fill($dt);
foreach($r in $dt.Rows)
{
Write-Host $r["ORG_UNIT"]
}
$conn.Close();
}
catch
{
#Write error message on screen and to a LOG file
write-host $_.Exception.Message
$_.Exception.Message >> "d:\error.log"
}
finally
{
$ErrorActionPreference = "Continue"
}
}
ProcessSQLServerDataBU_ROLLUP "(localdb)\ProjectsV13" "Flavors_DevEx" "SELECT [ORG_UNIT] FROM [BU_ROLLUP]"
i will get this result (where 4 represents the number of rows).. so how i can eliminate this number? and only show the data itself?
4
1
11
111
1111
Thanks