tailieunhanh - Microsoft SQL Server 2005 Developer’s Guide- P24

Microsoft SQL Server 2005 Developer’s Guide- P24:This book is the successor to the SQL Server 2000 Developer’s Guide, which was extremely successful thanks to all of the supportive SQL Server developers who bought that edition of the book. Our first thanks go to all of the people who encouraged us to write another book about Microsoft’s incredible new relational database server: SQL Server 2005. | Chapter 13 Using sqlcmd 479 12 Document Control 1 Engineering 16 Executive 14 Facilities and Maintenance 10 Finance 9 Human Resources 11 Information Services 4 Marketing 7 Production 8 Production Control 5 Purchasing 13 Quality Assurance 6 Research and Development 3 Sales 15 Shipping and Receiving 2 Tool Design 16 rows affected Here you can see how the sqlcmd command is executed to start the sqlcmd command shell. Then two T-SQL commands are added to the batch. The first command sets the current database to the sample AdventureWorks database and the next command performs a simple T-SQL query that returns the DepartmentID and Name columns from the table in the Adventureworks database. Command-Line Parameters The sqlcmd utility supports a number of command-line parameters that influence how the utility works. The following listing shows the complete set of command-line parameters that are supported by the sqlcmd utility C temp sqlcmd Microsoft R SQL Server Command Line Tool Version NT INTEL X86 Copyright C 2004 Microsoft Corporation. All rights reserved. usage sqlcmd -U login id -P password -S server -H hostname -E trusted connection -d use database name -l login timeout -t query timeout -h headers -s colseparator -w screen width -a packetsize -e echo input -I Enable Quoted Identifiers -c cmdend -L c list servers clean output -q cmdline query -Q cmdline query and exit 480 Microsoft SQL Server 2005 Developer s Guide -m errorlevel -u unicode output -i inputfile -V severitylevel -W remove trailing spaces -r 0 1 msgs to stderr -o outputfile -z new password -f codepage i codepage o codepage -Z new password and exit -k 1 2 remove replace control characters -y variable length type display width -Y fixed length type display width -p 1 print statistics colon format -R use client regional setting -b On error batch abort -v var value . -A dedicated admin connection -X 1 disable commands startup script environment variables and exit -x .