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)
 Dynamic query

Author  Topic 

sa.alavifar
Starting Member

1 Post

Posted - 2010-11-28 : 04:59:56
what is the problem in this code?

Create procedure [dbo].[temp]

@DbSrcName nvarchar(max),
@DbDisName nvarchar(max),
@DbPath nvarchar(max)

AS
Declare @Str varchar(500)
EXEC( 'BACKUP DATABASE '+ @DbSrcName +' TO DISK = '+ @DbPath + '.bak''
WITH NOFORMAT, INIT, NAME = '+ @DbDisName +', SKIP, NOREWIND, NOUNLOAD, STATS = 10, CHECKSUM
')


please help me!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-28 : 07:52:47
Doesnt seem like any problem. what was error you got?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-11-28 : 08:20:07
Apart from that NOREWIND and NOUNLOAD are for tapes and unnecessary when doing disk backups... Might be a stray ' after the file name. Looks like you forgot to add an escaped quote before the file name.

Hint: When doing dynamic SQL, print the result instead of executing it. Then you can easily see what the problems are and it's far faster than asking a bunch of random people to do your basic debugging for you.

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -