现有:
表a用来记录表名
id name
1 b
2 c
存在表b,
现在要删除表b: drop b,但前提是在表a中存在name='b',语句该怎么写?一句完成哦
SQL code:
if exists(select 1 from a where name='b')
drop table b
go
SQL code:
Create Table a
(
[id] int not null,
[ ......
我想查出 类型名字是‘单方精油’的所有 产品 我写了一条但是不对:
select pro_ID,pro_Name,prc_Name,pro_Content,pro_Nums,pro_Price,pro_MoneyType,pro_BigPicUrl,pro_Intro from
WT_Products,WT_ProCategory
where WT_Products.prc_ID= WT_ProCategory.prc_ID and prc_Name='单方精油' and pr ......
如上图,这其实是一个巡更班次表,其中4:00:00对应的ClassGroupID是当天的第一班组的ID,小于这个时间的应该算是前一天的最后一个班组的了,现在要用语句取得ClassGroupID的顺序为 11,12,13,但是不能以order by classgroupid asc这么来,因为这个ID的大小不能作为排序依据
我用这个语句取得的就不对了,事实上ClassGroupID ......
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间内的期初金额,本期入库金额,本期出库金额,本期结存。
kindname,beginmoney,insummoney,outsummoney,end ......
若输入'12:01|14:05|16:15|19:13'
循环输出|隔开的字符串,结果是:12:01 14:05 16:15 19:13
用while循环实现.(有可循环4次,必须得用while循环) 谢谢!
引用
SQL codedeclare@svarchar(1000)set@s='12:01|14:05|16:15|19:13'declare@ttable(tvarchar(10))set@s=@s+' ......
A表
A列 int
B列 int
如果在插入过程中A列的值大于9,则B列自动为1.此时A列清0;
雁
SQL code:
create trigger tri_insert_tb
on tb
instead of insert
as
if exists(select 1 from inserted where a>9)
begin
insert tb(a,b)
select 0,1
from inserted
where a>9
end
......