Select Query As Column Data

Aug 8, 2013

Outer query: select op.const_cd, (select const_hin from constituency c where c.const_cd=op.const_cd) from PollingStation op, constituency c

where op.const_cd=c.const_cd

group by op.const_cd
order by op.const_cd

Result is:
122 a 205
123 b 205
124 c 235
125 d 191
126 e 226
127 f 159
128 g 165
129 h 175
130 i 225
131 j 213

Inner Query result of: select const_cd, count(polling_cd) from PollingStation p where right(polling_cd,1)='A' group by p.const_cd order by p.const_cd:

122 4
123 4
124 2
125 3
126 1
127 6
128 11
129 9
130 2

I want this output:

const_cd const_name count inner query
122 a 205 4
123 b 205 4
124 c 235 2
125 d 191 3
126 e 226 1
127 f 159 6
128 g 165 11
129 h 175 9
130 i 225 2
131 j 213

View 8 Replies


ADVERTISEMENT

How To Write Query To Select Second Row Column Data

Nov 18, 2013

I have a requirement like below .

Input table will be like below:

eventdata:
accountID deviceID timestamp speedKPH address
--------- -------- ---------- -------- -------------
preva1 bolero 1359089006 15 Ullalu Road
preva1 bolero 1359088796 0 Ullalu Road
preva1 bolero 1359088886 0 Ullalu Road
preva1 bolero 1359088888 8.47 Ullalu Road
preva1 bolero 1359088986 0 Ullalu Road
preva1 bolero 1359088988 45 Ullalu Road
preva1 bolero 1359088996 21 Ullalu Road
preva1 bolero 1359088998 0 Ullalu Road
preva1 bolero 1359089006 15 Ullalu Road
preva1 bolero 1359089009 12 Ullalu Road
preva1 bolero 1359089006 15 Ullalu Road
preva1 bolero 1359089016 0 Ullalu Road
preva1 bolero 1359089026 0 Ullalu Road

So here i need output table like below:

stoppagedetails:
accountID deviceID from_timestamp to_timestamp diff
--------- -------- ---------- -------- -------------
preva1 bolero 1359088796 1359088888 92
preva1 bolero 1359088986 1359088988 2
preva1 bolero 1359088998 1359089006 8
preva1 bolero 1359089016

How to write mysql query for the above requirement.

View 3 Replies View Related

Data Access :: How To Get Min Of More Than One Column In Select Query

Nov 24, 2015

I am using SQL select query to select MIN from column data but I have 12 columns and want to select MIN of all these 6 columns in one SQL select statement.

I have written as SELECT MIN(temp_sv,humidity_sv,SH1,SH2,SH3,SH4) from production but its not working... How to do this....

View 4 Replies View Related

Query - Select Common Data From One Column And Display In Severalcolumns

Feb 28, 2008

Hello,I have a (big) table which is not normalized, but for i need at themoment i thinkthat's no problem. Indeed, what i would like to do is to select thename field andthe note. The problem is that i want to display the note in 2different columns.the first columns will show the number (count) of time that a certainnote (e.g note=4)appears for a certain name and in the other column the same thing butfor a different note value.so each column noteX will display the number of time that the notewith the value X appears for each namefor example, to the following table:Name | note | job | city | id |----------------------------------------john | 4 | jb1 | hamb | 1 |john | 5 | jb2 | hamb | 2 |john | 5 | jb3 | hamb | 3 |john | 5 | jb4 | hamb | 4 |Mark | 4 | jb1 | mun | 5 |Mark | 4 | jb2 | mun | 6 |Mark | 4 | jb5 | mun | 7 |Mark | 5 | jb1 | mun | 8 |peter | 5 | jb3 | berl | 9 |peter | 5 | jb5 | berl | 10 |frank | 4 | jb6 | v.form | 11 |frank | 5 | jb3 | v.form | 12 |frank | 5 | jb2 | v.form | 13 |the result should be:Name | note5 | note4 |-------------------------john | 3 | 1 |Mark | 1 | 3 |peter | 2 | 0 |frank | 2 | 1 |How should be the right SQL command to show the data i want?Rui DiasJoin Bytes!Thanks a lot

