July 21, 2010 at 8:29 am
Hello everyone, how have you been?
I have some problems with the following, I am trying to execute a statement to insert the percentage of the amount of money but it returns error
I have the following table
IF OBJECT_ID ('tblTax') IS NOT NULL
DROP TABLE tblTax
GO
CREATE TABLE tblTax
(Taxes MONEY
)
GO
CREATE PROCEDURE [InsTaxes]
DECLARE @Amount MONEY
INSERT INTO tblTax ( Taxes) VALUES (@Amount *0.1)
END
The error is:
Msg 8152, Level 16, State 14, Procedure InsertarDiezmos, Line 32
String or binary data would be truncated.
I have tried to make a conversion to decimal value of the parameter but have not had satisfactory results.
I would appreciate if anyone can give me a suggestion or help.
Thanks to all
[font=Comic Sans MS]Eduardo U. Gutiérrez Leiva[br]Cobit 5 Foundations[/font]
July 21, 2010 at 8:48 am
Eduardo Gutiérrez (7/21/2010)
Hello everyone, how have you been?I have some problems with the following, I am trying to execute a statement to insert the percentage of the amount of money but it returns error
I have the following table
IF OBJECT_ID ('tblTax') IS NOT NULL
DROP TABLE tblTax
GO
CREATE TABLE tblTax
(Taxes MONEY
)
GO
CREATE PROCEDURE [InsTaxes]
DECLARE @Amount MONEY
INSERT INTO tblTax ( Taxes) VALUES (@Amount *0.1)
END
The error is:
Msg 8152, Level 16, State 14, Procedure InsertarDiezmos, Line 32
String or binary data would be truncated.
I have tried to make a conversion to decimal value of the parameter but have not had satisfactory results.
I would appreciate if anyone can give me a suggestion or help.
Thanks to all
It appears that you're not giving us all the information needed to help you troubleshoot this.
1. Error is on line 32 of procedure InsertarDiezmos. You did not include this procedure.
2. If procedure InsertarDiezmos is in fact the InsTaxes procedure, you did not include everything going on in that procedure - you're not even close to 32 lines in that.
3. If the procedures are different, then it appears that there is a trigger on the tblTax that is calling the procedure InsertarDiezmos. This most likely means that you have a cursor in your trigger.
4. The procedure InsTaxes does not compile.
5. When you fix the compile errors, this code runs fine.
CREATE PROCEDURE [InsTaxes]
AS
DECLARE @Amount MONEY
INSERT INTO tblTax ( Taxes) VALUES (@Amount *0.1)
RETURN
GO
execute InsTaxes
Of course, the way the proc is written, you're always inserting a null into this table. Do you mean to be able to pass a value into @Amount?
I suggest that you HELP US HELP YOU by taking a look at the first link in my signature, and they try to post some sample code/data in the format suggested that reproduces the problem that you are having.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
July 22, 2010 at 11:18 pm
thank you very much for your help, he was right the sentence is correctly written, I found the error in the size of a text field.
The mistake was to enter a text a little bigger than indicated on the table
Thank you very much again ... your links helped me a lot
[font=Comic Sans MS]Eduardo U. Gutiérrez Leiva[br]Cobit 5 Foundations[/font]
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply