Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Return Value

Author  Topic 

sunny_10
Yak Posting Veteran

72 Posts

Posted - 2014-03-06 : 01:49:44
Hi

In the below procedure i want value should be returned if the stored procedure is executed successfully

Create PROCEDURE [dbo].[Sp_backup]
-- Add the parameters for the stored procedure here
@path VARCHAR(256) ,
@dbname varchar(50)

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- specify database backup directory
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name

-- specify filename format
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)

DECLARE db_cursor CURSOR FOR
SELECT name FROM master.dbo.sysdatabases
WHERE name IN (@dbname)

OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @dbname

WHILE @@FETCH_STATUS = 0
BEGIN
SET @fileName = @path + @dbname + '_' + @fileDate + '.BAK'
BACKUP DATABASE @dbname TO DISK = @fileName

FETCH NEXT FROM db_cursor INTO @dbname
END
CLOSE db_cursor
DEALLOCATE db_cursor
END

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-03-06 : 06:07:55
http://stackoverflow.com/questions/19145518/how-to-know-tsql-stored-procedure-update-executed

Javeed Ahmed
Go to Top of Page
   

- Advertisement -