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
 General SQL Server Forums
 New to SQL Server Programming
 TRUNC

Author  Topic 

esostigma
Starting Member

3 Posts

Posted - 2007-05-22 : 17:07:19
ok i thought trunc meant that it truncated the characters or data in a cell to something, but what is going on here?

UPDATE primary_mst set box_name_change = TRUNC(box_name_change);

site: http://www.deweydesigns.com
blog: http://www.deweydesigns.com/blog
myspace:
http://www.myspace.com/esotericstigma

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-05-22 : 17:28:39
No. TRUNCATE means delete data in the table without logging. Readup Books On Line if you have any questions. Depending on what you are acually doing you would either need a REPLACE or one of the LEFT/RIGHT functions. Check out BOL for those too.

Dinakar Nethi
SQL Server MVP
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

esostigma
Starting Member

3 Posts

Posted - 2007-05-22 : 17:40:41
so it is simply deleting the data in box_name_change?

site: http://www.deweydesigns.com
blog: http://www.deweydesigns.com/blog
myspace:
http://www.myspace.com/esotericstigma
Go to Top of Page

nheidorn
Starting Member

28 Posts

Posted - 2007-05-22 : 17:59:52
As far as I know, SQL server does not have a TRUNC() function. However, Oracle does and some flavors of Visual Basic do.

It is apparently used to strip the decimal portion of a numeric value. That is, TRUNC(1.25) returns 1.

You can use the T-SQL ROUND() function to truncate values in a similar fashion. Search for ROUND in Books Online for more info.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-05-22 : 18:00:17
Yes. but you need to use it with a different syntax. I would advise caution before deleting.
TRUNCATE TABLE <tablename>


Dinakar Nethi
SQL Server MVP
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -