473,774 Members | 2,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VarChar being truncated.

1 New Member
Now I know this has been asked before, but I am not getting the same error as mentioned in the earlier posts I could find.

Server is SQL 2000 Ent.

As you can see the table is for parsing Security event logs. This information is then used to create reports that are sent out to clients.

Problem:
The Strings and message values from the EventLogs gets truncated when pulled from the servers. (68 of them)

When I try to set the columns to their respect maximums I get an an error.

Could someone enlighten me as to why. I am VERY new to SQL programming, as in, no formal training. So this is a bit puzzling.

Thanks..

Code and output below.

Expand|Select|Wrap|Line Numbers
  1. USE [LogParser]
  2. GO
  3. /****** Object:  Table [dbo].[SecurityEvents_Temp]    Script Date: 03/27/2007 15:57:46 ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. SET ANSI_PADDING ON
  9. GO
  10. CREATE TABLE [dbo].[SecurityEvents_Temp](
  11.     [BankNumber] [varchar](3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
  12.     [UserName] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
  13.     [DomainName] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
  14.     [EventLog] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
  15.     [RecordNumber] [int] NULL,
  16.     [TimeGenerated] [datetime] NULL,
  17.     [TimeWritten] [datetime] NULL,
  18.     [EventID] [int] NULL,
  19.     [EventType] [int] NULL,
  20.     [EventTypeName] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
  21.     [EventCategory] [int] NULL,
  22.     [EventCategoryName] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
  23.     [SourceName] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
  24.     [Strings] [varchar](8000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
  25.     [ComputerName] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
  26.     [SID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
  27.     [Message] [varchar](8000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
  28.     [Data] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
  29. ) ON [PRIMARY]
  30.  
  31. GO
  32. SET ANSI_PADDING OFF
OutPut

Warning: The table 'SecurityEvents _Temp' has been created but its maximum row size (18377) exceeds the maximum number of bytes per row (8060). INSERT or UPDATE of a row in this table will fail if the resulting row length exceeds 8060 bytes.
SparkByte
www.titangs.com
Mar 27 '07 #1
3 3477
iburyak
1,017 Recognized Expert Top Contributor
Am I missing something?
What error message did you get?
Mar 27 '07 #2
tezza98
38 New Member
This from SQL Server Books Online

SQL Server can have as many as two billion tables per database and 1,024 columns per table. The number of rows and total size of the table are limited only by the available storage. The maximum number of bytes per row is 8,060. If you create tables with varchar, nvarchar, or varbinary columns in which the total defined width exceeds 8,060 bytes, the table is created, but a warning message appears. Trying to insert more than 8,060 bytes into such a row or to update a row so that its total row size exceeds 8,060 produces an error message and the statement fails.
So you can only have a maximum of 8060 bytes, so you will have to make the varchars smaller to accomodate this
Mar 28 '07 #3
iburyak
1,017 Recognized Expert Top Contributor
You found a right comment from Books on line.

If you need to store larger amount then this you have following options for consideration:
1. Use Text datatype instead of varchar which can store as much data as your computer can handle. This requires some programming skills.
2. You can brake event log message into smaller pieces and store it as consecutive records with additional sequence number column.
3. You can store messages in files and just have full path to that file in your table in case you need to retrieve context and display it in some front end.


Good Luck.
Mar 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2938
by: James | last post by:
I am currently working on a PHP based website that needs to be able to draw from Oracle, MS SQL Server, MySQL and given time and demand other RDBMS. I took a lot of time and care creating a flexible and solid wrapper and am deep into coding. The only problem is a noticed VARCHAR fields being drawn from SQL Server 2000 are being truncated to 255 characters. I searched around php.net and found the following : Note to Win32 Users: Due...
2
2501
by: Jason | last post by:
I have a field in my databse that stores comments submitted from a web form. For some reason the data is being truncated when re-displayed. I have the settings as follows: varchar(255) is this the longest field length for varchar? thanks, j
3
2165
by: Zack Sessions | last post by:
If I declare a local variable in a cursors query and append values to it with successiuve concatenations, how come SQL7 does not report an error if I concatenate a value to it that will overflow it's declared size? Specifically, DELCARE @t varchar(5) .... SET @t = '12345'
2
6997
by: John | last post by:
Hi Everyone, I have a question about dynamically changing the length of a varchar(n) field, in case the value I'm trying to insert is too big and will give a "truncated" error, but before the error is given! i.e. Is there some kind of a way to "test" the length of the field while Inserting the value into it, and to have it automatically increase its length to the length of the value being inserted, in case the value is too big? I've...
1
2574
by: Chris Moore | last post by:
Hello, I am attempting to write a stored procedure that builds and executes a dynamic SQL statement which can be up to 8000 characters long. Therefore, I have declared a variable of type varchar(8000) which, according to the documentation, is the maximum acceptable length of such a variable. Unfortunately, however, SQL Server seems allow varchars to only be half this size: the resulting string keepings getting truncated to 4000...
2
12033
by: sbcaco | last post by:
Hello again... can someone tell me how to work around this error: String or binary data would be truncated. I am doing this: update table1 set =
0
1386
by: manoj339 | last post by:
I have varchar variable declared .When I print this var it shows me correct value before a C function. Inside a c function this variable value is getting truncated . The c function does not pass this variable .It intializes structure memebers only. I am using Pro*C/C++: Release 8.1.7.0.0 and OS details is : Release: 5.8 Kernel architecture: sun4u Application architecture: sparc Hardware provider: Sun_Microsystems Domain: Kernel version:...
0
1742
Krishna Ladwa
by: Krishna Ladwa | last post by:
In Sql Server 2000 Version, I found that no Notification message box appears when converting text column to varchar but the data gets truncated to the given size for the varchar. Whereas it appears when you convert the varchar column to text column. Do this through Enterprise Manager Console Create a New table with a column as varchar datatype from Enterprise Manager  table created  Open the table and add one row  Successfully added the...
0
27259
by: maheshmohta | last post by:
Background Often while remodeling legacy application, one of the important tasks for the architects is to have an optimum usage of storage capabilities of database. Most of the legacy applications are constrained by the technology available at the time of their development and hence aren’t optimum as per current scenario. One of such cases is the extensive usage of CHAR fields, which aren’t optimum solution for space storage now. This paper...
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9915
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5358
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.