저장 프로 시저의 출력을 통해 텍스트 파일로 출력하려고하는 작은 문제가 있습니다. Powershell. 여기 저장 프로 시저의 Powershell 출력 형식 지정
#Connection Object
$cn = New-Object System.Data.SqlClient.SqlConnection(
"Data Source=localhost; Database=test;User ID=test;Password=xyzzy;"
)
$q = "exec usp_Users"
#Data Adapter which will gather the data using our query
$da = New-Object System.Data.SqlClient.SqlDataAdapter($q, $cn)
#DataSet which will hold the data we have gathered
$ds = New-Object System.Data.DataSet
#Out-Null is used so the number of affected rows isn't printed
$da.Fill($ds) >$null| Out-Null
#Close the database connection
$cn.Close()
if($ds.Tables[0].Rows.Count -eq 0){
write-host '0:No Data found'
exit 2
}
$file = "C:\temp\" + "users" + $(Get-Date -Format 'MM_dd_yyyy') + ".txt"
$ds.Tables[0] | out-File $file -encoding ASCII -width 255
는 출력 :
Column1
-----
USER_NAME,USER_TYPE
[email protected],MasterAdministrator
[email protected],UserAdministrator
[email protected],Users
I가 '열 1'과 밑줄을 제거 할 수 있습니까
? 확장 속성
rockin! 매력처럼 작동 –