# INSERTS with MS SQL Server columns with newid() default values

**URL:** <https://www.ruby-forum.com/t/inserts-with-ms-sql-server-columns-with-newid-default-values/115524>\
**Category:** Rails\
**Created:** [September 25, 2007, 11:41pm UTC](https://www.ruby-forum.com/t/inserts-with-ms-sql-server-columns-with-newid-default-values/115524 "2007-09-25T23:41:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 25, 2007, 11:41pm UTC](https://www.ruby-forum.com/t/inserts-with-ms-sql-server-columns-with-newid-default-values/115524/1 "2007-09-25T23:41:07Z")

</div>

My first steps in RoR … and it turns into a bad dream when it come to  
SQL Server!

I have this table ‘Tbl\_People’, with 2 fields

id\_People primary key, automatically generated by SQL Server  
with newid() default value,  
namePeople is a string

I have an ODBC connection to the database. I can list the records,  
but … I cannot make any inserts in the table. The INSERT string  
generated by Ruby is the following:

INSERT INTO Tbl\_People (id\_People, namePeople) VALUES(‘newid’,  
‘GRONDIER, Evelyne’)

And will be refused because the string ‘newid’ cannot be inserted in  
the uniqueindentifier/primary key field ‘id\_People’.

The error returned is: ‘DBI::DatabaseError: 37000 (8169) [Microsoft]  
[ODBC SQL Server Driver][SQL Server]Conversion failed when converting  
from a character string to uniqueidentifier’

It seems to be so obviously a big and basic problem that I feel I  
missed something usually written in bold on each RoR training document  
such as ‘Don’t try INSERTs through RoR’,‘uniqueIdentifier is Chinese  
to RoR’, or ‘RoR doesn’t work with MS SQL Server’…

Any idea?
