Solved

Microsft, SQL 2005, String or binary data would be truncated.

Posted on 2008-10-06
2
1,226 Views
Last Modified: 2012-05-05
Hi, I am creating a temp table based on SP_Columns and inserting the output of SP_Columns 'MyTable' into the temp table. This works fine for all except one of my tables were i get the error
"String or binary data would be truncated."
the error is pointing to Column_Def NVARCHAR (4000)

Even turning the ANSI_WARNINGS OFF i still get the msg

this is my query

SET ANSI_WARNINGS OFF
CREATE TABLE #SpColumns
(            Table_Qualifier SYSNAME,
            Table_Owner SYSNAME,
            Table_Name SYSNAME,
            Column_Name SYSNAME,
            Data_Type SMALLINT,
            Type_Name VARCHAR(13),
            Precision INT,
            length INT,
            Scale SMALLINT,
            Radix SMALLINT,
            Nullable SMALLINT NOT NULL,
            Remarks VARCHAR (254) NULL,
            Column_Def NVARCHAR (4000) NULL,
            SQL_Data_Type SMALLINT,
            SQL_DateTime_Sub SMALLINT,
            Char_Octet_Length INT NULL,
            Ordinal_Position INT,
            Is_Nullable VARCHAR (254),
            SS_Data_Type TINYINT
)

INSERT INTO #SpColumns EXEC Sp_Columns 'MyTableName'

Help?
SET ANSI_WARNINGS ON
0
Comment
Question by:Matt_Jsy
2 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 22650017
make both of yoru varchar fields varchar(255)....also, make your nvachar(4000) field a varchar(8000)
0
 

Author Closing Comment

by:Matt_Jsy
ID: 31503412
Hey that worked, many thanks.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now