EasyCFM.COM ColdFusion Forums / MS SQL Server Related Issues / Extra WhiteSpace

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Extra WhiteSpace -- page: 1 2

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

apletfx
03-06-2007 @ 4:24 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 607
Joined: Nov 2002

I have read elsewhere that MS SQL can add extra white space to fields. Im
having this issue myself and am not satisfied with the answers I have
been reading about. I have read that people use trim() to remove the
space on the output but that is ridiculous to have to add an extra function
just to stop this. I would imaging that the error could be corrected in the
database rather than at the code level.  

Mark Aplet
http://www.pixeljunkie.org

JJfutbol
03-06-2007 @ 6:28 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1250
Joined: Nov 2004

Do you first know why the extra whitespace is even being added in?? I work with Microsoft SQL Server all the time and it's never happened to me unless the whitespace was forced by the user (entering blanks within a textarea in a text datatype field) or an error by the developer. The second one happened to one of the guys on our team which ended up being quite a funny story.

Are you by chance using CFC's to insert and update records in your database?? If so make sure your cffunction's and the cfcomponent tags have a output="false". You must have this stated as by default those tags have a value of true for the output attribute. Let us know how you are doing. Do note it is recommended and considered best practice when ever entering data into the database (or updating it) to use trim() just in case.

----------------------------------------------------
Some free CF applications available at my site, such as the popular CFC Validator www.javier-julio.com My new site design is up!! Let me know what you all think! Working on a fully accessible Forum, which validates as full CSS and XHTML 1.0 Strict.

apletfx
03-06-2007 @ 8:10 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 607
Joined: Nov 2002

Well actually I typed it in directly through the ent manager. It's possible
that I set the datatype or length incorrectly. I used char as the datatype
and 100 as the length. Would this make a difference?

Mark Aplet
http://www.pixeljunkie.org

JJfutbol
03-06-2007 @ 8:37 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1250
Joined: Nov 2004

I never use char but I'm sure it has its uses but if its a simple field with just string data I'd recommend using varchar or nvarchar. I used to know the difference between the 2 but I don't remember at the moment my apologies. I'd stick to using varchar there. The length sounds just fine unless the data you save will never need that much space.

----------------------------------------------------
Some free CF applications available at my site, such as the popular CFC Validator www.javier-julio.com My new site design is up!! Let me know what you all think! Working on a fully accessible Forum, which validates as full CSS and XHTML 1.0 Strict.

raulriera
03-07-2007 @ 4:03 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 69
Joined: Aug 2005

If you use "char(100)" and use a value less than 100 MSSQL will add whitespaces until it reaches the 100 cap, use varchar(100) insted Smile

Raul Riera
http://www.hipervinculo.net

apletfx
03-07-2007 @ 4:11 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 607
Joined: Nov 2002

Thats the ticket! Thanks Guys!

Sorry to have so many seemingly dumb questions. I just signed up for an
online training class so hopefully I will not ask as many dumb
questions. Smile

Mark Aplet
http://www.pixeljunkie.org

JJfutbol
03-07-2007 @ 4:34 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1250
Joined: Nov 2004

Thats the difference between char and varchar! Raul thank you so much. Nice to have someone remind us. I haven't had time to look it up. So there you go Mark you got your answer. Well instead of asking Pablo to pay us senior members for answering questions maybe you should pay us Mark when asking questions with such a rough angry tone. Wink  No question is dumb. If anything now we know the difference between char and varchar. Let us know if we can do anything else.

----------------------------------------------------
Some free CF applications available at my site, such as the popular CFC Validator www.javier-julio.com My new site design is up!! Let me know what you all think! Working on a fully accessible Forum, which validates as full CSS and XHTML 1.0 Strict.

apletfx
03-07-2007 @ 6:11 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 607
Joined: Nov 2002


quote:


Well instead of asking Pablo to pay us senior members for answering
questions maybe you should pay us Mark when asking questions with
such a rough angry tone.



Was I angry sounding? Im sorry, it wasn't the intention. I wasn't even
reading about it on this forum. It was a MS SQL and PHP forum.  Sorry to
come off that way.  Blush

Mark Aplet
http://www.pixeljunkie.org

JJfutbol
03-07-2007 @ 6:27 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1250
Joined: Nov 2004

Don't worry I'm just picking on ya. Smile  As I said earlier there is never a dumb question. You asked a perfectly valid one today. I just hope this time I can actually remember the difference between char and varchar!

----------------------------------------------------
Some free CF applications available at my site, such as the popular CFC Validator www.javier-julio.com My new site design is up!! Let me know what you all think! Working on a fully accessible Forum, which validates as full CSS and XHTML 1.0 Strict.

mquack
03-07-2007 @ 6:33 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1544
Joined: Jan 2005

A) Why should Pablo pay anyone?  People are here of their own free will.  Mind you, I won't turn down gifts, but I'm not looking for a job, so Pablo, please do not consider putting me on the payroll.  Smile

B) What angry tone?  I certainly haven't seen/perceived an angry tone from Mark.

By the way, on the topic of trim(), it should not be used to ditch whitespace on output.  It should be used to ditch whitespace that a user mistakenly entered in a form field, before entering into the database.  If you're storing a ton of extra whitespace in your database, then there's a programming flaw somewhere.  Smile


www.rachelqueensg.com
Amazon Wish List

PAGE: 1 2

Website Designed and Developed by Pablo Varando.