1. How to run a query on a remote SQL Server?
Ans: To do the same use OPENROWSET:
Syntax: SELECT * FROM OPENROWSET('SQLOLEDB',REMOTE_SERVER_NAME';'sa';'password','SQL STATEMENT')
Example: Select * from OPENROWSET('SQLOLEDB','local';'sa';'','Select * from employees')
2.How can execute operating system comman from within SQL Server?
Ans: The xp_cmdshell stored procedure helps to do the same.
Example:EXEC MASTER..xp_cmdshell 'Dir C:\'
3. If we have two triggers of same type on a table, then which one will fire first?
Ans: They will fire as they are created. However we can set the trigger order by using stored procedure sp_settriggerorder, but the first and last triggers have of different types. Also define first and last triggers rest will fire as they have created.
No comments:
Post a Comment