View 5 Replies View Related

Return The Results Of A Select Query In A Column Of Another Select Query.

Feb 8, 2008

Not sure if this is possible, but maybe. I have a table that contains a bunch of logs.
I'm doing something like SELECT * FROM LOGS. The primary key in this table is LogID.
I have another table that contains error messages. Each LogID could have multiple error messages associated with it. To get the error messages.
When I perform my first select query listed above, I would like one of the columns to be populated with ALL the error messages for that particular LogID (SELECT * FROM ERRORS WHERE LogID = MyLogID).
Any thoughts as to how I could accomplish such a daring feat?

View 9 Replies View Related

Transact SQL :: SELECT On Column Name From Query Result Set In Same Query?

May 9, 2015

I have a column colC in a table myTable that has a value (e.g. '0X'). The position of a non-zero character in column colC refers to the ordinal position of another column in the table myTable (in the aforementioned example, colB).

To get a column name (i.e., colA or colB) from table myTable, I can join ("ON cte.pos = cn.ORDINAL_POSITION") to INFORMATION_SCHEMA.COLUMNS for that table catalog, schema and name. But I want to show the value of what is in that column (e.g., 'ABC'), not just the name. Hoping for:

COLUMN_NAME Value
----------- -----
colB        123
colA        XYZ

I've tried dynamic SQL to no success, probably not executing the concept correctly...

Below is what I have:

