• If I'm reading this right, I would change the strategy. there might be additional details why you HAVE to go SQLcmd, but i'll start with my assumption.

    instead of stepping out to the command line and running SQLCmd, and trying to wrestle the data back into SQL,

    I think it would add a linked server to the same server with the same credentials being used, and insert results into a temp table locally, for further consumption.

    SELECT *

    --INTO #Results

    FROM OPENQUERY( [MyLinkedServer],'SELECT * FROM MyDatabase.dbo.TableName ')

    SELECT *

    --INTO #Results

    FROM [MyLinkedServer].MyDatabase.dbo.TableName

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!