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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Return Value
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sunny_10
Yak Posting Veteran

72 Posts

Posted - 03/06/2014 :  01:49:44  Show Profile  Reply with Quote
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

India
737 Posts

Posted - 03/06/2014 :  06:07:55  Show Profile  Send ahmeds08 a Yahoo! Message  Reply with Quote
http://stackoverflow.com/questions/19145518/how-to-know-tsql-stored-procedure-update-executed

Javeed Ahmed
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000