Named Pipes Provider: Could not open a connection to SQL Server [2]

  • Hi guys, I need your help.

    I've this query for export the resultset in txt file:

    EXEC master.dbo.sp_configure 'show advanced options',

    1 RECONFIGURE EXEC master.dbo.sp_configure 'xp_cmdshell',

    1 RECONFIGURE EXEC xp_cmdshell 'bcp "SELECT * FROM [MYdb].[dbo].[TB40] WHERE LEFT (ZZ, 2) IN (''Is'', '''MS', ''OS'', ''SM'') AND YEAR (MAX([theDate])) >= YEAR (GETDATE());" queryout "c:\output\123.txt" -T -c -t;'

    but the error is :

    SQLState = 08001, NativeError = 2

    Error = [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [2].

    SQLState = 08001, NativeError = 2

    Error = [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is config

    ured to allow remote connections. For more information see SQL Server Books Online.

    SQLState = S1T00, NativeError = 0

    Error = [Microsoft][SQL Server Native Client 10.0]Login timeout expired

    can you help me?

    thank you in advance

  • You will need to specify the server name where the database MYdb is held

    EXEC xp_cmdshell 'bcp "SELECT * FROM [MYdb].[dbo].[TB40] WHERE

    LEFT (ZZ, 2) IN (''Is'', '''MS', ''OS'', ''SM'')

    AND YEAR (MAX([theDate])) >= YEAR (GETDATE());"

    queryout "c:\output\123.txt"

    -S "SERVER_NAME" -T -c -t;'

  • many thanks for help !!!!

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

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