Archive for SqlServer

SQL Server 2000 Data Import and Export

Data export and import

Bulk Copy Program (BCP)

  • Syntax
    BCP {[[database_name.][owner].]{table_name | view_name} | "query"}
        {in | out | queryout | format} data_file
         [-m max_errors] [-f format_file] [-e err_file]
         [-F first_row] [-L last_row] [-b batch_size]
         [-n] [-c] [-w] [-N] [-V (60 | 65 | 70)] [-6]
         [-q] [-C code_page] [-t field_term] [-r row_term]
         [-i input_file] [-o output_file] [-a packet_size]
         [-S server_name[\instance_name]] [-U login_id] [-P password]
         [-T] [-v] [-R] [-k] [-E] [-h "hint [,...n]"]
    
  • Import Example
    bcp Northwind.dbo.Employees in c:\temp\addemploy.txt -c -T
    
  • Export Example
    bcp Northwind.dbo.Employees_Export
        out c:\temp\export.txt -c -T
    bcp Northwind.dbo.Employees_Export
        out c:\temp\Export_Comma.txt -c -t, -r\n -T
    

SQL Server 2005 Network Configuration

  • Open SQL Server Configuration Manager
  • Under SQL Server 2005 Network Configuration -> Protocols
    • Enable TCP/IP protocol
    • Right click TCP/IP and select Properties
    • Under IP Addresses tab
    • Remove TCP Dynamic Ports entry
    • Set TCP Port to 1433
  • Under SQL Native Client Configuration -> Client Protocols
    • Enable TCP/IP protocol
    • Right click TCP/IP and select Properties
    • Check that Default Port is 1433
  • Restart SQL Server service
  • Try connection: sqlcmd -s %COMPUTERNAME%/SQLEXPRESS

Troubleshooting

  • If logged in using a particular domain account, the computer need to be in that domain (e.g. VPN).

How to identify SQL Server version and edition

  • SELECT @@VERSION
  • SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')

Reference