Cannot open file because the current provider (SqlServer) cannot open a file.

  • Server has SQL 2012

    Opened powershell

    sqlps

    got PS SQLSERVER:\> prompt

    PS SQLSERVER:\> echo "xxxx" > tempps.txt

    This works fine in normal powershell. In sqlps I get error:

    Cannot open file because the current provider (SqlServer) cannot open a file.

    Well, I must have left out a step. Can somebody tell me how to get sqlps permission to open a file?

  • Add a path for the file. For example echo 'xxxx' > C:\temp\tempps.txt

  • The full path works, though I am wondering why the command works in normal powershell without the path

    and sqlps needs the path. I would ask why the error message lies and says sqlps doesn't have permission to open a file

    but I figure, hey, this is Microsoft.

    I don't quite follow the > syntax. What is that intended to do? I find that

    echo 'xxxx' > C:\temp\tempps.txt errors out and that

    echo 'xxxx' > C:\temp\tempps.txt does work.

  • I just noticed that the Ampersand gt in my last post translated as ">" so I guess that the forum kind of messed with the command you suggested.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply