0

I use Laravel 5.8 to insert row to MsSQL database

Model::insert([
  'name' => '中文字'
]);

The output SQL is

insert into table_name (name) values ('中文字')

But it's miss N char before string character. How to set N before string character by auto. Like this

insert into table_name (name) values (N'中文字')
Jay Chu
  • 45
  • 8
  • Have you tried `INSERT INTO table_name (name) VALUES ('N中文字')` – Ajith Jul 23 '20 at 06:43
  • Seems there is some confusion as to where the N should be, this isn't adding the N to the string, but a prefix to the string to show it's unicode ([What does N' stands for in a SQL script](https://stackoverflow.com/questions/14353238/what-does-n-stands-for-in-a-sql-script-the-one-used-before-characters-in-ins) I think shows what they mean) – Nigel Ren Jul 23 '20 at 07:08
  • 1
    You should probably log an Issue with the Laravel project on Github. Seems like a bug given that the SQLServer grammar implementation uses nvarchar datatype for all string columns. – AlwaysLearning Jul 23 '20 at 07:23
  • Is this causing real issues? It'd be a strange oversight for a major framework. Doesn't Laravel use prepared statements and bound parameters? – Álvaro González Jul 23 '20 at 14:57

0 Answers0