[*-)]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
 


---------------------------------------------------
Don't forget to "Mark as Answer" if you are satisfied.
0
mds8000
7/15/2007 6:55:48 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

3 Replies
743 Views

Similar Articles

[PageSpeed] 47

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.


Farooq Kaiser, MCTS, MCP
Please Mark As Answer if my answer helped you.
http://www.Fairnet.com
0
farooq
7/15/2007 8:21:14 PM

 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?


---------------------------------------------------
Don't forget to "Mark as Answer" if you are satisfied.
0
mds8000
7/16/2007 7:02:50 AM

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

ALTER TABLE yourTable

DROP COLUMN 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.


Limno

0
limno
7/16/2007 3:02:51 PM
Reply:

Similar Artilces:

When is a column not a column?
I have several extremely similar datawindows that I have to maintain that go against the same table. Recently, I had to add a column to that table, and also add the column to ALL of these datawindows that go against this table. I added the column to the first datawindow, set up the edit control style, etc. I then did a copy/paste of the columns edit control to the remaining dw's (of course remembering to first add the column in SQL). Everything (update props, column specs, column props) seems to indicate that the pasted column is linked to the column I selected, HOWEVER, when I...

SQL: mutiple rows one column to multiple columns one row
In InfoMaker SQL can you take a table with multiple rows for the same key and take a column from the rows and create mutiple columns with one report line with the key(no duplicate keys) on a report? For example Table books (key) (book title) 123 misery 123 titanic 123 roots 456 war 456 1984 456 giant The report I need would look like this Key title1 title2 title 3 123 misery titanic roots 456 war 1984 giant Thanks in advance. -- Kaye Hendry HealthInsight email:kaye.hendry@healthinsight.org ...

How to place in DataGrids’s first column table’s column name, in second Datagrid’s column table’s column value?
Hello I use C#. I’m interesting are there samples solved my problem. Andrew. You will need to loop through the datasource of the datagrid or through the datagrid items and fetch the values for the second datagrid.Sonu Kapoor [MVP] Feel free to ask me any .NET question | Ajax Data Controls Forum Thank you! I solved my problem at the server cite. Andrew. ...

Showing my own column names instead of database column names in datagridview-windows app. C#.net
HiI already bind a DataGridView to a databse. My DataGridView is showing column names as it is in the table. I want to show user-friendly column names in the grid instead of column names in the database table. Please help me in this reagard. Thanx in advance Your statement indicates to me that your columns are dynamically added to the grid, that's why it's showing the database column names. You can show user-friendly column names by changing your query like so: SELECT fName as 'First Name' FROM Users.DarmarkMark as Answer, if this reply answers your post. Go to "E...

SqlBulkCopy: the locale id '0' of the source column '<column name> ' and the locale id '1033' of the destination column '<column name>' do not match.
Hi, I am using the sqlbulkcopy object to transfer large amount of data from one SQL server to Other. The code look like this.. SqlDataReader readerSrc = null;SqlBulkCopy bulkCopy = new SqlBulkCopy(connDest);//Prepare Destination Table.SqlCommand cmdDelete = new SqlCommand("DELETE FROM " + destTableName, connDest);//Set the sqlcommand textSqlCommand cmdGet = new SqlCommand("SELECT * FROM " + srcTableName, connSrc);//Open source connection.connSrc.Open();//Open destination connection.connDest.Open();int delete = cmdDelete.ExecuteNonQuery();//Get the data.readerSrc = cmdGet.ExecuteRead...

SQL query to one column od database into two columns
Hi,I have a empskill Table which has 3 Columns (1) EmpID (2) SkillTypeID and (3) CourseID.Now  SkillTypeID column has data 1 or 2 .......in here 1 means Primary Skill and 2 means Secondary Skill. CourseID will reflect the ID's of subjects like c#,SQL,etc I need a Query which will count the number of primary skilled and number of secondary skilled persons based on subject and will display as followsCOURSE ID      SKILL TYPE  21                        222  &n...

Display multiple columns in Gridview from One Column of SQL table
Hi I have a table in sql with 2 columns and I want to display that in multiple columns in Gridview. SQL Table No.            Type 1               A1 1               B2 2              A2 2               B2 3        &...

How to use a full column name (table name and column name) with a DataReader
Hi, I have a problem retrieving the data with a DataReader from a stored proc that performs a join of two table with the same column's names but different data. Let me explain with an example: I have two tables: Table1: Id, Name Table2: Id, Name, IdTable1 The sproc is something like this: CREATE PROCEDURE [dbo].[SearchByName] (@Name nvarchar(40)) AS BEGIN SELECT * FROM dbo.Table1, dbo.Table2 WHERE Table1.Id = Table2.IdTable1 AND Table1.Name LIKE '%' + @Name + '%' END And my c# code is something like this: Database db = Databas...

