SQL Alter Sequence on remote server [closed] - sql-server

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;

Related

Incorrect syntax near the keyword 'COLUMN' [closed]

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);

SQL Server database backup from C#, using stored procedure [closed]

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.

How to call one stored procedure from another in SQL Server [closed]

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
How to call one stored procedure from another stored procedure and when I do that. Then it is not updating in Crystal Report field explorer.
This is my code:
SP1
ALTER PROCEDURE [dbo].[GetSpecialJournalInfoByJVID]
(#JvID numeric,#BusinessID numeric)
AS
BEGIN
SET NOCOUNT ON;
SELECT *
FROM JV
WHERE jvID = #JvID AND BusinessID = #BusinessID
END
SP2
ALTER PROCEDURE [dbo].[USP_GetSpecificAccountLedger]
#JvID numeric(18,0),
-- Add the parameters for the stored procedure here
#ParamDate1 datetime,
#ParamDate2 datetime,
#ParamBusinessID numeric(18,0),
#ParamAccountID numeric(18,0),
#ParamCurrentCurrencyRate decimal(18,10) =1
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT *
FROM JV
WHERE jvID = #JvID
-- Insert statements for procedure here
SELECT
COA.ACCOUNTID, COA.ACCOUNTNAME, COA.GLCODE,
COA.DESCRIPTION AS ACCOUNTDESCRIPTION,
COA.ISBANKACCOUNT, COA.BANKACCOUNTNO,
COA.REFACCOUNT, FIXED,
ISNULL(OPBAL.OPENINGBALANCE, 0) OPENINGBALANCE,
ISNULL(CURBAL.DR_CUR_BAL, 0) DR_CUR_BAL,
ISNULL(CURBAL.CR_CUR_BAL, 0) CR_CUR_BAL,
J.TRNDATE, J.TRNDESCRIPTION, TRNTYPE,
I need help, I googled it a lot but didn't got any solution
thanks in advance...
You can call a stored procedure by using the EXEC command. However, it might be better to use SQL Server user-defined function.
Please see: https://technet.microsoft.com/en-us/library/aa175085(v=sql.80).aspx

Code runs fine in SQL Server, but fails at the time of deploying [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Please tell me as soon as possible?
create table aboutus_table
(
id int primary key identity(1,1),
content char(7500),
)
select * from aboutus_table
create procedure admin_aboutus_save
(#aboutus_content char(7500))
as begin
insert into aboutus_table(content)
values(#aboutus_content)
end
create procedure admin_aboutus_detail
as begin
select * from aboutus_table
end
create procedure admin_aboutus_detail_delete
(#aboutus_id int)
as begin
delete aboutus_table where id=#aboutus_id
end
create procedure admin_aboutus_detail_edit
(#aboutus_id int)
as begin
select * from aboutus_table where id=#aboutus_id
end
create procedure admin_aboutus_edited_save
(#aboutus_id int,
#aboutus_content char(7500))
as begin
update aboutus_table
set content = #aboutus_content
where id = #aboutus_id
end
This is my code. It is running fine in SQL Server, but at the time of deploying a website, when it am running above code in SQL Server, it is show error.
An exception occurred while executing a Transact-SQL statement or batch.
'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
Incorrect syntax near the keyword 'procedure'.
Must declare the scalar variable "#aboutus_id".
Must declare the scalar variable "#aboutus_id".
Must declare the scalar variable "#aboutus_id".
As the error states, CREATE PROCEDURE must be the first statement in a query batch.
To force a piece of SQL to run in a new query batch, either execute that code separately, or place GO before it in SSMS.

How to take two database backup in a single operation [closed]

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/

Resources