0

I want to insert a row into a SQL Server table via Laravel Query Builder.

I'm converting unicode characters with the method below:

mb_convert_encoding($value, 'UCS-2LE', mb_detect_encoding($value, mb_detect_order(), true))

Everything works fine except for ntext fields. I cannot insert a row if there exists an ntext field. I can insert as NULL. But I cannot insert anyting in the ntext field.

But inserting for other types is working fine. And I'm getting a SQL Server 206 error when the data for the ntext field is not null.

What is the problem ?

TT.
  • 15,774
  • 6
  • 47
  • 88
Cihan Küsmez
  • 1,967
  • 5
  • 22
  • 41
  • 1
    Well, Unless you are working with a very old version of sql server (that is, before 2008), you souldn't use `text` or `ntext` at all. Instead, you should use `varchar(max)` or `nvarchar(max)`. If possible, I would suggest changing the data type of the `ntext` columns. – Zohar Peled Nov 13 '16 at 07:32
  • [Official reference](https://msdn.microsoft.com/nl-be/library/ms187993.aspx) of what Zohar said: `IMPORTANT! ntext, text, and image data types will be removed in a future version of SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.` – TT. Nov 13 '16 at 08:08
  • Can you edit your question and include the actual `INSERT` statement? – TT. Nov 13 '16 at 08:10
  • @ZoharPeled I'm not using these field types. This is not my system. I am building an integration system. – Cihan Küsmez Nov 22 '16 at 13:20

0 Answers0