SQL query returns 'No column name' as a column heading
 hi,I'm trying to execute this query in SQL Server 2005 Express Edition, the problem is in the column heading of the result for the majorName fieldSELECT studentID,fname,mname,lname,familyName,gpa ,(SELECT majorName AS major FROM major WHERE majorID=(SELECT majorID FROM studentmajorWHERE studentID='0000000'))FROM student WHERE studentID='0000000'; Why the result of this query returns 'No column name' as a label for the majorName field? I use the AS clause to allows the column to be named, the column heading of the result table still 'No column name&...

Get Name of DW Identity Column (column.identity property requires looping thru all columns)
I need to locate the identity column for a DW. Only method i see is use of the columnName.Idenity property - which requires you to traverse all the DW columns and then look up the identity property for each until one is yes. Is there a way just to get the identity column directly - or the Primary Key. thanks, Dave As one can see in he syntax, sorry no. I played around with it this week also as I am using DW.Net2.0 with DataSets and a DataSet can not create update commands from a SQL statements where one has 2 tables. But, now, with the help of DW.Net it can do it ...

SQL,Make Multiple values for multiple columns into one column separated by comma
Hi, I'm getting the result as this Name       Class       Subject------------------------------------------Anju         10             MathsAnju         10             Physics How to write the query to get the result like this Name       Class       Subjects------------...

is it possible to turn 1 column,many rows into one row,many columns in sql ?
 Hi AllI have the following query:Select CategoryName From Category Where CategoryId In(Select SkillId From SpecialitySkills Where CopywriterId = 13) It gives me the correct results but not in the form that i want, i would like it to be in one row, many columns. its in 1 column, many rows.Any ideas?  You must be talking about displaying it on a web page? Just create a loop that runs through the rows of the data that is returned then just make html table:dim tablestring as string = "<table><tr>" for i as integer = 0 to dt.rows.count - 1 tablestring += &...

Writing a column after column
Hi all, I need to consolidate columns of data available across different directories into a single excel csv file. Usually we write to a file row after row but for the current task I have, it would be convenient to write the file column after column. Is there a file writing mode for this? If not, I guess, I will have to write the matrix row by row and then take a transpose. Let me know what you guys think and if you could share some skeleton of code for something like this would be great. Thanks. -vijay vijay wrote: > I need to consolidate columns of data available acro...

validation columns against column
Hi  Do anybody know some articles or codeexample of how to validate columns against a input Column. B can be > A and B can be < C. If you in row ID write 55 for Column_B, it must be reject.example:ID        column_A  Column_B   Column_C1              3               10             152         &...

Web resources about - [*-)]how to delete all columns except one column for the corresponding column name......? - asp.net.sql-datasource

Liberty University students urged to carry guns. Do other schools agree?
Christian Science Monitor Liberty University students urged to carry guns. Do other schools agree? Christian Science Monitor The president ...

Alabama-Michigan St in CFP semifinal at familiar spot
Alabama and Michigan State are playing in the College Football Playoff semifinal at the Cotton Bowl in a stadium where both teams have already ...

At least 32 Islamic State fighters killed in strikes in Syria's Raqqa: monitor
At least 32 Islamic State fighters were killed and 40 more wounded in Syria's Raqqa province on Sunday, in a series of air strikes believed to ...

Arnold Schwarzenegger: Climate Change Hard On The Brain, Global Warming Fight Needs China And U.S. To ...
According to former California governor Arnold Schwarzenegger, climate change science is very difficult for the average brain to understand. ...

Star Wars planetary drinking glasses
Thinkgeek has extended its solar system drinking glasses with a new link of six 10oz Star Wars glasses that symbolize six of the Lucas mythos's ...

Ryan Gosling’s Scarecrow Sharpens ‘Saturday Night Live’ Parody Of ‘The Wiz Live!’
UPDATE, 9:30 AM: Adds full cast of The Wiz Live! parody, below. EARLIER: The cold opening — Taran Killam and Cecily Strong as Donald and Melania ...

Actor Morgan Freeman in plane scare: reports
Morgan Freeman was in for a scare Saturday when his plane experienced problems and had to make an unexpected landing that damaged the aircraft ...

Final Fantasy VII Remake Turns A Cult Classic Into An Action RPG
After announcing it at E3 2015, Square Enix unveiled the first gameplay trailer for one of its most anticipated games, Final Fantasy VII. And ...

Donald Trump: "I'm not playing on fears" of Muslims
CBS News Donald Trump: "I'm not playing on fears" of Muslims CBS News Republican presidential candidate Donald Trump is defending his public ...

Khloe Kardashian Bans Lamar Odom From Home As She Visits Kim Kardashian & Kanye’s Baby Boy & Imparts ...
Since learning that her estranged husband, Lamar Odom, had been found unconscious in a brothel after an alleged drug overdose, Khloe Kardashian ...

Resources last updated: 12/6/2015 6:13:53 PM