create view VIEW_A
{
user varchar(20),
password varchar(20),
kind varchar(2)
}
;
insert into VIEW_A(user,password,kind) select user,password,'A' from A;
insert into VIEW_A(user,password,kind) select user,password,'B' from A;
insert into VIEW_A(user,password,kind) select user,password,'C' from A;
Go
{
user varchar(20),
password varchar(20),
kind varchar(2)
}
;
insert into VIEW_A(user,password,kind) select user,password,'A' from A;
insert into VIEW_A(user,password,kind) select user,password,'B' from A;
insert into VIEW_A(user,password,kind) select user,password,'C' from A;
Go
解决方案 »
- 求助 sql 使某一列在原有基础上增加一些内容
- 如果经常要选择某列等于特定值的数据集,是不是把这些数据放一表好些?
- 为什么SQL2K装上SP3和SQL2005装上SP2后显示的还是SP1
- sql = "select * from Products where ID in ("getID.Substring(0,getID.Length-1))")"这样写有错吗??
- SQL2000备份文件如何还原到SQL2005中....?
- 求sql,
- SQL 2005 SP3 日志截取
- 各位高手,请个这个触发器要怎么弄啊?
- 70M,12万条txt数据(12到100个字段,用标准的“|”割开,每个字段为30~40个CNMARC字符)导入sql server2000/97出的数据丢失问题!
- 请问在sql server中如何解决行锁定的问题?(急!!)
- 又是字符替换问题,紧急求助。。。。。。
- 怎样从sql语句取数据出来放到程序中?
是
create view VIEW_A
{
user varchar(20),
password varchar(20),
kind varchar(2)
}
;
insert into VIEW_A(user,password,kind) select user,password,'A' from A;
insert into VIEW_A(user,password,kind) select user,password,'B' from B;
insert into VIEW_A(user,password,kind) select user,password,'C' from C;
Go
select 'TableA' as from, USER,PASSWORD from tableA
union all
select 'TableB' as from, USER,PASSWORD from tableB
union all
select 'TableC' as from, USER,PASSWORD from tableC
go
union all
select user , password , 'B' kind Form TB
union all
select user , password , 'C' kind Form TC这样就可以了,但是在保存为视图的时候有个技巧,要不sql会认为你写的代码是非法的。
方法就是,先写一个简单的视图,保存,退出,然后双击那个视图,把上面的sql语句copy到视图中,点击保存,搞定。
as
select user , password , 'A' kind Form A
union all
select user , password , 'B' kind Form B
union all
select user , password , 'C' kind Form C
as
(
select user , password , 'A' as kind Form A
union
select user , password , 'B' as kind Form B
union
select user , password , 'C' as kind Form C
)
select 'TableA' as from, USER,PASSWORD from tableA
union all
select 'TableB' as from, USER,PASSWORD from tableB
union all
select 'TableC' as from, USER,PASSWORD from tableC
go