Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

SQL insert error Argument data type text is invalid for argument 1 of replace function

Posted on 2009-02-17
5
Medium Priority
?
556 Views
Last Modified: 2012-05-06
I am running a query on my database to insert values into a table and I keep getting the following error 'Argument data type text is invalid for argument 1 of replace function.'

The query is not using a replace function so I have no idea what is causing the problem. Here's a simple form of the query that fails.

INSERT INTO table_name (field1, field2, field3, field4) VALUES ('test', 'test','test', 'test')  
The table field types are: int (identity), varchar, text, varchar, varchar
0
Comment
Question by:charlesqa
  • 3
  • 2
5 Comments
 
LVL 14

Expert Comment

by:Emes
ID: 23666542
the data type for the first field is not a char.

INSERT INTO table_name (field1, field2, field3, field4) VALUES (2, 'test','test', 'test')  


0
 

Author Comment

by:charlesqa
ID: 23666557
I am confused. The first field in the table is the id column which is an identity field and should be auto incrementing. Which is why the insert statement only includes the varchar/text field entries. I am misunderstanding your explanation?
0
 

Author Comment

by:charlesqa
ID: 23666576
Sorry just to clarify the field types:
field1 = varchar
field2 = text
field3 = varchar
field4 = varchar
The int field is the primary key and an identity column that is not specified in the INSERT statement.
0
 
LVL 14

Accepted Solution

by:
Emes earned 500 total points
ID: 23666680
do you have a trigger on this table?
0
 

Author Comment

by:charlesqa
ID: 23666708
That was it. This is inherited code and for the life of me I could not figure out why it was failing. There was a trigger that did a REPLACE function which of course does not work on the text datatype.
Thanks for the insight.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question