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);
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 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 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 7 years ago.
Improve this question
I'm making a stored procedure in SQL but I get the error Incorrect syntax near the word 'END' at line 1 position 1 but the line 1 in my code is:
CREATE PROCEDURE [dbo].[upd_facility_new] #Tcifno int
Try this format:
USE [dbName]
GO
/****** Object: StoredProcedure [dbo].[SP_name] Script Date: 08/14/2015 10:34:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[SP_name]
AS
BEGIN
SET NOCOUNT ON;
SELECT * FROM TableName
END
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 8 years ago.
Improve this question
I have a query like this:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[User_SelectByLoginID]
#LoginID nvarChar(4)
as
SELECT dbo.[User].*
FROM dbo.[User]
WHERE LoginID=#LoginID
And data in the User table:
LoginID ='1111' | Name ='abc' | Email = 'abc#yahoo.com'
when I executed this query and typed in '1111111', it returned the record:
1111 abc abc#yahoo.com
it is ridiculous when I entered the wrong LoginID and still got the data.
P/S: I set LoginID nvarchar(4)
Can someone explain for me? And how to make it right?
If you set #LoginID to nvarchar(4) it will truncate to that size so really you are passing in 1111 and not 11111111.
SQL Server silently truncates your value passed to stored procedure, so even though you pass value '1111111', it is cut off to the declared length (4) so in your stored procedure there is a value '1111'.
So you should declare your parameter #LoginID to the same size which has your column LoginID in User table