0

I want to check weather my database contain row or not?
and if it contain then i want to delete that row. this process can be done during run time of page.

3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by Knvn
0

you can count the row inside the table by Count(*) an aggregate function.Then if count greater tahn Zero than.delete that row.

Edited by SiluSilu: n/a

0

suppose student table has lots of row but i want to check whether that table contain row. That is identify by some value like A101(Primary key). So that i want to check student table has any row that contain A101. what should i write in IF condition.

0

I think you are asking the DB query to do this. Well, I guess below is what you are looking for...

--In SQL Server
IF EXISTS(SELECT 1 FROM Student WHERE StudentID = 101)
BEGIN
	DELETE FROM Student WHERE StudentID=101
END
0

You can create a stored procedure with the above command and you can call it from the code wherever you want.

Or

You can execute this command directly from the code using SqlCommand.

Sorry for the delay.....I was on leave!!!!!!!!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.