我的MSN是[email protected]
希望有高手可以为我解答
希望有高手可以为我解答
解决方案 »
- 求助:asp.net连接不上另外一台电脑上的sql server
- 请教一个变量的问题
- sp3怎么装
- 以前安装过Mysql,后来没用删除了,今天重新安装出现了问题
- SQL Server 2000 对硬件的要求,哪位可以总结一下。谢谢
- 我想写个存储过程,在输入@col_nam(某列的名字)和@keyword后能从表中找出列@col_nam
- 请教高手有关sql2000数据库备份的问题,急!急!!急!!!
- 在設計數據庫表時碰到多對多(即n對m)怎麼辦?? 請教前輩,大家都來把我的帖子向前推
- 在sql server中可以在select 中用if嗎
- SQL SERVER 有没有与 ORACLE 里的 NVL()等效的函数
- 请教高手解决 Invalid attribute/option identifier 难题
- 服务器的MSSQL数据库为什么不可以在别的电脑上连接进去[急]
from tablename
where PriceValueBegin>5.5
and PriceValueEnd <=5.5
select Quotiety
from tablename
where PriceValueBegin<=5.5
and PriceValueEnd >5.5对新纪录的判断:
if exists (
select 1 from tablename where
(PriceValueBegin<=5 and
and PriceValueEnd >5)
or (PriceValueBegin<=7 and
and PriceValueEnd >7)
if exists (
select 1 from tablename where
(PriceValueBegin<=5 and
and PriceValueEnd >5)
or (PriceValueBegin<=7 and
and PriceValueEnd >7)
)
print '5-7有重复'
就是给这个表添加加价率
比如已经有
5 7 1.2
8 9 1.23
11 15 1.55我添加6-10时,就要判断是否已经有相同那一段的值,6-10元这间,包括5-7中和8-9中的部分,所以添加就不能成功,我的意思是如何判断比较好不知道有没有是否做过这样的设计
你的方法有些仍然不能判断到所有的比如
5 6
6 8
9 10理论上来说我应该能添加8-9,
因为我的单价是满足>=PriceValueBegin,<PriceValueEnd的
if exists (
select 1 from tablename where
(PriceValueBegin<=8 and
and PriceValueEnd >8)
or (PriceValueBegin<=9 and
and PriceValueEnd >9)
) print '8-9有重复'
if exists (
select 1 from tablename where
(PriceValueBegin<=8 and
and PriceValueEnd >8)
or (PriceValueBegin<=9 and
and PriceValueEnd >9)
) print '8-9有重复'
5 6
的意思是(5,6]或者[5,6),不能是[5,6]或者(5,6)如果是[5,6)
那8 9的判断是if exists (
select 1 from tablename where
(PriceValueBegin<=8
and PriceValueEnd >8)
or (PriceValueBegin<9
and PriceValueEnd >9)
) print '8-9有重复'
如果是(5,6]
那8 9的判断是if exists (
select 1 from tablename where
(PriceValueBegin<8
and PriceValueEnd >8)
or (PriceValueBegin<=9
and PriceValueEnd >9)
) print '8-9有重复'
PriceValueEnd 是<PriceValueEnd
@PriceValueBegin money,
@PriceValueEnd money
select 1 from PriceQuotiety where
(PriceValueBegin<@PriceValueBegin and PriceValueEnd >@PriceValueBegin) or (PriceValueBegin<@PriceValueEnd and PriceValueEnd >@PriceValueEnd)
set @num=(select count(*) from table_name
where (@start between PriceValueBegin and PriceValueEnd)
or (@end between PriceValueBegin and PriceValueEnd) )
if @num=0 then
begin
print 'it can be Add!'
end
CREATE PROCEDURE PriceQuotiety_Exists
@PriceValueBegin money,
@PriceValueEnd money
AS
DECLARE @Err int --是否存在--判断是否已经有这个起始价
IF EXISTS(SELECT * FROM PriceQuotiety WHERE PriceValueBegin=@PriceValueBegin)
BEGIN
SET @Err = 0
END
ELSE
BEGIN
--判断结束值是否已经有了
IF EXISTS(SELECT * FROM PriceQuotiety WHERE PriceValueEnd=@PriceValueEnd)
BEGIN
SET @Err = 0
END
ELSE
BEGIN
IF EXISTS(select 1 from PriceQuotiety where (PriceValueBegin<@PriceValueBegin and PriceValueEnd >@PriceValueBegin) or (PriceValueBegin<@PriceValueEnd and PriceValueEnd >@PriceValueEnd))
BEGIN
SET @Err = 0
END
ELSE
SET @Err = 1
END
END
RETURN @Err
GO
CREATE PROCEDURE PriceQuotiety_Exists
@PriceValueBegin money,
@PriceValueEnd money
AS
DECLARE @Err int --是否存在--判断是否已经有这个起始价
IF EXISTS(SELECT * FROM PriceQuotiety WHERE PriceValueBegin=@PriceValueBegin)
BEGIN
SET @Err = 0
END
ELSE
BEGIN
--判断结束值是否已经有了
IF EXISTS(SELECT * FROM PriceQuotiety WHERE PriceValueEnd=@PriceValueEnd)
BEGIN
SET @Err = 0
END
ELSE
BEGIN
IF EXISTS(select 1 from PriceQuotiety where (PriceValueBegin<@PriceValueBegin and PriceValueEnd >@PriceValueBegin) or (PriceValueBegin<@PriceValueEnd and PriceValueEnd >@PriceValueEnd))
BEGIN
SET @Err = 0
END
ELSE
SET @Err = 1
END
END
RETURN @Err
GO
@PriceValueBegin money,
@PriceValueEnd money
AS
DECLARE @Err int --是否存在--判断是否已经有这个起始价
IF EXISTS(select 1 from PriceQuotiety where (PriceValueBegin<=@PriceValueBegin and PriceValueEnd >@PriceValueBegin) or (PriceValueBegin<@PriceValueEnd and PriceValueEnd >@PriceValueEnd))
BEGIN
SET @Err = 0
END
ELSE
SET @Err = 1
RETURN @Err
GO