I have a code snippet below that is suppose to execute a stored procedure into a text file. The error i am recieving is "Syntax error in From clause". When i transfer the SQL script to SSMS it runs fine. Is there another erorr i am not seeing? Thank you for the help
$SqlConnection = New-Object System.Data.OleDb.OleDbConnection $SqlConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ServerPath + ";Extended Properties=""Text;HDR=YES;""" $SqlCmd = New-Object System.Data.OleDb.OleDbCommand("SELECT * INTO [Test#txt] FROM OPENROWSET('SQLOLEDB','Server=(local);TRUSTED_CONNECTION=YES;','set fmtonly off; set nocount on; exec DBName.Schema.StoredProcedure);",$SqlConnection) $SqlConnection.Open() $SqlCmd.ExecuteNonQuery() $SqlConnection.Close()