I have done many inserts/updates and question that always was on the top of my mind is where I should trim the values that I'm inserting or updating. In this case I use ColdFusion as my server-side programming language and SQL Microsoft is my database language. So if I'm doing insert, should I trim the values in ColdFusion or SQL? Do I have to do in both? What is more efficient? I was wondering if this can improve efficiency if I follow some recommended steps. Here is example that I have in one of my Insert codes:
<cfset userphone = trim(user_phonenum)>
<cfset userdob = trim(user_dob)>
INSERT INTO UserTest
( mm_phone,
mm_dob
)
VALUES
(
'#trim(userphone)#',
CASE WHEN LTRIM(RTRIM('#userdob#')) = '' THEN NULL ELSE LTRIM(RTRIM('#userdob#')) END
)
In the code above I have used ColdFusion trim where I set both values userphone
and userdob
. Should I do the trim there or down below in SQL Insert statement? What is better and more efficient? If anyone can help please let me know. Thank you.