存储过程是否会写入数据库?

时间:2022-10-17 23:51:48

I'm pretty new to SQL and I want to make sure I am not changing or editing anything on sql01 database. I am allowed to read this database but not make any changes or edit anything.

我是SQL的新手,我想确保我没有在sql01数据库上更改或编辑任何内容。我被允许阅读此数据库,但不做任何更改或编辑任何内容。

The second database called called app02 is created and owned by me. So I can do whatever with it.

名为app02的第二个数据库由我创建并拥有。所以我可以用它做任何事情。

Both databases are on different servers.

两个数据库都在不同的服务器上

I am doing a query to see which FIRSTNAME and LASTNAME are listed in both databases. When I run the below, I will be connected to my database app02 in SQL Server. I am having to run a stored procedure to connect to the database not owned by me:

我正在进行查询以查看两个数据库中列出的FIRSTNAME和LASTNAME。当我运行下面的代码时,我将连接到SQL Server中的数据库app02。我必须运行存储过程来连接到不属于我的数据库:

EXEC sp_addlinkedserver @server='sql01'
EXEC sp_addlinkedsrvlogin 'sql01', 'false', NULL, 'username', 'password's

Will this save to or edit anything on the sql01 database? Here is my complete query:

这会保存或编辑sql01数据库上的任何内容吗?这是我的完整查询:

EXEC sp_addlinkedserver @server='sql01'
EXEC sp_addlinkedsrvlogin 'sql01', 'false', NULL, 'username', 'password'

SELECT LASTNAME, FIRSTNAME, STATUS, CLASS
  FROM sql01.database1.dbo.MyTable1 T1
  WHERE EXISTS (SELECT FIRSTNAME, LASTNAME 
                FROM app02.database2.dbo.MyTable2 T2
                WHERE T1.FIRSTNAME = T2.FIRSTNAME
                AND T1.LASTNAME = T2.LASTNAME)

1 个解决方案

#1


1  

If you perform SELECT Operation over any table then only you are viewing the Data from the table.When You use commands such as update ,delete then only the data structure will be modified.You can just use select statements and it will not change the database in the any sense.

如果您对任何表执行SELECT操作,那么只有您正在查看表中的数据。当您使用诸如update,delete之类的命令时,只会修改数据结构。您只能使用select语句,它不会更改数据库在任何意义上。

Hope that this will help.

希望这会有所帮助。

#1


1  

If you perform SELECT Operation over any table then only you are viewing the Data from the table.When You use commands such as update ,delete then only the data structure will be modified.You can just use select statements and it will not change the database in the any sense.

如果您对任何表执行SELECT操作,那么只有您正在查看表中的数据。当您使用诸如update,delete之类的命令时,只会修改数据结构。您只能使用select语句,它不会更改数据库在任何意义上。

Hope that this will help.

希望这会有所帮助。