Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Can anyone please help me to take two database backups in a single operation of database backuping in Sql Server 2005.
thanks in advance
see http://sqlbackupandftp.com/
Is this what you need? This is a db-script that backs up two databases.
DECLARE #database1 varchar(100)
DECLARE #database2 varchar(100)
DECLARE #backupDir1 varchar(500)
DECLARE #backupDir2 varchar(500)
SET #database1 = 'NameOfdb1'
SET #database2 = 'NameOfdb2'
SET #backupDir1 = 'C:\Inetpub\db_backup\' + #database1
SET #backupDir2 = 'C:\Inetpub\db_backup\' + #database2
BACKUP DATABASE #database1
TO DISK = #backupDir1
WITH STATS = 10
BACKUP DATABASE #database2
TO DISK = #backupDir2
WITH STATS = 10
I put this in a StoredProcedure, and can then run it as one operation.
Check the below blog
http://www.simple-talk.com/sql/database-administration/sql-backup-pro-for-the-accidental-dba/
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 months ago.
Improve this question
On SQL Server, I'm trying to alter sequence on a remote server using this:
ALTER SEQUENCE SeverName.DbName.sys.SeqName_sequence RESTART WITH 1000;
Unfortunately, this does not work. Does anyone know if this is possible and the correct syntax?
You can do this using dynamic SQL, and specify that database's sp_executesql procedure.
DECLARE #sql nvarchar(max) = '
ALTER SEQUENCE SomeSchemaName.SomeSequenceName RESTART WITH 1000;
';
EXEC SeverName.DbName.sys.sp_executesql #sql;
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am using sql server and i want to increase size of my column but it gives exception
-- increase size of email type
ALTER TABLE [dbo].[AM_email_content]
ALTER COLUMN [email_type] VARCHAR(100);
There is no issue in your Alter statement. It should work. Select your entire statement and then execute it in SSMS.
ALTER TABLE [dbo].[AM_email_content] ALTER COLUMN [email_type] VARCHAR(100);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Please help me I am using SQL Server. I want to create a backup to my device after action EXECUTION text execution in mvc C#.
Suppose you have BackUp method in HomeController, then execute the follwoing store procedure.
_dbcontext.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, #"EXEC [dbo].[spBackUpDatabases]");
and spBackUpDatabases store procedure is like
USE [TestAppDbContext]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spBackUpDatabases]
AS
BEGIN
SET NOCOUNT ON;
-- backup database TestAppDbContext to disk='D:/TestAppDb/test.bak'
exec( 'backup database TestAppDbContext to disk = N''D:/TestAppDb/test.bak'' with format, init;' );
END
I think this help u.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
Let's say I have this procedure :
USE [base1]
GO
SET ANSI_WARNINGS OFF
GO
IF OBJECT_ID ( 'dbo.MyProcedure ', 'P' ) IS NOT NULL DROP PROCEDURE dbo.MyProcedure ;
GO
CREATE PROCEDURE dbo.MyProcedure
#code NVARCHAR(1000),
#Month INT,
#YEAR INT
AS
SET NOCOUNT ON;
-- my code
GO
-- END PROCEDURE
I use the procedure by following steps :
To create it i execute the script of procedure
The procedure is create in this database base1 not in master
I launch this command EXECUTE dbo.MyProcedure N'Test',03,2016; => i get the succesfull result
I disconnect from the server and i reconnect
I execute this : CEXECUTE dbo.MyProcedure N'Test',03,2016; => i get this error
Could not find stored procedure 'dbo.MyProcedure'.
So in custom database base1>Programmability >stored procedures => i can see the procedure it exists
Typically, default database on connection is master. so when you disconnected and reconnected, you most likely are in master database. You can verify by executing SELECT DB_NAME(). Since you created your proc in a different database, execution will fail until you switch databases or fully qualify your proc call.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have used a cursor and fetch function in SQL Server Stored Procedure
OPEN Cursor1
FETCH NEXT FROM Cursor1 INTO #RegionId
But how to do the same in Oracle Stored Procedure. Please Help
Below is the example of how Cursor can be used in Oracle...
DECLARE
CURSOR Cursor1 IS
...Some sql statement....
BEGIN
OPEN Cursor1;
LOOP
FETCH Cursor1 INTO RegionId;
EXIT WHEN Cursor1%NOTFOUND;
......
END LOOP;
CLOSE Cursor1;
END;