C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

Error in Stored Procedure


Posted Date: 04 Dec 2008      Posted By: juhee      Member Level: Gold     Points: 1   Responses: 4



hi all

i hv created a stord Procdure in sql server 05 for restore of database from .bak file.........but when i am callin it from asp.net it ig giving errors...in syntax.....


.............
ALTER PROCEDURE [dbo].[TestRecovery]

-- Add the parameters for the stored procedure here
@DatabaseName VARCHAR(50)

AS
SET NOCOUNT ON;
BEGIN
DECLARE @FileName AS NVARCHAR(100)
DECLARE @Path AS NVARCHAR(100)
DECLARE @RecoveryCommand AS NVARCHAR(1000)
SET @FileName = '''C:\SQL2005Backups\'+ @DatabaseName + '\Full'+
LEFT(REPLACE(CONVERT(VARCHAR(25), GETDATE(),108), ':', ''), 4) + '.BAK'''
SET @Path = 'C:\SQL2005Backups\'+ @DatabaseName
SET @RecoveryCommand=' Restore database '+ @DatabaseName + 'from disk = ' + @FileName +'with move'+ @DatabaseName+ ' to'+@Path +'.mdf,
move'+ @DatabaseName+'_log to' +@Path +'.ldf '


EXECUTE sp_executesql @RecoveryCommand
End
.................

plz help whrs is the error





Responses

Author: Danasegarane.A    04 Dec 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 0

What is the Exact Error msg ?

Thanks and Regards,
Danasegarane Arunachalam



Author: Danasegarane.A    04 Dec 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 0

What is the Exact Error msg ?

Thanks and Regards,
Danasegarane Arunachalam



Author: juhee    04 Dec 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 3

hi Danasegarane

these r the errors

Incorrect syntax near 'disk'.
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.
The label 'toC' has already been declared. Label names must be unique within a query batch or stored procedure.



Author: Jayabalaji B    04 Dec 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 3

ALTER procedure [dbo].[sp_Usr_ClientName]
@intClientType int,
@intUsrID numeric(18,0),
@intCountryId int,
@intStateID int,
@intCityID int
as
begin

select g.chvClientName,g.intCustID from tbl_Usr_General g
where flgGeneral=1 and g.intClientType=@intClientType and g.intUsrID=@intUsrID and g.intCountryId=@intCountryId
and g.intStateID=@intStateID and g.intCityID=@intCityID

end

B.Jayabalaji,
balarefutes@gmail.com



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : mobile...
Previous : File Upload
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use