Task:
Datatable, DataSet, Dataview and SQL query
Description: Datatable, DataSet, Dataview and SQL query.
1) Merge two DataTable into one.
var dt1 = new DataTable(); //contain data
2) DataView Example of rowfilter, distinct and sorting .
DataTable dtprod= new DataTable(); //contain data
3) SQl query for permission of execution of execute/create/delete/update and and few more quries.
sp_helptext StoredProcdeureName
Execute permission stored procdeure for user
Description: Datatable, DataSet, Dataview and SQL query.
1) Merge two DataTable into one.
var dt1 = new DataTable(); //contain data
var dt2 = new DataTable(); //contain data
var result = dt1.AsEnumerable()
.Union(dt2.AsEnumerable());
DataTable dtnew = result.CopyToDataTable();
2) DataView Example of rowfilter, distinct and sorting .
DataTable dt= new DataTable(); //contain data
DataView dv = new DataView(dt);
DataView dv = new DataView(dt);
dv.RowFilter = "status =1";
dt = dv.ToTable();DataTable dtprod= new DataTable(); //contain data
DataView dv = new DataView(dtprod);
dv.RowFilter
= "status =1";
string[] colname = { "product_id", "product_name", "product_code", "price", "quantity" };
dv.Sort
= "product_code asc";
dtprod= dv.ToTable(true, colname);
3) SQl query for permission of execution of execute/create/delete/update and and few more quries.
sp_helptext StoredProcdeureName
GRANT privileges
ON object TO user;
REVOKE privileges
ON object FROM user;
GRANT EXECUTE TO username;
other permission to user
GRANT SELECT, INSERT, DELETE, UPDATE TO username;
//Delete Duplicate Rows in a Table.
//Delete Duplicate Rows in a Table.
DELETE
FROM TABLENAME
WHERE ID NOT IN
(
SELECT MAX(ID)
FROM TABLENAME
GROUP BY duplicateColumn1, duplicateColumn2)
No comments:
Post a Comment