----SEARCHING (3RD,6,--) CHARACTER IN GIVEN STRING
CREATE PROC USP_GEN_STRING(@STRING VARCHAR(50))AS
BEGIN
DECLARE @POSITION INT
SET @POSITION =3
WHILE(@POSITION<=LEN(@STRING))
BEGIN
SELECT CHAR(ASCII(SUBSTRING(@STRING,@POSITION,1))) AS THIRDCHAR
SET @POSITION=@POSITION+3
END
END
EXEC USP_GEN_STRING @STRING='BABJIREDDY'
SELECT CHAR(ASCII(SUBSTRING('BABJIREDDY',3,1)))
------------------------------------------------------------------------------------------------------------
----TO GET THE BACKCACK AS PER DATE
DECLARE @BACKNAME VARCHAR(100)='D:\MANJUDB\MANJU1_'+ REPLACE( CAST(GETDATE() AS VARCHAR(17)),':','_') +'.BAK'
----PRINT @BACKNAME
DECLARE @QUERY VARCHAR(1000)
SELECT @QUERY=('BACKUP DATABASE MANJU1 TO DISK='+CHAR(39)+@BACKNAME +CHAR(39))
-----PRINT @QUERY
EXEC(@QUERY)
-----------------------------------------------------------------------------------------------------------
-----VERIFYONLY BACKUP FILE ARE PRESENT OR NOT
RESTORE VERIFYONLY FROM DISK='D:\MANJUDB\MANJU1_MAY 22 2014 8_36.BAK'
----------------------------------------------------------------------------------------------------------
SP_CONFIGURE 'ADVANCED OPTIONS',1
RECONFIGURE
SP_CONFIGURE 'XP_CMDSHELL',1
RECONFIGURE
------BY USING THIS PROCEDURE TO FIND FILES WITH IN THE DRIVE USING XP_CMDSHELL
ALTER PROC USP_GET_FILES(@PHATH VARCHAR(100)) AS
BEGIN
EXEC( 'XP_CMDSHELL ''DIR '+@PHATH+' /B''')
END
EXEC USP_GET_FILES 'D:\'
------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment