SQL链接数据库
Standard Security:
"Data Source=Aron1;Initial
Catalog=pubs;User Id=sa;Password=asdasd;"
- or -
"Server=Aron1;Database=pubs;User
ID=sa;Password=asdasd;Trusted_Connection=False"
(both
connection strings produces the same result)
Trusted Connection:
"Data
Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"
- or -
"Server=Aron1;Database=pubs;Trusted_Connection=True;"
(both connection strings produces the same result)
(use serverName\instanceName as Data Source to use
an specifik SQLServer instance)
Connect via an IP
address:
"Data Source=190.190.200.100,1433;Network
Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;"
(DBMSSOCN=TCP/IP instead of Named Pipes, at the end of the
Data Source is the port to use (1433 is the default))
Enabling MARS (multiple active result sets):
"Server=Aron1;Database=pubs;Trusted_Connection=True;MultipleActiveResultSets=true"
Note! Use &nbs
相关文档:
常用SQL查询:
1、查看表空间的名称及大小
select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
2、查看表空间物理文件的名称及大小
select tablespace_name, file_id, ......
--跨服务器查询如下:
SELECT a.*,b.stor_Name
from OPENROWSET('MSDASQL',
'DRIVER={SQL Server};SERVER=tom;UID=sa;PWD=123',
pubs.dbo.authors) AS a,stores b
ORDER BY a.au_lname, a.au_fname
--其中,tom为远程服务器名,stores 是本机数据库pubs中的表
--需要注意的是若二个表中的 ......
SQL Server 2005 不允许远程连接解决方法
刚刚安装的数据库系统,按照默认安装的话,很可能在进行远程连接时报错,通常是错误:"在连接到 SQL Server 2005 时,
在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。
(provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接) "搜M ......
left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录
right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录
inner join(等值连接) 只返回两个表中联结字段相等的行
举例如下:
--------------------------------------------
表A记录如下:
aID aNum
1 a ......