Click here to Skip to main content
16,009,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello sir,
In my project an employee table is there.having a gridview column of that table i.e. Grade,values are A,B,C,D.And also having a column age .I want to delete the records of grade-A,B,C whose age>58 And of grade-D whose age>60.

Plz sir send the solution. Urgent.
Posted
Updated 5-Dec-12 23:00pm
v3

Hi,

Try this

delete from grade where grade in('A','B','C') and age>58 or grade='d' and age>60
 
Share this answer
 
create a stored pro

create proc proce_name
as begin
Delete A,B,C from table_name where age>58
Delete D from table_name where age>60
end

execute stored
 
Share this answer
 
delete from employee where Grade in ('A','B','c') and age >58
union
delete from employee where grade =D and age >60

This is the query what u required implement as you wise.
 
Share this answer
 
v2
Comments
Devang Vaja 6-Dec-12 5:28am    
u have copypasted only added union..!!!!nice 1 point from me
Patel Shailendra 6-Dec-12 5:36am    
its not the point of comment, the point is resolving the submitted question answer.
delete from employee where Grade in ('A','B','C') and age>58

then second query

delete from employee where Grade='D' and age>60

May this will Help you nalini ji

hApPy cOdInG:)
 
Share this answer
 
cn.ConnectionString = @"Data Source=PHANNY-PC\PHANNY; Initial Catalog=db_stuRegisterPay; Integrated Security=SSPI";
            cn.Open();
SqlCommand com = new SqlCommand();
            com.Connection = cn;
            com.CommandType = CommandType.Text;
          
            com.CommandText = "Delete A,B,C where age>58 and age>60";
com.ExecuteNonQuery();
MessageBox.Show("Saving is done
!");
 
Share this answer
 
v2
hi
you can use sqlCommand from ado.net or newer technology, and delete sql query to remove info from table.
 
Share this answer
 
Comments
Nalini Ranjan Sahoo 6-Dec-12 4:58am    
Sir What is sqlCommand from ado.net?Plz Clarify it.
MohsenSaleh 6-Dec-12 5:15am    
//connection string for connecting to database
SqlConnection cn=new Connection(@"Data Source=PHANNY-PC\PHANNY; Initial Catalog=db_stuRegisterPay; Integrated Security=SSPI");
cn.Open();
//SqlCommand for exacut Command on DB

SqlCommand com = new SqlCommand();
com.Connection = cn;
com.CommandText = "delete from employee where Grade in ('A','B','C') and age>58";
com.ExecuteNonQuery();
MessageBox.Show("Saving is done);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900