Hello Guys,
I have question concerning IF EXISTS (this statement is not correct but I would like to test if this select statement is true, if it is I qould like to insert the @DATE, @VALUE_, @S, @T of table @QT1 into the table QT)
I would like to do a test:
DECLARE @DATE_ datetime
DECLARE @VALUE_ varchar(100)
DECLARE @T_ varchar(30)
DECLARE @S_ varchar(30)
DECLARE @Max_ID int
/* the max of SEEDID */
SET SELECT TOP 1 @Max_ID = SEEDID from QT order by SEEDID desc
SET @Max_ID = @Max_ID + 1
/* if this condition is not null */
IF EXISTS (
SET SELECT @DATE_ =DATE, @VALUE_ = VALUE_, @S_ = S, @T_ = T
FROM
WHERE QT1.SC = 7 and QT1.code= 1476 and QT1.DATE not in (
SELECT QT.DATE
FROMWHERE QT.SC = 7 and QT.code = 1476) IS NOT NULL)
/* insert into QT */
INSERT INTO QT (SEEDID, CODE, S, DATE, VALUE_, SC. T)
VALUES ( @Max_ID, 1476, 'HS', @S_, @DATE_, @VALUE_, 7, @T_ )
any suggestion how to do that?
Thanks on advance
Ina
I have question concerning IF EXISTS (this statement is not correct but I would like to test if this select statement is true, if it is I qould like to insert the @DATE, @VALUE_, @S, @T of table @QT1 into the table QT)
I would like to do a test:
DECLARE @DATE_ datetime
DECLARE @VALUE_ varchar(100)
DECLARE @T_ varchar(30)
DECLARE @S_ varchar(30)
DECLARE @Max_ID int
/* the max of SEEDID */
SET SELECT TOP 1 @Max_ID = SEEDID from QT order by SEEDID desc
SET @Max_ID = @Max_ID + 1
/* if this condition is not null */
IF EXISTS (
SET SELECT @DATE_ =DATE, @VALUE_ = VALUE_, @S_ = S, @T_ = T
FROM
WHERE QT1.SC = 7 and QT1.code= 1476 and QT1.DATE not in (
SELECT QT.DATE
FROMWHERE QT.SC = 7 and QT.code = 1476) IS NOT NULL)
/* insert into QT */
INSERT INTO QT (SEEDID, CODE, S, DATE, VALUE_, SC. T)
VALUES ( @Max_ID, 1476, 'HS', @S_, @DATE_, @VALUE_, 7, @T_ )
any suggestion how to do that?
Thanks on advance
Ina