日期:2014-05-17 浏览次数:20486 次
<?xml version="1.0" encoding="gb2312"?> <books> <book id="0">大江东去</book> <book id="1">东周列国</book> <book id="2">先秦故事</book> <book id="3">三晋之家</book> </books>
--> 测试数据:[tb] IF OBJECT_ID('[tb]') IS NOT NULL DROP TABLE [tb] GO CREATE TABLE [tb]([id] INT IDENTITY(1,1) PRIMARY KEY ,[content] XML) INSERT [tb] SELECT '<?xml version="1.0" encoding="gb2312"?> <books> <book id="0">大江东去</book> <book id="1">东周列国</book> <book id="2">先秦故事</book> <book id="3">三晋之家</book> </books>' --------------开始查询-------------------------- SELECT * FROM [tb]
------解决方案--------------------
这样写就可以了。
INSERT into [tb](content,comm) values((SELECT '<?xml version="1.0" encoding="gb2312"?> <books> <book id="0">大江东去</book> <book id="1">东周列国</book> <book id="2">先秦故事</book> <book id="3">三晋之家</book> </books>'),'hellworld');
------解决方案--------------------
IF OBJECT_ID('[tb]') IS NOT NULL DROP TABLE [tb] GO CREATE TABLE [tb]([id] INT IDENTITY(1,1) PRIMARY KEY ,[content] XML) INSERT [tb] SELECT '<?xml version="1.0" encoding="gb2312"?> <books> <book id="0">大江东去</book> <book id="1">东周列国</book> <book id="2">先秦故事</book> <book id="3">三晋之家</book> </books>' --------------开始查询-------------------------- SELECT * FROM [tb] ----------------------------------------------- INSERT into [tb](content,comm) values((SELECT '<?xml version="1.0" encoding="gb2312"?> <books> <book id="0">大江东去</book> <book id="1">东周列国</book> <book id="2">先秦故事</book> <book id="3">三晋之家</book> </books>'),'hellworld');
------解决方案--------------------
INSERT into [tb](content,comm) values('<?xml version="1.0" encoding="gb2312"?>
<books>
<book id="0">大江东去</book>
<book id="1">东周列国</book>
<book id="2">先秦故事</book>
<book id="3">三晋之家</book>
</books>','hellworld');
把select去掉。
或者去掉括号。 select 'aa','bb'