sqlserver数据库学习

1。

sql server  查看使用的索引 set showplan_all on

set showplan_all on
go
SELECT [id]
      ,[name]
      ,[cid]
      ,[sex]
  FROM [test].[dbo].[T_user]
GO

2。

执行返回参数exec sp_executesql @strID,N'@BeginID int out ',@EndID out

3。

sqlserver 触发器 获取新旧数据

select   *   from inserted
select   * from deleted

oracle 触发器获取新旧数据

update   table_name   set   Item1   =   :new.value   where   Item1   =   :old.value;  

4。

修改表的所有者 exec sp_changeobjectowner '要改的表名','dbo'修改表的所有者
修改存储过程权限grant exec on AuditeComments to gallery_w

5。

跨域查询

--打开Ad Hoc Distributed Queries
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

SELECT a.* FROM OPENROWSET('SQLOLEDB','219.239.93.75';'gallery_admin';'d*7du(N2h',
   'SELECT * FROM Gallery.dbo.AlbumIDs') AS a

原文地址:https://www.cnblogs.com/yuanws/p/1358402.html