SQLCMD output

  • I have a script that outputs a query to a text file. When using -o I am pointing to a shared directory on another server. Does sqlcmd use smb (445) or port 139 to connect when writing the file?

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • The behavior of SQL Server's sqlcmd utility when writing a file to a shared directory can depend on several factors, including the version of SQL Server, the network configuration, and the specific command used.

    However, as of my last knowledge update in September 2021, SQL Server and sqlcmd typically use SMB (Server Message Block) over port 445 for file operations involving shared directories. This is the more modern and commonly used method for file sharing and should be preferred over port 139, which is associated with the older NetBIOS protocol.

    To ensure that SQL Server is using port 445 for file operations, make sure of the following:

    Network Configuration: The servers involved should have SMB file sharing enabled and be configured to use port 445 for SMB traffic.

    SQL Server Version: Ensure that you are using a relatively recent version of SQL Server, as older versions might have different behaviors.

    Firewall Rules: Check your firewall settings to ensure that traffic on port 445 is allowed between the SQL Server and the remote server where the shared directory is located.

    SQL Server Configuration: Verify that SQL Server has appropriate permissions to write to the shared directory.

    Remember that network and security configurations can vary, so it's essential to consult with your network and system administrators or refer to the documentation specific to your SQL Server version for precise information on how file operations are handled. Additionally, it's a good practice to keep your systems updated to benefit from the latest security and protocol improvements.

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

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