Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

using trim with SQL

Guest
Apr 20, 2006 Apr 20, 2006
I've attempted to use trim() im my SQL statement but It throws an error saying its not a valid function.

This isnt the statement but this is the context im using it in.

<cfquery datasource="#datasources.DATADSN#">
INSERT INTO dbo.People (Christian)
<cfif IsDefined("FORM.Christian") AND #FORM.Christian# NEQ "">
trim('#FORM.Christian#')
<cfelse>
NULL
</cfif>
</cfquery>

If you cant use it at this point, where can you use it?
458
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Apr 20, 2006 Apr 20, 2006
If you are just trying to trim leading/trailing whitespace, here is the correct syntax:

<cfquery datasource="#datasources.DATADSN#">
INSERT INTO dbo.People (Christian)
<cfif IsDefined("FORM.Christian") AND Trim(FORM.Christian) NEQ "">
#Trim(FORM.Christian)#
<cfelse>
NULL
</cfif>
</cfquery>
Translate
Guest
Apr 20, 2006 Apr 20, 2006
It looks like you're using SQL Server. SQL Server 2000 doesn't have a unified trim function, you need to left and right-trim. Try LTrim ( Rtrim ('#FORM.Christian#')).
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 20, 2006 Apr 20, 2006
LATEST
If you are just trying to trim leading/trailing whitespace, here is the correct syntax:

<cfquery datasource="#datasources.DATADSN#">
INSERT INTO dbo.People (Christian)
<cfif IsDefined("FORM.Christian") AND Trim(FORM.Christian) NEQ "">
#Trim(FORM.Christian)#
<cfelse>
NULL
</cfif>
</cfquery>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources