Monday, March 26, 2012

INSERT WHERE

Is there any Sql Cluase to say insert if the record not found in a single
statement
i.e : INSERT INTO STUDENTSVALUES('RKNET')
where not exists Name='RKNET'
thnaks in advance.
RKNETI made a query using IF clause.
IF NOT EXISTS( SELECT Name FROM STUDENTS WHERE Name='RKNET' )
INSERT INTO STUDENTSVALUES('RKNET')
"RKNET"?? ??? ??:

> Is there any Sql Cluase to say insert if the record not found in a single
> statement
> i.e : INSERT INTO STUDENTSVALUES('RKNET')
> where not exists Name='RKNET'
> thnaks in advance.
> RKNET|||> Is there any Sql Cluase to say insert if the record not found in a single
> statement
Try this
IF NOT EXISTS (SELECT * FROM table WHERE [name]='RKNET')
INSERT INTO STUDENTSVALUES('RKNET')
ELSE
blabla
"RKNET" <RKNET@.discussions.microsoft.com> wrote in message
news:2049DBD3-2B67-4A09-B77D-604CF570D592@.microsoft.com...
> Is there any Sql Cluase to say insert if the record not found in a single
> statement
> i.e : INSERT INTO STUDENTSVALUES('RKNET')
> where not exists Name='RKNET'
> thnaks in advance.
> RKNET

No comments:

Post a Comment