Showing posts with label username. Show all posts
Showing posts with label username. 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.

Saturday, February 11, 2012

@Variables

Just trying to confirm what I think I am seeing...
If I run a query which does something like this...
Select @.MyField = UserName
from dbo.signon
running this SQL statement inside a procedure does not produce anything in
terms of output row set? Just trying to confirm, that the client
application which is calling this procedure would not get any rows returned
(in this portion of the code) and that it is just setting some @. variables
for my later use within the Proc. Is that correct?
It is apparently "illegal" for me to have a statement like the following:
Select @.MyField = UserName, password
from dbo.signon
This is not a "real" situation, I am just trying to understand what I can
do and what I can not do. When I try this, I get the following error "A
SELECT statement that assigns a value to a variable must not be combined
with data-retrieval operations.", which brings me to the conclusion that it
is illegal.
So in a situation where I needed to populate a "@.MyField" variable and also
retrieve the password (for some reason), this would be a two step process
(assuming no cursor logic)?
Thanks in advance for your assistance!!!!!!This is a multi-part message in MIME format.
--=_NextPart_000_00AC_01C3E587.E1CFBF20
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: 7bit
No rows will be returned to the client when you use SELECT to populate
variables. You can populate multiple variables concurrently:
Select @.MyField = UserName
, @.MyFiled2 = password
from dbo.signon
Note: If your select would retrieve multiple rows, then the results are
unpredictable.
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Jim Heavey" <JimHeavey@.nospam.com> wrote in message
news:Xns947E5CB70CF08JimHeaveyhotmailcom@.207.46.248.16...
Just trying to confirm what I think I am seeing...
If I run a query which does something like this...
Select @.MyField = UserName
from dbo.signon
running this SQL statement inside a procedure does not produce anything in
terms of output row set? Just trying to confirm, that the client
application which is calling this procedure would not get any rows returned
(in this portion of the code) and that it is just setting some @. variables
for my later use within the Proc. Is that correct?
It is apparently "illegal" for me to have a statement like the following:
Select @.MyField = UserName, password
from dbo.signon
This is not a "real" situation, I am just trying to understand what I can
do and what I can not do. When I try this, I get the following error "A
SELECT statement that assigns a value to a variable must not be combined
with data-retrieval operations.", which brings me to the conclusion that it
is illegal.
So in a situation where I needed to populate a "@.MyField" variable and also
retrieve the password (for some reason), this would be a two step process
(assuming no cursor logic)?
Thanks in advance for your assistance!!!!!!
--=_NextPart_000_00AC_01C3E587.E1CFBF20
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

No rows will be returned to the client =when you use SELECT to populate variables. You can populate multiple =variables concurrently:
Select @.MyField =3D UserName
, @.MyFiled2 =3D = password from dbo.signon
Note: If your select would retrieve multiple rows, then the results =are unpredictable.
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"Jim Heavey" wrote =in message news:Xns9=47E5CB70CF08JimHeaveyhotmailcom@.207.46.248.16...Just trying to confirm what I think I am seeing...If I run a query =which does something like this... Select @.MyField ==3D UserName from dbo.signonrunning this SQL =statement inside a procedure does not produce anything in terms of output row set? Just trying to confirm, that the client application which =is calling this procedure would not get any rows returned (in this =portion of the code) and that it is just setting some @. variables for my later =use within the Proc. Is that correct?It is apparently ="illegal" for me to have a statement like the following: Select =@.MyField =3D UserName, password from =dbo.signonThis is not a "real" situation, I am just trying to understand what I can =do and what I can not do. When I try this, I get the following error "A SELECT statement that assigns a value to a variable must not be =combined with data-retrieval operations.", which brings me to the conclusion =that it is illegal.So in a situation where I needed to populate a ="@.MyField" variable and also retrieve the password (for some reason), this =would be a two step process (assuming no cursor logic)?Thanks in =advance for your assistance!!!!!!

--=_NextPart_000_00AC_01C3E587.E1CFBF20--