Click here to Skip to main content
15,892,537 members
Home / Discussions / Database
   

Database

 
GeneralRe: delete duplicate rows Pin
Ashfield5-Oct-08 21:16
Ashfield5-Oct-08 21:16 
AnswerRe: delete duplicate rows Pin
Blue_Boy4-Oct-08 2:56
Blue_Boy4-Oct-08 2:56 
GeneralRe: delete duplicate rows Pin
Ashfield5-Oct-08 21:15
Ashfield5-Oct-08 21:15 
AnswerRe: delete duplicate rows Pin
nelsonpaixao6-Oct-08 15:06
nelsonpaixao6-Oct-08 15:06 
Questionbackup restore Pin
ss4444443-Oct-08 7:49
ss4444443-Oct-08 7:49 
AnswerRe: backup restore Pin
Ashfield3-Oct-08 8:23
Ashfield3-Oct-08 8:23 
AnswerRe: backup restore Pin
Wendelius3-Oct-08 21:12
mentorWendelius3-Oct-08 21:12 
QuestionBackup and restore SQL database Pin
Rupesh Kumar Swami3-Oct-08 6:12
Rupesh Kumar Swami3-Oct-08 6:12 
hi all,
i am new to SQL Server
i want to Create backup of my database and restore it programmatically.
i search many example on Google and also on Code project(USING SMO object) but no link fulfill my requirement.Each example give error "Backup failed for Server 'MachineName\InstanceName'.

Then i use following stored procedure to create backup

Create PROCEDURE CreateBackupFile<br />
@BackUpPath varchar(200)<br />
	AS<br />
BEGIN<br />
	<br />
	Backup Database Test to disk =  @BackupPath <br />
END


above procedure works well when i run via VB.net

but now the problem with Restore.I use following statement

Create PROCEDURE RestoreBackupFile<br />
@RestoreFilePath varchar(200)<br />
	AS<br />
BEGIN<br />
<br />
RESTORE DATABASE Vehicle<br />
FROM DISK = @RestoreFilePath<br />
END


but when i run this procedure then it give error "Database is use for this session. Use Master'

after that i modify above procedure as following

Create PROCEDURE RestoreBackupFile<br />
@RestoreFilePath varchar(200)<br />
	AS<br />
BEGIN<br />
Use master<br />
Go<br />
RESTORE DATABASE Vehicle<br />
FROM DISK = @RestoreFilePath<br />
END


but now one more limitation appear that we can not use the 'Use database' statement within Stored procedure,function and trigger

Pleast suggest how can i resolve this problem.

Rupesh Kumar Swami
Software Developer,
Integrated Solution,
Bikaner (India)

My Company
Award: Best VB.NET article of June 2008: Create Column Charts Using OWC11

AnswerRe: Backup and restore SQL database Pin
Wendelius3-Oct-08 21:20
mentorWendelius3-Oct-08 21:20 
GeneralRe: Backup and restore SQL database Pin
Rupesh Kumar Swami3-Oct-08 22:33
Rupesh Kumar Swami3-Oct-08 22:33 
GeneralRe: Backup and restore SQL database Pin
Wendelius3-Oct-08 22:46
mentorWendelius3-Oct-08 22:46 
GeneralRe: Backup and restore SQL database Pin
Rupesh Kumar Swami3-Oct-08 22:50
Rupesh Kumar Swami3-Oct-08 22:50 
GeneralRe: Backup and restore SQL database Pin
Wendelius3-Oct-08 23:03
mentorWendelius3-Oct-08 23:03 
GeneralRe: Backup and restore SQL database Pin
Rupesh Kumar Swami3-Oct-08 23:12
Rupesh Kumar Swami3-Oct-08 23:12 
GeneralRe: Backup and restore SQL database Pin
Wendelius3-Oct-08 23:24
mentorWendelius3-Oct-08 23:24 
GeneralRe: Backup and restore SQL database Pin
Rupesh Kumar Swami3-Oct-08 23:58
Rupesh Kumar Swami3-Oct-08 23:58 
GeneralRe: Backup and restore SQL database Pin
Wendelius4-Oct-08 0:46
mentorWendelius4-Oct-08 0:46 
QuestionQueries for Searching and Advanced Searching Pin
ramkoti2-Oct-08 20:41
ramkoti2-Oct-08 20:41 
AnswerRe: Queries for Searching and Advanced Searching Pin
Ashfield2-Oct-08 21:01
Ashfield2-Oct-08 21:01 
GeneralRe: Queries for Searching and Advanced Searching Pin
ramkoti29-Oct-08 23:30
ramkoti29-Oct-08 23:30 
GeneralRe: Queries for Searching and Advanced Searching Pin
Ashfield30-Oct-08 10:08
Ashfield30-Oct-08 10:08 
QuestionConvert Font in SQL 2005 Pin
tungcan5diop2-Oct-08 20:36
tungcan5diop2-Oct-08 20:36 
AnswerRe: Convert Font in SQL 2005 Pin
Ashfield2-Oct-08 21:02
Ashfield2-Oct-08 21:02 
GeneralRe: Convert Font in SQL 2005 Pin
Paul Conrad3-Oct-08 6:44
professionalPaul Conrad3-Oct-08 6:44 
QuestionEvaluating Values Inside a SQL Report - Help! Pin
Juba2-Oct-08 17:54
Juba2-Oct-08 17:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.