CREATE TABLE myTable (colA VARCHAR(3), colB VARCHAR(3), colC VARCHAR(3))
INSERT INTO myTable (colA, colB, colC) VALUES ('ABC', '123', '0X')
INSERT INTO myTable (colA, colB, colC) VALUES ('XYZ', '789', 'X0')
;WITH cte AS
(
SELECT CAST(PATINDEX('%[^0]%', colC) AS SMALLINT) pos, STUFF(colC, 1, PATINDEX('%[^0]%', colC), '') colC

[Code] ....

View 4 Replies View Related

Select Query For Column

Mar 13, 2008

i have one table called Healthmanagement
in that i have column HealthTitles in that there r so many rows..few of them r here:

HealthTitles
---------------------------------
Lung Health
Lung Health: General
Lung Health: Asperic Detailed Modified
Diseases
Diseases: in one generation
Attacks
Attacks: Health Related

i want in ouput all rows but which r with ':' i want after that part only and if the rows r without ':' then remain as it is:

so i want

HealthTitles
---------------------------------
Lung Health
General
Asperic Detailed Modified
Diseases
in one generation
Attacks
Health Related

how can i get that?
thanks for any help.

View 4 Replies View Related

Select Query With Incremental Column On The Fly?

Jul 10, 2007

Hi, all.
I want to Select query with incremental column on the fly.

For example
Use pubs
GO
select * from jobs where job_desc like '%e%' Order by max_lvl
returns
job_idjob_descmin_lvlmax_lvl
1New Hire - Job not specified1010
12Editor25100
13Sales Representative25100
...

I want to add here Rank Column numbering in order
select RankOnTheFly, * from jobs where job_desc like '%e%' Order by max_lvl
Then result will be..
Rankjob_idjob_descmin_lvlmax_lvl
11New Hire - Job not specified1010
212Editor25100
313Sales Representative25100
..

I can get the result using cursor and looping throught and inserting or Using Identity function.
But, I saw before there is just one simple Select query doing that.

Does anyone know this?
Thank you..

View 12 Replies View Related

Null Value In Column In Select Query

Mar 18, 2015

Suppose I have added a xyz bit column in mytable. From now onwards new values inserted in mytable will have 0 or 1 in xyz column but the values that were previously stored will have NULL value in xyz column.

Now I want to write a query in which I will not give xyz parameter always like it can be null or value.

select * from mytable
where class='something'
and xyz is null

or

select * from mytable
where class='something'
and xyz = 1

Now how to write same query for both cases.

View 9 Replies View Related

Add A Column Based On A Select Query

Mar 5, 2006

Supose I have the following select:

Select Name, Age, (select TelNums from Telephone)
From Person

The problem is that (select TelNums from Telephone) can return more than 1 record:

tel1
tel2
.
.
.

I was wondering how I can make a select to return the tel numbers like: 'tel1,tel2,tel2'

»»» Ken.A

View 3 Replies View Related

Format Of DateTime Column In SELECT Query

Dec 19, 2006

I am using SQL2005 and ASP.NET 2.0
I have one column in database called DateTime and it is defined like type datetime.It is formated like: day.month.year hour:minutes:seconds
My question is: I want to get date from Column DateTime in format day.month.year in SELECT query, not in stored procedure.
 thanks

View 3 Replies View Related

SELECT Query (rows Returned In One Column)?

Aug 17, 2005

Hi there,

I¡¦ve got a table with the following as well as other info:

User ID
DirectoryTypeID (int)
Region ID (int)

I need to run a query where I could get the region ID, then, in the second column, I¡¦d get all distinct directory types within that region. For example, if I run the query:

subRegionAreaID directoryTypeID
--------------- ---------------
3 1
3 2
3 3
3 9

If need these results to be:

subRegionAreaID directoryTypeID
--------------- ---------------
3 1, 2, 3, 9

Is this possible?

Many Thanks!! ļ


Grazi

View 1 Replies View Related

SQL Server 2008 :: SELECT On Column Name From Querys Resultset In Same Query?

May 9, 2015

I have a column colC in a table myTable that has a value (e.g. '0X'). The position of a non-zero character in column colC refers to the ordinal position of another column in the table myTable (in the aforementioned example, colB).To get a column name (i.e., colA or colB) from table myTable, I can join ("ON cte.pos = cn.ORDINAL_POSITION") to INFORMATION_SCHEMA.COLUMNS for that table catalog, schema and name. But I want to show the value of what is in that column (e.g., 'ABC'), not just the name. Hoping for:

COLUMN_NAME Value
----------- -----
colB 123
colA XYZ

I've tried dynamic SQL to no success, probably not executing the concept correctly..Below is what I have:

CREATE TABLE myTable (colA VARCHAR(3), colB VARCHAR(3), colC VARCHAR(3))
INSERT INTO myTable (colA, colB, colC) VALUES ('ABC', '123', '0X')
INSERT INTO myTable (colA, colB, colC) VALUES ('XYZ', '789', 'X0')

;WITH cte AS
(
SELECT CAST(PATINDEX('%[^0]%', colC) AS SMALLINT) pos, STUFF(colC, 1, PATINDEX('%[^0]%', colC), '') colC
FROM myTable

[code]....

View 5 Replies View Related

HELP With SQL Query: Select Multiple Values From One Column Based On &&<= Condition.

Aug 7, 2007

Hello all. I hope someone can offer me some help. I'm trying to construct a SQL statement that will be run on a Dataset that I have. The trick is that there are many conditions that can apply. I'll describe my situation:

I have about 1700 records in a datatable titled "AISC_Shapes_Table" with 49 columns. What I would like to do is allow the user of my VB application to 'create' a custom query (i.e. advanced search). For now, I'll just discuss two columns; The Section Label titled "AISC_MANUAL_LABEL" and the Weight column "W". The data appears in the following manner:

(AISC_Shapes_Table)

AISC_MANUAL_LABEL W
W44x300 300
W42x200 200
(and so on)
WT22x150 150
WT21x100 100

(and so on)
MT12.5x12.4 12.4
MT12x10 10
(etc.)

I have a listbox which users can select MULTIPLE "Manual Labels" or shapes. They then select a property (W for weight, in this case) and a limitation (greater than a value, less than a value, or between two values). From all this, I create a custom Query string or filter to apply to my BindingSource.Filter method. However I have to use the % wildcard to deal with exceptions. If the user only wants W shapes, I use "...LIKE 'W%'" and "...NOT LIKE 'WT%" to be sure to select ONLY W shapes and no WT's. The problems arises, however, when the user wants multiple shapes in general. If I want to select all the "AISC_MANUAL_LABEL" values with W <= 40, I can't do it. An example of a statement I tried to use to select WT% Labels and MT% labels with weight (W)<=100 is:




Code SnippetSELECT AISC_MANUAL_LABEL, W
FROM AISC_Shape_Table
WHERE (W <= 100) AND ((AISC_MANUAL_LABEL LIKE 'MT%') AND (AISC_MANUAL_LABEL LIKE 'WT%'))



It returns a NULL value to me, which i know is NOT because no such values exist. So, I further investigated and tried to use a subquery seeing if IN, ANY, or ALL would work, but to no avail. Can anyone offer up any suggestions? I know that if I can get an example of ONE of them to work, then I'll easily be able to apply it to all of my cases. Otherwise, am I just going about this the hard way or is it even possible? Please, ANY suggestions will help. Thank you in advance.

Regards,

Steve G.



View 4 Replies View Related

Select Distinct Column Data With Other Values From The Table

Dec 16, 2004

I have a table 'wRelated' with the following columns

[related_id] [int]
[channel_id] [int]
[mui] [varchar]
[price_group_id]
[type_id] [int]
[related_mui] [varchar] (100)
[date_started] [smalldatetime]
[date_ended] [smalldatetime]
[date_entered] [datetime]
[deleted] [tinyint],
[rank] [int]
data in column [mui] is repeated as the table has more than one entries for the same [mui],
The requirement is to select the distinct[mui] but value in all the other columns for the same mui should be select in the next row with null for the same [mui]
The recordset expected should be something like this.

[mui],[related_mui],[price_group_id],[date_entered],[date_ended] m123,rm345,'pr','12-10-2003',12-12-2004'
null,rm789,'ar','12-1-2003',26-2-2004'
null,rm999,'xy','14-12-2002',12-2-2004'
m777,rm889,'pr','12-12-2004',12-12-2004'
null,rm785,'yy','1-10-2002',12-12-2004'
m888,rm345,'pr','2-8-2003',12-12-2004'
null,rm345,'tt','30-7-2002',12-12-2004'

I have tried Unions and temporary table inserts.

View 1 Replies View Related

Trigger Not Running When Trying To Select Data From A Column That Is Being Updated?

Dec 11, 2006

Trigger not running when trying to select data from a column that is being updated?

View 1 Replies View Related

SELECT * View Returning Wrong Column Data

Oct 16, 2007

SQL 2005 9.00.3402.00 (x64) As Above really when I select * OR select a single column from the view the wrong column data is returned. in SQL Management Studio when I expand the Columns of the view it reflects the old table structure not the new table structure. I can easily fix by compiling the view again but this would mean I would have to recompile all referencing views when I make a change to table structures. I've tried various DBCC Clean Buffers & drop cache with no effect. Is there a command to recompile all views & poss stored procs in a database. Any help or explanation would be appreciated GW

View 12 Replies View Related

Transact SQL :: How To Select Data With Specific Priority Of A Column

Aug 1, 2015

i have table that has rows as below

DECLARE @Table TABLE
(minv_code INT,
alert_msg varchar(10),
alert_time Datetime)

[code]...

i want to select the data priority wise. the o/p should look like 

e.g first row - 873939, 'Meter', '7/24/2015 3:31:22'
second row - 873939, 'Tamper', '7/24/2015 3:30:00'
third row - 873939, 'Reverse', '7/24/2015 3:31:18'
fourth row -873940, 'Tamper', '7/24/2015 3:31:22' 
fifth row - 873940, 'Reverse', '7/24/2015 3:30:00'

View 6 Replies View Related

Data Warehousing :: Query That Extracts Email Data From A Column

Jun 8, 2015

I have  a column in which Email data is available like 

clicuanan@aspenms.com(M)
jteply@mac.com(M)

How to extract in the below format

clicuanan@aspenms.com
jteply@mac.com
tjones@jpmc.com

View 4 Replies View Related

SQL Search :: Query For Finding Two Columns Data In Third Column And Getting Data From It?

Jul 6, 2015

getting result as given below.

Input:

id Name Data

101 AA PQ102BBRAJAKIRANBUBLU

102 BB RS101AAEROJUCHALABAGUNDI

103 CC TU104GGANDICANKILLANYONE

OUTPUT:

id Name Data

101 AA 101AAEROJUCHALABAGUNDI

102 BB PQ102BBRAJAKIRANBUBLU

103 CC

View 4 Replies View Related

How To Select Data From Excel Table By Original Column Order?

Feb 21, 2007

Hello, everyone:

I have an Excel table that has columns like,

Vendoe_Name
Level
Address
Email
Phone

I use the statemen

SELECT * FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=C: est.xls;Extended Properties=Excel 8.0')...[Sheet1$]

and got output by column order,

Address
Email
Level
Phone
Vendoe_Name

How to make output by original column order like,

Vendoe_Name
Level
Address
Email
Phone

Any help will appreciated. Thanks

ZYT

View 1 Replies View Related

SQL Server 2014 :: Select Data From Table With A Particular Column Priority

Aug 1, 2015

DECLARE @Table TABLE
(minv_code INT,
alert_msg varchar(10),
alert_time Datetime)

[Code]....

i want to select the data priority wise
the o/p should look like below

first row - 873939, 'Meter', '7/24/2015 3:31:22'
second row - 873939, 'Tamper', '7/24/2015 3:30:00'
third row - 873939, 'Reverse', '7/24/2015 3:31:18'
fourth row -873940, 'Tamper', '7/24/2015 3:31:22'
fifth row - 873940, 'Reverse', '7/24/2015 3:30:00'

View 1 Replies View Related

SQL Server 2008 :: Querying XML Data With Column Value In Same Select Clause

Aug 3, 2015

I'm working on a query in which I need to get few nodes values from the XML data by using the value from SQL column (MessageContentType) in this query. I'm able to get the nodes value when i hard code the value in the query but the problem is MessageContentType will vary from some records in the table, due to that I'm not getting the corresponding node values. I have tried few ways to get this value dynamically but I'm missing something.

Sample Table Data
MessageContentType | BodySegment
xx:ADT_A03_26_GLO_DEF | <ns0:ADT_A03_26_GLO_DEF xmlns:ns0="http://microsoft.com/HealthCare/HL7/2X">.....

Current Query - HardCode Script

SELECT
ID,MsgContentType
BODYSEGMENT,
BODYSEGMENT.value('declare namespace xx="http://microsoft.com/HealthCare/HL7/2X"; /xx:ADT_A03_26_GLO_DEF[1]/colxx[1]/colxx[1]','varchar(300)') AS TimeSpan
FROM
s

When i tried the below line of script, I'm getting this error "[color=#FF0000]The argument 1 of the XMLdata type method "value" must be a string literal.[/color]"

Concat MsgContentType Column
BODYSEGMENT.value('declare namespace xx="http://microsoft.com/HealthCare/HL7/2X"; /'+MsgContentType+'[1]/EVN_EventType[1]/EVN_2_RecordedDateTime[1]','varchar(300)') AS TimeSpan

To overcome that error i used sql column but I'm getting this error [color=#FF0000]XQuery [S.bodysegment.value()]: Syntax error near '[', expected a "node test"[/color].

BODYSEGMENT.value('declare namespace xx="http://microsoft.com/HealthCare/HL7/2X"; /[sql:column("MsgContentType")][1]/EVN_EventType[1]/EVN_2_RecordedDateTime[1]','varchar(300)') AS TimeSpan

I tried this line of script, i didn't get any error by timespan is coming as null, I do hope this script not pointing the correct node to traverse the sibling node.

BODYSEGMENT.value('declare namespace xx="http://microsoft.com/HealthCare/HL7/2X"; /*[local-name()=sql:column("MsgContentType")][1]/EVN_EventType[1]/EVN_2_RecordedDateTime[1]','varchar(300)') AS TimeSpan

View 9 Replies View Related

Select Statement That Will Output Related Rows With Different Column Data Per Row?

Apr 27, 2008

Is there a way to build a select statement that will output related rows with different column data per row? I want to return something like:


rowtype| ID | value
A | 123 | alpha
B | 123 | beta
C | 123 | delta
A | 124 | some val
B | 124 | some val 2
C | 124 | some val 3
etc...

where for each ID, I have 3 rows that are associated with it and with different corresponding values.

I'm thinking that I will have to build a temp table/cursor that will get all the ID data and then loop through it to insert each rowtype data into another temp table.

i.e. each ID iteration will do something like:
insert into #someTempTable (rowtype, ID, value) values ('A', 123, 'alpha')
insert into #someTempTable (rowtype, ID, value) values ('B', 123, 'beta')
insert into #someTempTable (rowtype, ID, value) values ('C', 123, 'delta')
etc..

After my loop, I will just do a select * from #someTempTable

Is there a better, more elegant way instead of using two temp tables? I am using MSSQL 2005

View 2 Replies View Related

Select Query To Get Last 6 Months Data

Sep 16, 2004

Hi,
I need to write a select query to get last six months data from a table , on monthly wise.Can anyone help me in writing this query
I am using sql server 2000.

eg: Jan...data
feb...data

TIA,
Ravi

View 1 Replies View Related

Select Query For Retrieving Data Using 3 Tables?

Apr 21, 2015

I want to retrieve the data from table "Document" and i need to check the below condition using 3 tables.

Document.ID=Project.ID=Group.ID

Here Project and Group is an another table.

Query : Select Document.Name from Document, Group, Project where
Document.ID = Group.ID and Document.ID= Project.ID.

is this right a way?

View 3 Replies View Related

What Is The Query That Would Reverse Data In A Column?

Apr 26, 2002

i keep thinking that this can be done with a query, but so far, none of my queries have worked out:


I have data in a column that I would like to permanently reverse, while not disturbing the rest of the columns. For example:

Col1 col2
--- ----
apple John
pear Amy
beans Sam
carrot Bugs

to be
col1 col2
-- ---
carrot John
beans Amy
pear Sam
apple Bugs

Thanks,
Judith

View 1 Replies View Related

Query Data From XML Column With XQuery

Jan 22, 2013

I am trying to learn XQuery and Xpath in SQL Server. I created a sample file and uploaded it to a Table with 2 columns ID, XMLDoc. The below code is within the document in the XMLDoc column so it is the only record in the column.

I am trying to query the file so it will show all the results in a table like a normal select statement would. How would you construct the select statement to select all the information like a select * ? How would you select one field like all suppliers? I would like to select the supplier, requestor for each item.

Here is the xml:

Code:
<tst:Document xmlns:tst ="http://www.w3.org/2001/XMLSchema" SchemaVersion="0.1" Classification="Test" UniqueIdentifier="1234" Title="Test">
<tst:Revision RevNumber="0" TimeStamp="2013-01-21T12:56:00">
<tst:Author Name="Me" Guid="1234" />
</tst:Revision>

[Code] ....

View 1 Replies View Related

Difference Between Select Query And SelectCommand In Data Adapters

May 27, 2008

 

Can any one tell me the difference between Select Query and
SelectCommand in data adapters?

 

Using SelectCommand:

 

string selectSQL = "SELECT CustomerID, CompanyName FROM Customers WHERE Country = @Country AND City = @City"; SqlConnection nwindConn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind");SqlDataAdapter custDA = new SqlDataAdapter();           SqlCommand selectCMD = new SqlCommand(selectSQL, nwindConn);custDA.SelectCommand = selectCMD; // Add parameters and set values.selectCMD.Parameters.Add("@Country", SqlDbType.NVarChar, 15).Value = "UK";selectCMD.Parameters.Add("@City", SqlDbType.NVarChar, 15).Value = "London"; DataSet custDS = new DataSet();custDA.Fill(custDS, "Customers");  Using Select Query: 

SqlDataAdapter
da = new SqlDataAdapter("select P_UID,P_EMIAL,P_NAME from p_users where p_email=@p_email
and p_pwd=@p_pwd", con);

            da.SelectCommand.Parameters.Add("@p_email", SqlDbType.VarChar, 50).Value
= etxt1.Text;

            da.SelectCommand.Parameters.Add("@p_pwd", SqlDbType.VarChar, 50).Value = pwdtex.Text;   Can you plz tell vat is the need for giving custDA.SelectCommand and adding parameters to that command instead of  directly giving Select Query in Data Adapter?  Similarly  Update Command: custDA.UpdateCommand.Parameters.Add("@CustomerID", SqlDbType.NChar, 5, "CustomerID") custDA.UpdateCommand.Parameters.Add("@CompanyName", SqlDbType.NVarChar, 40, "CompanyName")Dim myParm As SqlParameter = custDA.UpdateCommand.Parameters.Add("@OldCustomerID", _ SqlDbType.NChar, 5, "CustomerID")myParm.SourceVersion = DataRowVersion.Original[C#]custDA.UpdateCommand.Parameters.Add("@CustomerID", SqlDbType.NChar, 5, "CustomerID"); custDA.UpdateCommand.Parameters.Add("@CompanyName", SqlDbType.NVarChar, 40, "CompanyName"); SqlParameter myParm = custDA.UpdateCommand.Parameters.Add("@OldCustomerID", SqlDbType.NChar, 5, "CustomerID");myParm.SourceVersion = DataRowVersion.Original; instead of above process, y cant v do above method in below procedure? 

private void UpdateStudent(int
RollNo, string SName, string
Course, DateTime Doj, Decimal
FeePaid)

    {

        SqlConnection
conn = new SqlConnection("Data Source=UMASHANKAR\SQLSERVER2005;Initial
Catalog=employee;Persist Security Info=True;User ID=sa;pwd=sa1 ");

 

        SqlCommand
cmd = new SqlCommand("UPDATE Student SET SName='" + SName + "',Course='" + Course + "',Doj='" + Doj + "',FeePaid='" + FeePaid + "'
WHERE RollNo=" + RollNo, conn);

 

        try

        {

            if
(conn.State == ConnectionState.Closed)
conn.Open();

            cmd.ExecuteNonQuery();

        }

        catch {
}

        finally

        {

            cmd.Dispose();

            conn.Close();

            conn.Dispose();

        }

    }

 

PLZ TELL ME
THE DIFFERENCE OR ANY ADVANTAGES OF UPDATECOMMAND PROCESS AND QUERY METHOD

  IN this way I want difference OR ANY ADVANTAGES for InsertCommand, DeleteCommand also

View 2 Replies View Related

Trying To Select AdventureWorks Database Data From Query Analyzer - Need Help

Jan 30, 2006

Hi there,    I have installed Sql server 2005 developer on my machine which already has a Sql server 2000 installed on. Now i am trying to query the Sqlserver 2005 data(Ex: from Person.Address located in AdventureWorks database) in Sqlserver 2000 query analyzer:
When i try as Select * from Address it said invalid object.
But when i explored AdventureWorks database in the Management studio i see it as Person.Address!!! i don't understand what is a Person in Person.Address??? any clues on this?
So as a test when i ran select * from Person.Address it did work and i saw the results in query analyzer.
Can any one help me understand about this confusion?
Thanks-L

View 1 Replies View Related

Select Query - Showing Columns Data Row Wise

Dec 28, 2011

I have get 3 columns in a select query. how can show these 3 columns in row wise.

View 2 Replies View Related

Convert XML Data With Select Query And Insert Into Table?

Jun 19, 2014

I want to convert xml data with select query and insert into table.

Xml sample like this :

<ROOT>
<ROW>
<NAME>JHON</NAME>
<ADDRESS>
<ADDRESS1>
<CITY>LKO</CITY>
<STATE>UP</STATE>

[code]....

And data should be like this with select query :

NAME ADDRESS1CITY ADDRESS1STATE ADDRESS2CITY ADDRESS2STATE
JHON LKO UP DLI DELHI
YASH AAA HYR NULL NULL

I want simple query in form of above format.

View 8 Replies View Related

How To Use INSERT INTO.... SELECT FROM Query To Export MS SQL Data In FoxPro 2.6 DBF

Nov 28, 2006

Hi all,

This is my very first post to this forum. How to use the INSERT INTO... SELECT FROM query to export MS SQL 2000 data into FoxPro 2.6 DBF file? I want to write a VB 6.0 program, and already connected to MS SQL 2000 Database by MS SQL ODBC connection. Now I want to Export this MS SQL data to FoxPro 2.6 DBF. I found ROWSET option, but don't know how to use it for FoxPro.
Please help me.

Thanks in Advance.

Regards,
Rajeev Vandakar

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved