从字符串转换为 uniqueidentifier 时转换失败 - 两个 GUID [英] Conversion failed when converting from a character string to uniqueidentifier - Two GUIDs

查看:49
本文介绍了从字符串转换为 uniqueidentifier 时转换失败 - 两个 GUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么我不能插入这个.我看不出问题.错误信息是从字符串转换为 uniqueidentifier 时转换失败.

I don't understand why I can't insert this. I can't spot the problem. The error message is Conversion failed when converting from a character string to uniqueidentifier.

GUID 是我从其他一些表中选择时得到的.

The GUIDs are the ones that I got when I did a select from some other tables.

insert into [db].[dbo].[table] (myid,friendid,time1,time2) values
 ( CONVERT(uniqueidentifier,'0C6A36BA-10E4-438F-BA86-0D5B68A2BB15'),
   CONVERT(uniqueidentifier,'DF215E10-8BD4-4401-B2DC-99BB03135F2E'),
'2014-01-05 02:04:41.953','2014-01-05 12:04:41.953')

我使用 SQL Server 2012

I use SQL Server 2012

列是

id        uniqueidentifier,
myid      uniqueidentifier,
friendid  uniqueidentifier,
time1     datetime nullable,
time2     datetime nullable

推荐答案

问题是 ID 列没有获得任何值.我在@Martin Smith SQL Fiddle 上看到他用 DEFAULT newid 声明了 ID 列,但我没有..

The problem was that the ID column wasn't getting any value. I saw on @Martin Smith SQL Fiddle that he declared the ID column with DEFAULT newid and I didn't..

这篇关于从字符串转换为 uniqueidentifier 时转换失败 - 两个 GUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