SQL里TEXT类型的字段如何操作???
我想在一个表a里增加一笔资料时 ,另外一个表b也增加一笔资料, a,b两个表都有Text类型的值! 并且Text类型的字段不能为null
不理解你的意思,数据库里字符类型是char和varchar,char是定长,varchar是不定长度
create table a
(
字段1 char(12) not null ,
字段2 varchar(12)
)
insert into a(字段1,字段2) values(123456789012,)
insert into a(字段1,字段2) values(123456789012,12345)
不理解你操作是什么意思?操作什么?
if exists (select * from dbo.sysobjects where id = object_id(N[dbo].[FK_TABLE2_TABLE1]) and OBJECTPROPERTY(id, NIsForeignKey) = 1)
ALTER TABLE [dbo].[TABLE2] DROP CONSTRAINT FK_TABLE2_TABLE1
GO
if exists (select * from dbo.sysobjects where id = object_id(N[dbo].[TABLE1]) and OBJECTPROPERTY(id, NIsUserTable) = 1)
drop table [dbo].[TABLE1]
GO
if exists (select * from dbo.sysobjects where id = object_id(N[dbo].[TABLE2]) and OBJECTPROPERTY(id, NIsUserTable) = 1)
drop table [dbo].[TABLE2]
GO
CREATE TABLE [dbo].[TABLE1] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[major] [text] COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[TABLE2] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[uid] [int] NULL ,
[aaa] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[bbb] [text] COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
在table1中新建触发器
CREATE TRIGGER [TRI] ON [dbo].[TABLE1]
FOR INSERT, UPDATE, DELETE
AS
insert into table2(uid,aaa,bbb)values(2,asdfasdf,qewrqwer)
请看下面的代码:
create table a(
a int,
aa text)
create table b(
b int,
bb text)
go
insert into a values(1,123541345134523463734eryeryyu4tyu35674u4[4ptoi24-602560235oikt[pwortqwoe)
insert into b values(2,qwer0idvnkdcodafgaiofioasdfipoweriofkjsa)
select * from a
select * from b
go
create trigger tri_ins
on a
for insert
as
select * into b from inserted
go
insert into a values(4,234546wertgsdfgjw9efgtwe0rt`)
它返回下面的错误。
不能在 inserted 表和 deleted 表中使用 text、ntext 或 image 列。
如何解决?
ntext/text/image是有很多操作受限制,这个只能通过外部更新