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.
| Author |
Topic |
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2008-02-25 : 11:50:31
|
| In a ZIP column, data type is NVARCHAR and data 11374-3832.If I apply a function left([ZIP], 10), it displays 11374-3832 but if I apply left([ZIP], 5), it displays Null. (should be 11374). Why?Is it bug? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-02-25 : 12:24:49
|
| can you provide table definitions and sample data in the form of create table and insert into statements?_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2008-02-25 : 12:28:30
|
| Original table have more than 20 columns and 9000 records.I found the problem for left() function so that I create a small table in which there is only one column and one record as show before.I just enter one record. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-02-25 : 12:39:54
|
works fine for me:DECLARE @zip TABLE (number NVARCHAR(20))INSERT INTO @zipSELECT '11374-3832'SELECT number, LEFT(number, 5), LEFT(number, 10)FROM @zip _______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2008-02-25 : 14:44:00
|
| I've run into many "issues" with 2005. You might try updating statistics or adding some nonsense where clause (something like WHERE Zip IS NOT NULL or something) just to see if that makes a difference. I'm not sure why 2005 does these strange "random" things, but it might be due to parameter sniffing or some cached execution plan or something else, but I know it's frustrating. |
 |
|
|
|
|
|