Part two: SQL Server Management Studio
点击start - All programs - Micrift SqlServer 2005 - SQL Server Management Studio,可以进入SQL Server Management Studio操作界面
关于SQL Server Management Studio个人理解他就是一个数据库客户端,所以他的功能我们可以想象到(管理维护服务器) 创建数据库:
同样我们可以在Object Explore中创建表、视图、索引等
执行Transact-SQL
Note That:On the Management Studio toolbar, click Database Engine Query to open the Query Editor
显示查询结果:
Part three: SQLCMD
The first step to using sqlcmd is starting the utility.
To start the sqlcmd utility and connect to a default instance of SQL Server
1. Click Start, point to All Programs, point to Accessories, and then click Command Prompt.
2. At the command prompt, type sqlcmd.
3.Press ENTER.
To terminate your sqlcmd session, type EXIT at the sqlcmd prompt. An example to use sqlcmd(the below figure)
To connect to a named instance of SQL Server by using sqlcmd
1. Open a command prompt window, and type sqlcmd -S myServer
2. Press ENTER. An example to connect to Local Server and search all databases(the below figure)
It is obviously that there are three added databases in Local Server.
Use sqlcmd to run Transact-sql the below figure show the process of the using of Transact-sql
Note that: in the local server, there is a database name 'test2',and in database test2 exist a table named 'test2'.
To run the script file
the Script file name is 'testScript.sql', located in Disk C root path, the content of testScript.sql as following:
-----------------------Script start-----------------------------------
use test2;
go
create table test_script (
id integer not null ,
name varchar(200) null
);
go
insert into test_script values(100,'Script 100');
insert into test_script values(101,'Script 101');
insert into test_script values(102,'Script 102');
go
select * from test_script;
go
--------------------------Script end--------------------------------------- run the script file as the below figure described;