Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sql

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-07-12 : 07:12:44
Eugene writes "This is the stored procedure I created:

Create Procedure usp_InsertCustomer
@FirstName varchar(25),
@LastName varchar(25),
@CompanyName varchar(25),
@Phone int,
@Email varchar(20),
@Password varchar(20),
@Address varchar(30),
@Zip int,
@StateID varchar(30),
@City varchar(30),
@CountryID varchar(30),
@CustomerTypeID int,
@IP varchar(20)
AS SET NOCOUNT ON

Declare @sessionID AS UNIQUEIDENTIFIER
Declare @session AS varchar(255)

set @sessionID = NEWID()
set @session = convert(varchar(255),@SessionID)

INSERT INTO Customer FirstName,LastName,CompanyName,Phone,Email,Password,Address,Zip,StateID,City,CountryID,CustomerTypeID,Session,IP,LastUpdate
VALUES(@FirstName,@LastName,@CompanyName,@Phone,@Email,@Password,@Address,@Zip,@StateID,@City,@CountryID,@CustomerTypeID,@session,@IP,GETDATE())



when I execute the stored procedure as bellow:

EXECUTE usp_InsertCustomer "Eugene","Kevin","Maju",0123176940,"tea@hotmail.com","123456","112 Jln",50470,"WP","KL","Malaysia",1,"127.0.0.1"


I am getting the following error:

Server: Msg 8152, Level 16, State 9, Procedure usp_InsertCustomer, Line 23
String or binary data would be truncated.
The statement has been terminated.

How do I solve the problem?.

Your help is kindly appreciated.

Regards

Eugene"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-12 : 07:26:58
You need to increase the column size of the table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-07-12 : 07:43:52
One of your parameters contains data that is wider than the column you are trying to insert it into allows

You could put a DEBUG in there:

SELECT LEN(@FirstName) AS LEN_FirstName,
...

to see what the actual data length are, then compare against the DDL for the table

Kristen
Go to Top of Page
   

- Advertisement -