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
 where is the space coming from

Author  Topic 

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-02-24 : 13:30:52
I have two varchar columns (MNIPre and MNIEND). MNIpre is populated with 'GCSO99MNI' and MNIEND is populated with a numerical value starting at 100000 and increasing row by row up to 999999. I have a third column (MNINO)i am populating by using:

Update MNIONE set MNINO-MNIPRE+MNIEND.

What i would expect to get in MNINO is 'DCSO99MNI100000', 'DCSO99MNI1000001', etc, and so on.

!@#!! INSTEAD....i am getting 'DCSO99MNI 1000000', 'DCSO99mni 1000001'. I have verified over and over again that there is neither a trailing space at the end of the string in MNIPRE nor a leading space at the beginning of MNIEND. Where is this space coming from?

thanks

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-02-24 : 13:34:33
Ugh. disregard. I changed the MNIPRE to a varchar(9) and it fixed it.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-02-24 : 13:35:07
I don't understand your formula. What are you expecting minus to do with this varchar data?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-24 : 13:37:06
Are the columns varchar? What's the dattype of all the columns...


Never heard of doing this MNINO-MNIPRE+MNIEND with varchar columns



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-02-24 : 13:37:07
it's a unique ID we use for the persons in our tables.
Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-02-24 : 13:37:48
MNINO=MNIPRE+MNIEND
Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-02-24 : 13:38:38
funny how a little typo creates mass confusion. i love it.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-02-24 : 13:40:04
Ah!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-24 : 14:01:27
quote:
Originally posted by tkizer

Ah!




Bach



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-02-24 : 14:02:02
meh
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-24 : 14:42:14
Where did "Meh" Come from and who said it first?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -