- SQL Server Reference Guide
- Introduction
- SQL Server Reference Guide Overview
- Table of Contents
- Microsoft SQL Server Defined
- SQL Server Editions
- SQL Server Access
- Informit Articles and Sample Chapters
- Online Resources
- Microsoft SQL Server Features
- SQL Server Books Online
- Clustering Services
- Data Transformation Services (DTS) Overview
- Replication Services
- Database Mirroring
- Natural Language Processing (NLP)
- Analysis Services
- Microsot SQL Server Reporting Services
- XML Overview
- Notification Services for the DBA
- Full-Text Search
- SQL Server 2005 - Service Broker
- Using SQL Server as a Web Service
- SQL Server Encryption Options Overview
- SQL Server 2008 Overview
- SQL Server 2008 R2 Overview
- SQL Azure
- The Utility Control Point and Data Application Component, Part 1
- The Utility Control Point and Data Application Component, Part 2
- Microsoft SQL Server Administration
- The DBA Survival Guide: The 10 Minute SQL Server Overview
- Preparing (or Tuning) a Windows System for SQL Server, Part 1
- Preparing (or Tuning) a Windows System for SQL Server, Part 2
- Installing SQL Server
- Upgrading SQL Server
- SQL Server 2000 Management Tools
- SQL Server 2005 Management Tools
- SQL Server 2008 Management Tools
- SQL Azure Tools
- Automating Tasks with SQL Server Agent
- Run Operating System Commands in SQL Agent using PowerShell
- Automating Tasks Without SQL Server Agent
- Storage – SQL Server I/O
- Service Packs, Hotfixes and Cumulative Upgrades
- Tracking SQL Server Information with Error and Event Logs
- Change Management
- SQL Server Metadata, Part One
- SQL Server Meta-Data, Part Two
- Monitoring - SQL Server 2005 Dynamic Views and Functions
- Monitoring - Performance Monitor
- Unattended Performance Monitoring for SQL Server
- Monitoring - User-Defined Performance Counters
- Monitoring: SQL Server Activity Monitor
- SQL Server Instances
- DBCC Commands
- SQL Server and Mail
- Database Maintenance Checklist
- The Maintenance Wizard: SQL Server 2000 and Earlier
- The Maintenance Wizard: SQL Server 2005 (SP2) and Later
- The Web Assistant Wizard
- Creating Web Pages from SQL Server
- SQL Server Security
- Securing the SQL Server Platform, Part 1
- Securing the SQL Server Platform, Part 2
- SQL Server Security: Users and other Principals
- SQL Server Security – Roles
- SQL Server Security: Objects (Securables)
- Security: Using the Command Line
- SQL Server Security - Encrypting Connections
- SQL Server Security: Encrypting Data
- SQL Server Security Audit
- High Availability - SQL Server Clustering
- SQL Server Configuration, Part 1
- SQL Server Configuration, Part 2
- Database Configuration Options
- 32- vs 64-bit Computing for SQL Server
- SQL Server and Memory
- Performance Tuning: Introduction to Indexes
- Statistical Indexes
- Backup and Recovery
- Backup and Recovery Examples, Part One
- Backup and Recovery Examples, Part Two: Transferring Databases to Another System (Even Without Backups)
- SQL Profiler - Reverse Engineering An Application
- SQL Trace
- SQL Server Alerts
- Files and Filegroups
- Partitioning
- Full-Text Indexes
- Read-Only Data
- SQL Server Locks
- Monitoring Locking and Deadlocking
- Controlling Locks in SQL Server
- SQL Server Policy-Based Management, Part One
- SQL Server Policy-Based Management, Part Two
- SQL Server Policy-Based Management, Part Three
- Microsoft SQL Server Programming
- An Outline for Development
- Database
- Database Services
- Database Objects: Databases
- Database Objects: Tables
- Database Objects: Table Relationships
- Database Objects: Keys
- Database Objects: Constraints
- Database Objects: Data Types
- Database Objects: Views
- Database Objects: Stored Procedures
- Database Objects: Indexes
- Database Objects: User Defined Functions
- Database Objects: Triggers
- Database Design: Requirements, Entities, and Attributes
- Business Process Model Notation (BPMN) and the Data Professional
- Business Questions for Database Design, Part One
- Business Questions for Database Design, Part Two
- Database Design: Finalizing Requirements and Defining Relationships
- Database Design: Creating an Entity Relationship Diagram
- Database Design: The Logical ERD
- Database Design: Adjusting The Model
- Database Design: Normalizing the Model
- Creating The Physical Model
- Database Design: Changing Attributes to Columns
- Database Design: Creating The Physical Database
- Database Design Example: Curriculum Vitae
- NULLs
- The SQL Server Sample Databases
- The SQL Server Sample Databases: pubs
- The SQL Server Sample Databases: NorthWind
- The SQL Server Sample Databases: AdventureWorks
- The SQL Server Sample Databases: Adventureworks Derivatives
- UniversalDB: The Demo and Testing Database, Part 1
- UniversalDB: The Demo and Testing Database, Part 2
- UniversalDB: The Demo and Testing Database, Part 3
- UniversalDB: The Demo and Testing Database, Part 4
- Getting Started with Transact-SQL
- Transact-SQL: Data Definition Language (DDL) Basics
- Transact-SQL: Limiting Results
- Transact-SQL: More Operators
- Transact-SQL: Ordering and Aggregating Data
- Transact-SQL: Subqueries
- Transact-SQL: Joins
- Transact-SQL: Complex Joins - Building a View with Multiple JOINs
- Transact-SQL: Inserts, Updates, and Deletes
- An Introduction to the CLR in SQL Server 2005
- Design Elements Part 1: Programming Flow Overview, Code Format and Commenting your Code
- Design Elements Part 2: Controlling SQL's Scope
- Design Elements Part 3: Error Handling
- Design Elements Part 4: Variables
- Design Elements Part 5: Where Does The Code Live?
- Design Elements Part 6: Math Operators and Functions
- Design Elements Part 7: Statistical Functions
- Design Elements Part 8: Summarization Statistical Algorithms
- Design Elements Part 9:Representing Data with Statistical Algorithms
- Design Elements Part 10: Interpreting the Data—Regression
- Design Elements Part 11: String Manipulation
- Design Elements Part 12: Loops
- Design Elements Part 13: Recursion
- Design Elements Part 14: Arrays
- Design Elements Part 15: Event-Driven Programming Vs. Scheduled Processes
- Design Elements Part 16: Event-Driven Programming
- Design Elements Part 17: Program Flow
- Forming Queries Part 1: Design
- Forming Queries Part 2: Query Basics
- Forming Queries Part 3: Query Optimization
- Forming Queries Part 4: SET Options
- Forming Queries Part 5: Table Optimization Hints
- Using SQL Server Templates
- Transact-SQL Unit Testing
- Index Tuning Wizard
- Unicode and SQL Server
- SQL Server Development Tools
- The SQL Server Transact-SQL Debugger
- The Transact-SQL Debugger, Part 2
- Basic Troubleshooting for Transact-SQL Code
- An Introduction to Spatial Data in SQL Server 2008
- Performance Tuning
- Performance Tuning SQL Server: Tools and Processes
- Performance Tuning SQL Server: Tools Overview
- Creating a Performance Tuning Audit - Defining Components
- Creating a Performance Tuning Audit - Evaluation Part One
- Creating a Performance Tuning Audit - Evaluation Part Two
- Creating a Performance Tuning Audit - Interpretation
- Creating a Performance Tuning Audit - Developing an Action Plan
- Understanding SQL Server Query Plans
- Performance Tuning: Implementing Indexes
- Performance Monitoring Tools: Windows 2008 (and Higher) Server Utilities, Part 1
- Performance Monitoring Tools: Windows 2008 (and Higher) Server Utilities, Part 2
- Performance Monitoring Tools: Windows System Monitor
- Performance Monitoring Tools: Logging with System Monitor
- Performance Monitoring Tools: User Defined Counters
- General Transact-SQL (T-SQL) Performance Tuning, Part 1
- General Transact-SQL (T-SQL) Performance Tuning, Part 2
- General Transact-SQL (T-SQL) Performance Tuning, Part 3
- Performance Monitoring Tools: An Introduction to SQL Profiler
- Performance Tuning: Introduction to Indexes
- Performance Monitoring Tools: SQL Server 2000 Index Tuning Wizard
- Performance Monitoring Tools: SQL Server 2005 Database Tuning Advisor
- Performance Monitoring Tools: SQL Server Management Studio Reports
- Performance Monitoring Tools: SQL Server 2008 Activity Monitor
- The SQL Server 2008 Management Data Warehouse and Data Collector
- Performance Monitoring Tools: Evaluating Wait States with PowerShell and Excel
- Practical Applications
- Choosing the Back End
- The DBA's Toolbox, Part 1
- The DBA's Toolbox, Part 2
- Scripting Solutions for SQL Server
- Building a SQL Server Lab
- Using Graphics Files with SQL Server
- Enterprise Resource Planning
- Customer Relationship Management (CRM)
- Building a Reporting Data Server
- Building a Database Documenter, Part 1
- Building a Database Documenter, Part 2
- Data Management Objects
- Data Management Objects: The Server Object
- Data Management Objects: Server Object Methods
- Data Management Objects: Collections and the Database Object
- Data Management Objects: Database Information
- Data Management Objects: Database Control
- Data Management Objects: Database Maintenance
- Data Management Objects: Logging the Process
- Data Management Objects: Running SQL Statements
- Data Management Objects: Multiple Row Returns
- Data Management Objects: Other Database Objects
- Data Management Objects: Security
- Data Management Objects: Scripting
- Powershell and SQL Server - Overview
- PowerShell and SQL Server - Objects and Providers
- Powershell and SQL Server - A Script Framework
- Powershell and SQL Server - Logging the Process
- Powershell and SQL Server - Reading a Control File
- Powershell and SQL Server - SQL Server Access
- Powershell and SQL Server - Web Pages from a SQL Query
- Powershell and SQL Server - Scrubbing the Event Logs
- SQL Server 2008 PowerShell Provider
- SQL Server I/O: Importing and Exporting Data
- SQL Server I/O: XML in Database Terms
- SQL Server I/O: Creating XML Output
- SQL Server I/O: Reading XML Documents
- SQL Server I/O: Using XML Control Mechanisms
- SQL Server I/O: Creating Hierarchies
- SQL Server I/O: Using HTTP with SQL Server XML
- SQL Server I/O: Using HTTP with SQL Server XML Templates
- SQL Server I/O: Remote Queries
- SQL Server I/O: Working with Text Files
- Using Microsoft SQL Server on Handheld Devices
- Front-Ends 101: Microsoft Access
- Comparing Two SQL Server Databases
- English Query - Part 1
- English Query - Part 2
- English Query - Part 3
- English Query - Part 4
- English Query - Part 5
- RSS Feeds from SQL Server
- Using SQL Server Agent to Monitor Backups
- Reporting Services - Creating a Maintenance Report
- SQL Server Chargeback Strategies, Part 1
- SQL Server Chargeback Strategies, Part 2
- SQL Server Replication Example
- Creating a Master Agent and Alert Server
- The SQL Server Central Management System: Definition
- The SQL Server Central Management System: Base Tables
- The SQL Server Central Management System: Execution of Server Information (Part 1)
- The SQL Server Central Management System: Execution of Server Information (Part 2)
- The SQL Server Central Management System: Collecting Performance Metrics
- The SQL Server Central Management System: Centralizing Agent Jobs, Events and Scripts
- The SQL Server Central Management System: Reporting the Data and Project Summary
- Time Tracking for SQL Server Operations
- Migrating Departmental Data Stores to SQL Server
- Migrating Departmental Data Stores to SQL Server: Model the System
- Migrating Departmental Data Stores to SQL Server: Model the System, Continued
- Migrating Departmental Data Stores to SQL Server: Decide on the Destination
- Migrating Departmental Data Stores to SQL Server: Design the ETL
- Migrating Departmental Data Stores to SQL Server: Design the ETL, Continued
- Migrating Departmental Data Stores to SQL Server: Attach the Front End, Test, and Monitor
- Tracking SQL Server Timed Events, Part 1
- Tracking SQL Server Timed Events, Part 2
- Patterns and Practices for the Data Professional
- Managing Vendor Databases
- Consolidation Options
- Connecting to a SQL Azure Database from Microsoft Access
- SharePoint 2007 and SQL Server, Part One
- SharePoint 2007 and SQL Server, Part Two
- SharePoint 2007 and SQL Server, Part Three
- Querying Multiple Data Sources from a Single Location (Distributed Queries)
- Importing and Exporting Data for SQL Azure
- Working on Distributed Teams
- Professional Development
- Becoming a DBA
- Certification
- DBA Levels
- Becoming a Data Professional
- SQL Server Professional Development Plan, Part 1
- SQL Server Professional Development Plan, Part 2
- SQL Server Professional Development Plan, Part 3
- Evaluating Technical Options
- System Sizing
- Creating a Disaster Recovery Plan
- Anatomy of a Disaster (Response Plan)
- Database Troubleshooting
- Conducting an Effective Code Review
- Developing an Exit Strategy
- Data Retention Strategy
- Keeping Your DBA/Developer Job in Troubled Times
- The SQL Server Runbook
- Creating and Maintaining a SQL Server Configuration History, Part 1
- Creating and Maintaining a SQL Server Configuration History, Part 2
- Creating an Application Profile, Part 1
- Creating an Application Profile, Part 2
- How to Attend a Technical Conference
- Tips for Maximizing Your IT Budget This Year
- The Importance of Blue-Sky Planning
- Application Architecture Assessments
- Transact-SQL Code Reviews, Part One
- Transact-SQL Code Reviews, Part Two
- Cloud Computing (Distributed Computing) Paradigms
- NoSQL for the SQL Server Professional, Part One
- NoSQL for the SQL Server Professional, Part Two
- Object-Role Modeling (ORM) for the Database Professional
- Business Intelligence
- BI Explained
- Developing a Data Dictionary
- BI Security
- Gathering BI Requirements
- Source System Extracts and Transforms
- ETL Mechanisms
- Business Intelligence Landscapes
- Business Intelligence Layouts and the Build or Buy Decision
- A Single Version of the Truth
- The Operational Data Store (ODS)
- Data Marts – Combining and Transforming Data
- Designing Data Elements
- The Enterprise Data Warehouse — Aggregations and the Star Schema
- On-Line Analytical Processing (OLAP)
- Data Mining
- Key Performance Indicators
- BI Presentation - Client Tools
- BI Presentation - Portals
- Implementing ETL - Introduction to SQL Server 2005 Integration Services
- Building a Business Intelligence Solution, Part 1
- Building a Business Intelligence Solution, Part 2
- Building a Business Intelligence Solution, Part 3
- Tips and Troubleshooting
- SQL Server and Microsoft Excel Integration
- Tips for the SQL Server Tools: SQL Server 2000
- Tips for the SQL Server Tools – SQL Server 2005
- Transaction Log Troubles
- SQL Server Connection Problems
- Orphaned Database Users
- Additional Resources
- Tools and Downloads
- Utilities (Free)
- Tool Review (Free): DBDesignerFork
- Aqua Data Studio
- Microsoft SQL Server Best Practices Analyzer
- Utilities (Cost)
- Quest Software's TOAD for SQL Server
- Quest Software's Spotlight on SQL Server
- SQL Server on Microsoft's Virtual PC
- Red Gate SQL Bundle
- Microsoft's Visio for Database Folks
- Quest Capacity Manager
- SQL Server Help
- Visual Studio Team Edition for Database Professionals
- Microsoft Assessment and Planning Solution Accelerator
- Aggregating Server Data from the MAPS Tool
One of the first duties you’ll have as a Database Administrator (DBA) or Database Developer after you design a system and secure it properly will be to move data in and out of the system. It’s such a common task that there are several ways you can do it. SQL Server, from the earliest versions, provides tools and processes that can handle almost any format you can think of to bring data into and out of a database.
In this overview and tutorial, I’ll show you how to move data in and out of SQL Server, I’ll explain all of the processes you have available, and then explain any differences between the versions. I won’t be able to cover each tool in depth, but I’ll point out links so that you can get started right away. Along the way, I’ll hyperlink to lots of other tutorials, so if you’re new to SQL Server you can just follow those for anything you aren’t familiar with.
Data Types
Before I begin, it makes sense to recall the data types that you have available in a database system. I have an entire article on that here, which you should read thoroughly before you move on through this article.
Why is that so important? Well, the whole point of a database system is to be an authoritative data store. If you can’t depend on the fact that the data is correct in the system, you can’t depend on anything else.
So it follows that the data is in the format that you expect and the very bottom level of data is the type for a particular datum. What that means is that a number that might need to have math performed on it should be numeric not text. For instance, 1234 can be stored as many different types of data, but if it represents a code it will be treated differently than if it needs to be added to another number.
You need to understand both the source and destination formats so that you get what you want. You normally want to transfer the data from the source into as close a representation as you can for the destination. In other words, a number should be in the numeric format on the source and numeric on the destination and so on.
Sometimes that isn’t possible. If you’re coming from a duplicate platform (such as transferring SQL Server database data to SQL Server database data) this is straightforward, but if you’re coming from Oracle or Excel, the data types might not match up exactly. Dates are a classic example of this issue. It’s even more pronounced when you import or export to or from a text file text doesn’t have data types.
I’ll explain along the way how to deal with these situations and which method is best for a given application.
Key Restrictions
Not only do you need to focus on the data types, you need to focus as well on the Primary Keys in your system and other relationships such as Foreign Keys and Unique Indexes. The primary issue here is to get the data in at the right “time,” meaning that the order matters. If you have data in a “child” table, you have to put the data into the “parent” table first, or the insert will fail. Of course, you can turn off the constraints by suspending or dropping the keys, but that’s often a very bad idea.
The point is, you’ll have to treat the import just like a standard insert operation from an application. It needs to follow the same path. For exports, of course, you don’t have this issue, but at some point you are using that exported data somewhere else, so you need to think about it.
While you’re there, make sure you take into account other restrictions such as indexes, and whether you’ve set the Primary Key to be auto-generated (using the Identity qualifier) and so on.
In any case, there are two general methods for getting the data in or out of SQL Server manually, meaning that you have to open a tool and click or type, and automatically, meaning that you can set a schedule or a trigger for the import or export to happen without your intervention. Of course, an automated method can certainly be used manually.
I’ll arrange these in order of simplicity, although there will be a bit of my own opinion here. If you’re more familiar with working with commands, for instance, you might find that a command-line tool is better for you than a “Wizard” that guides you through the process.
Import and Export Methods: Manual
Manual methods are best when you just need to perform an import or export operation once. They require you to be at a console somewhere, although not necessarily at the server, mind you, you can run some of these tools from a client console.
Queries
The first and simplest way to get data in and out of SQL Server is to use the query tools. In SQL Server 2000, this includes Query Analyzer (QA) and osql and in SQL Server 2005 and higher you’ll use SQL Server Management Studio (SSMS) in a Query Window and SQLCMD.
To export data in QA and SSMS, you have a few options. One is to run the query, select all the data in the results pane (left-click the small box in the top left of the results pane and press CTRL-C) and then paste the results into Excel or a notepad file. Save the results and you’re done. Of course, this has the most danger of losing the data types, but it does work.
You can also right-click the results pane and select “Save As” to create a text file output. Not only that, in both QA and SSMS you can select “Output to File” before you even run the query, using the icon bar.
Another interesting use of QA and SSMS is to “build” a set of insert statements you can use in another table or database. Assume for a moment that you have a table in another database on a different server that you want to transfer the first and last names of the “authors” table into. Assume that it has only two columns: FirstName and LastName.
One possible method is to use the following kind of statement to create the statements and then paste the results into the query tool on the other system:
USE pubs; go SELECT 'INSERT INTO othertable (FirstName, LastName) VALUES (' + '''' + au_fname + +'''' + ',' + '''' + au_lname + ''''+ ')' FROM authors; GO
The basic idea is to get those single-quotes (ticks) correct. Adding four of them makes one tick.
To move data from one table into another in the same database, it’s much simpler. You just use a subquery. Assume again that table with just the first and last names:
USE pubs; GO CREATE TABLE test (FirstName varchar(255), LastName varchar(255)); GO INSERT INTO test (FirstName, LastName) SELECT au_fname, au_lname FROM authors; GO SELECT * FROM test; GO
I’ll cover osql and SQLCMD in a moment.
Import/Export Data and the Copy Database Wizard
By far the easiest method to use to move data in and out of SQL Server is to right-click the object in Enterprise Manager (EM) or SSMS and select “Tasks” (or “All Tasks”) and then follow the instructions in the Wizard. In fact, the Wizards use DTS or SSIs (more on those next) but it simplifies the process. In SQL Server 2005 and higher, another option called “Copy Database” on that same right-click menu will transfer an entire database if that’s what you’re after, but I find that Backup and Restore works better for that.
Import and Export Methods: Automated (or can be)
Although the previous commands and features require you to be at the console, you have other options that you can use for manual imports or exports that can also be scheduled in some cases you can use SQL Server Agent, within SQL Server commands.
Other commands, in fact all of the command-line versions you see below, can be automated even within Windows, using the Windows scheduler or even third-party Windows scheduling tools.
One caveat I would mention here any of the automatic methods should include logging and alerting in some way. You need to be able to tell that they ran, or didn’t run, how long they took, and whether they completed successfully. I’ve covered that in other articles on this site, including the PowerShell area.
The Bulk Copy Program (bcp)
Since the very first versions of SQL Server, the Bulk Copy Program (bcp.exe) has been one of the easiest and fastest ways to export or import data. It’s a command-line program that you can find out more about by typing bcp /?:
C:\>bcp /? usage: bcp {dbtable | query} {in | out | queryout | format} datafile [-m maxerrors] [-f formatfile] [-e errfile] [-F firstrow] [-L lastrow] [-b batchsize] [-n native type] [-c character type] [-w wide character type] [-N keep non-text native] [-V file format version] [-q quoted identifier] [-C code page specifier] [-t field terminator] [-r row terminator] [-i inputfile] [-o outfile] [-a packetsize] [-S server name] [-U username] [-P password] [-T trusted connection] [-v version] [-R regional enable] [-k keep null values] [-E keep identity values] [-h "load hints"] C:\>
I’ve covered this tool in another tutorial, but the important thing to keep in mind is that you have two basic formats it can work with: “text,” and “native.” Text is just that, ANSI text. You’ll lose all of your data types this way. Here’s an example of sending the entire “authors” table from my SQL1\SQL2K instance (also works with the later versions) to a text file called “test.txt”:
bcp authors out -SSQL1\SQL2K -T -oc:\temp\test.txt
You can also use the “native” format, which means that it will keep the type formats and so on, but only for SQL Server. All you have to do to use that is to add the –N qualifier to the end of the statement above.
PowerShell
I’ve covered PowerShell a lot, and it’s a command-line tool with a thousand (or more) uses. It has the ability to talk to anything in Windows, and can also select data from SQL Server and send it to an output file. I’ll do that here.
I’m not including error handling, logging and alerting in this example so that I can focus on the “meat” of the process, but you absolutely should. In the following example, I’m using PowerShell and the AdventureWorks sample database on my server called “UNIVAC”.
The result is a file that has each element separated by a colon, but you have a ton of control over the format and placement of these data elements. Also this presumes that you have the SQL Server client libraries available on the system where it runs from:
# SQL Server Query using SQL Data Adaptor $serverName = "UNIVAC" $databaseName = "AdventureWorks" $qry = @" SELECT * FROM Production.Product "@ $connString = "Server=$serverName;Database=$databaseName;Integrated Security=SSPI;" $da = New-Object "System.Data.SqlClient.SqlDataAdapter" ($qry,$connString) $dt = New-Object "System.Data.DataTable" [void]$da.fill($dt) $dt | out-file c:\temp\test.txt
DTS
The name says it all Data Transformation Services (DTS). This graphical tool, available in SQL Server 2000, allows you to select the objects you want to work with and then perform actions on them, including copying them. I’ve covered this tool here and there is a lot more information on it at InformIT.
Although you can still run a DTS package in SQL Server 2005 and higher, it’s best to use SSIS, which I’ll explain next.
SSIS
SQL Server Integration Services is the replacement for DTS in SQL Server 2005 and higher. It is aimed at the Extract, Transform and Load process in Business Intelligence, but you can use it for much more.
I’ve covered this tool in more depth here, but like DTS it also creates “packages” that are a group of objects and actions you can perform on them such as transferring data in and out. I usually start with the Import and Export data Wizards, and then save those as an SSIS package to work with later.
BULK INSERT
The BULK INSERT statement is similar to the bcp.exe program, except that you type it in a Query Window in QA or SSMS or other query tool. It can read data from a text or native SQL Server file and import it into the database you’re using.
It has similar qualifiers, such as native or text formats. The primary difference with this tool is that it doesn’t export anything it’s import only. Read more about it here.
SQLCMD and osql
I’ve covered these two tools in other tutorials that you can read here, but the idea is that they provide a command-line query interface to SQL Server. The osql tool is available in SQL Server 2000 and higher, and SQLCMD is available in SQL Server 2005 and higher.
With these tools, you enter the name of the server, database and a query you want to run. They both contain a switch (-o) that will send the results of the query to a file. You can treat this similar to the “Output to File” option in QA and SSMS.
Here’s a quick sample that runs the same select statement as the PowerShell script:
sqlcmd -S UNIVAC -d AdventureWorks -E -Q "SELECT * FROM Production.Product" –o c:\temp\test2.txt
And of course these are only the primary methods you have. There are others, which I’ll cover in later tutorials.
InformIT Articles and Sample Chapters
If you’re using DTS, make sure you check out this free chapter from SQL Server DTS, by Jim Samuelson and Brian Sullivan, Enhancing DTS Package Performance.
Books and eBooks
SSIS is a huge program with a lot of study required. Happily there’s a book here for that: Microsoft SQL Server 2005 Integration Services. (Also available in Safari Books Online)
Online Resources
If you need a blow-by-blow for the Import and Export Wizard, you can start here.