Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inserting local variables

Status
Not open for further replies.

btacy

IS-IT--Management
Nov 2, 2007
32
0
0
GB
hi all,
i'm running a script which picks pieces of information from a few tables and stores them in local variables. then it inserts the information in the variables (per record)as a new record into another table.
it worked perfectly in SQL 2005, i tried to use it in SQL 2000 and it gived the following error

Server: Msg 8152, Level 16, State 2, Line 38
String or binary data would be truncated.
The statement has been terminated.

line 38 is :
INSERT INTO webuser

does anyone have an idea of what could be wrong?
 
That happens when you are trying to insert data in to a column that is not 'large' enough to accomodate it.

Ex: Column is varchar(2) and you try setting it to 'Hello World'

Code:
Create Table #Temp (Data VarChar(2))

Insert Into #Temp values('Hello World')

[tt][!]
Server: Msg 8152, Level 16, State 9, Line 3[/!]
String or binary data would be truncated.
[/tt]
The statement has been terminated.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Without seeing structure or syntax, I'm going with:

your column sizes are not the same on the SQL Server 2000 version.

Any chance we could see more?
 
thanks all,
the problem was caused by the sizes of the variables as you pointed out.
thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top