Forum

SQL - automatically...
 
Notifications
Clear all

SQL - automatically start script after restart

2 Posty
1 Users
0 Likes
561 Widok
0
Topic starter

example

2 Answers
0
Topic starter

example

0
Topic starter

1. create procedure inside master

2. Example content of procedure

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE MountDiskY
AS
BEGIN
	SET NOCOUNT ON;
	EXEC sp_configure 'show advanced options', '1';
	RECONFIGURE EXEC sp_configure 'xp_cmdshell', '1';
	RECONFIGURE EXEC xp_cmdshell 'NET USE Y: \\  /PERSISTENT:yes /user:my_user my_password'
END
GO

 3. Right click and EXECUTE this script to create

4. after creation

5. Autostart procedure: click NEW QUERY

6. and type

USE MASTER
GO
EXEC SP_PROCOPTION MountBackupDiskY, 'STARTUP', 'ON'
GO

 

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: