sqlserver给某个用户授权某张表得操作权限,并利用这个用户进行跨库查询
Sql表授权
- 创建用户
![](https://img2020.cnblogs.com/blog/1347657/202008/1347657-20200828150014630-482068164.png)
此时,改用户登录是看不到任何表的
- 设置权限
![](https://img2020.cnblogs.com/blog/1347657/202008/1347657-20200828150044029-174805426.png)
![](https://img2020.cnblogs.com/blog/1347657/202008/1347657-20200828150100280-144734322.png)
- 创建连接
EXEC sp_addlinkedserver 'LinkName','','SQLOLEDB','要跨的库的ip地址' --有自定义实例名还要加上/实例名EXEC sp_addlinkedsrvlogin 'LinkName','false',NULL,'erpuser','erpuser1.'exec sp_serveroption @server='LinkName' , @optname= 'rpc', @optvalue ='TRUE'exec sp_serveroption @server='LinkName' , @optname= 'rpc out', @optvalue='TRUE'select * from LinkName.FBBASE5.dbo.SWAP_LMISU8