sql

方法一:

select  * from servername.dbo.tablename

方法二:

select * from OPENDATASOURCE(
         'SQLOLEDB',
         'Data Source=远程ip;User ID=sa;Password=密码'
         ).库名.dbo.表名
where 条件

例子: 

select blogid from snai_blog_new.dbo.blog_config where username= (select username from oblog46.dbo.oblog_user where username='ycy')

select username from dbname.dbo.k_user
where username=(select username from dbname2.dbo.k_user
where username=dbname.dbo.k_user.username)

***************************************************************

创建/删除 索引:

DROP INDEX 表名.索引名

 CREATE  INDEX [索引名] ON [所有者].[表名]([classid], [isbest]) ON [PRIMARY]
GO

***************************************************************

去除记录中重复的记录(老忘记单词)

select   distinct   top   4   au_lname,au_fname   from   authors

你可能感兴趣的:(sql)