Questions tagged [truncate]

Data truncation is the automatic or deliberate shortening of data. A string, decimal number, or datestamp can be truncated to a shorter value. A data stream (such as a file or record set) can be truncated when either the entirety of the data is not needed or when it will be stored in a location too short to hold its entire length. No rounding occurs when numbers are truncated.

Data truncation may occur automatically, such as when a long string is written to a smaller buffer, or deliberately, when only a portion of the data is wanted. The truncation principles can be used in several different ways.

###Function Calls

Many data handling programs have built in methods or functions to handle truncation. Syntax will vary, but the principles are the same. Examples include:

  • Strings: TRUNC("This is a string.", 12) = This is a st
  • Decimals: TRUNC(3.14159, 2) = 3.14 or floor(3.14159) = 3
  • Dates: TRUNC(#7/4/2017 23:45#) = #7/4/2017 00:00#

###SQL Statement

In SQL, the TRUNCATE TABLE statement removes all rows from a table without invoking any triggered actions. The result of this operation quickly removes all data from a table, typically bypassing a number of integrity enforcing mechanisms. It was officially introduced in the SQL:2008 standard. In the SQL standard TRUNCATE TABLE is defined as a data manipulation language (DML) feature but database vendors often classify it as DDL for their own implementation-specific reasons.

The TRUNCATE TABLE mytable statement is logically (though not physically) equivalent to the DELETE FROM mytable statement (without a WHERE clause).

Datestamp values

Datestamps can be truncated. 2009-02-09 09:41:22 can be truncated, for example, to the:

  • year 2009-01-01 00:00:00
  • month 2009-02-01 00:00:00
  • day 2009-02-09 00:00:00
  • hour 2009-02-09 09:00:00

Related tags

References

Function Calls

SQL Statements

1585 questions
0
votes
0 answers

Truncate a decimal number

In java if we have a number, which is double, like this 0.619879223757707784592145. It will show it as 6.19879223757707e-4, when you print that number. I am asking that whether i can print this number as 0.000619. In C#, we can use the code…
0
votes
1 answer

Click to reveal rest of text using truncate helper

I was wondering if it was possible to use jquery on the truncate helper method in rails. I have made the omission symbol a link_to like so <%= raw(truncate(@book.description, :length => 1000, :omission => (link_to' (continued)', :id =>…
Richlewis
  • 15,070
  • 37
  • 122
  • 283
0
votes
1 answer

Truncation function not working

I am pulling some data from a mysql database and building a table with it. I have a truncation function to chop down very long strings. Here is the truncation function: function myTruncate($string, $limit, $break=".", $pad="...") { //…
lampwins
  • 920
  • 1
  • 9
  • 25
0
votes
0 answers

iOS UIButton text not getting truncated

I am making an app that generates a UITableView from data. I have a custom UITableViewCell that contains a UIButton with text. The title of one of the generated buttons is too long for the UIButton, but isn't getting truncated as I have selected in…
Max Strater
  • 540
  • 6
  • 17
0
votes
1 answer

break-to-a-newline when printing 5000 floating point numbers on one line in C++ on Linux

I am working on printing out a long stream of floating point numbers to a .csv file by C++ on Linux. I need to print 5000 numbers on one line without any break. Each number is separated by comma. But, the line is broken after printing out 512…
dtustudy68
  • 325
  • 1
  • 4
  • 13
0
votes
1 answer

Tooltip truncated in jqGrid

I have a unique scenario in a JQgrid here. I am trying to load some data into jqGrid. The data is successfully loaded into the grid. The issue is when i hover on a particular column of a row the tooltip appears. I am able to see all the tooltip…
0
votes
2 answers

Toggle more/less in a list using jquery

Need somebody to run an eye over this please. Sometimes it works on jsfiddle, sometimes it doesn't! Any improvements welcome. http://jsfiddle.net/hotdiggity/JBqB3/8/
hotdiggity
  • 329
  • 7
  • 23
0
votes
1 answer

Asp:DropDownList only shows 1st 90,337 items

We have a dropdownlist that we are populating from the database stored proc. The stored proc returns 94,060 rows. And the subroutine is adding all 94,060 items to the DropDownList. However, when running the app, the dropdownlist only shows the first…
Gilbert
  • 37
  • 4
0
votes
2 answers

How to trim text to certain length, full sentences?

I'm looking for a solution for trimming an unknown text to certain length. Keeping only full sentences. So text like this "Were you born 1. 3. 1987 in Prague? Štěpán Jr. lives there for 3 years now! " should be turned into "Were you born 1. 3.…
Tomáš Fejfar
  • 11,129
  • 8
  • 54
  • 82
0
votes
4 answers

How to insert a space in a sentence if it runs across the screen?

I have a user control in my asp.net web project. It displays the title of a blog post. If the title is too long, it will stretch the wrapped table and ruin the page layout. Is there a way I can chop the text after 40 characters IF the text doesn't…
mrblah
  • 99,669
  • 140
  • 310
  • 420
0
votes
2 answers

TRUNCATE TABLE Hangs in MariaDB

Iam trying to migrate from mysql to mariadb. This time I can face another issue with mariadb. Sometimes the TRUNCATE TABLE query becomes hang. But in MySQL, this issue doesn't occured. Can anyone help me in this regard??? Iam a newone in MariaDB.
Haseena
  • 484
  • 2
  • 11
  • 25
0
votes
1 answer

Sidebar and pagination disappear with truncate_html in production

So I decided to use the truncate_html gem so that I can remove tags from my posts when I want to preview them. It worked beautifully in development mode, I installed it just like the documentation says https://github.com/ianwhite/truncate_html but…
Michael Peralta
  • 293
  • 5
  • 18
0
votes
2 answers

C++ time.h difftime

I am in trouble with interpreting difftime quantity in a log I have produced: I measure duration for some method call, and I log it, with this syntax: time_t end, start ; time(&start); obj->sqp_func(this); time(&end); t_time = difftime(end,…
kiriloff
  • 25,609
  • 37
  • 148
  • 229
0
votes
3 answers

SQL truncate table error at -U

I want to run the following but I get an error at the '-' in front of 'U' sqlcmd -U foo -P Bar -S server -D db -Q "use db truncate table Table1" Thanks for the help EDIT: TRUNCATE TABLE table1 Does not work as it says I do not have permission.
weewa
  • 125
  • 3
  • 4
  • 14
0
votes
1 answer

mysql truncating error

Create procedure a06_generate_data( p_loop_count int, p_min int, p_max int, p_status char(1)) begin declare v_max int; declare v_min…
user1682055
  • 93
  • 2
  • 3
  • 9