Showing posts with label corresponding. Show all posts
Showing posts with label corresponding. Show all posts

Monday, February 13, 2012

[*-)]how to delete all columns except one column for the corresponding column name......?

hi friends,

i've a table with (columns) username, content,data,......... i need to delete all column names(i.e.,content,data,......) except username for the specified username. eg: consider username=mahendran. i've to delete the values in the content,data,............for the username=mahendran. but username should exist.

how to do that?pls help me.....Confused

Use the following

DataTable.Columns.Remove takes the column name or column reference as argument.

To remove column using it's index, you can use DataTable.Columns.RemoveAt method.

|||

hi farooq,

i need the SQL query for delete command. i wrote

delete [contact],[title] from <table_name> where userid=<user_id>

but it is not working.what is the correct format?

|||

If you want to change your table structure, you useAlter Table along withDrop Column instead of Delete which is for your records. Here is a sample:

ALTERTABLE yourTable

DROPCOLUMN col2, col3

You can find more information about SQL DML(SQL Data Manipulation Language) and DDL(SQL Data Definition Language) if you are interested about the topic.