SQL Server :: Columns To Rows - Table

Nov 13, 2010

I have a table think as table1, with 3 columns

col1 col2 col3 -- Columns
Y N 1 -- Data

but i want

colname val
col1 Y
col2 N
col3 1

View 3 Replies


Similar Messages:

SQL Server :: Copying Few Rows With Selected Columns From One Table To Another

Mar 29, 2011

Table1

t1c1 t1c2 t1c3
1 1 jim
2 2 ruth
3 4 paul
4 8 sam
5 16 NA

Table2 ( Need this)

t2c1 t2c2 t2c3 t2c4 t2c5
10 1 1 jim 2010-02-03
10 2 1 ruth 2010-02-03
10 4 1 paul 2010-02-03
10 8 1 sam 2010-02-03

The tricky part I have to perform is to copy rows( only t1c2 -> t2c2, t1c3->t2c4 columns) untill I see NA(Not applicable string) in t1c3 to Table2 putting (10 in t2c1, 1 in t2c3, current date in t2c5 columns for all rows).

View 1 Replies

Table That Has Some Columns And Rows Want This Table To Have Borders That Are Visible Inside It??

Sep 1, 2010

i have a table that has some columns and rows i want this table to have borders that are visible inside it i want every column an row to be closed in borders how can i do that?

View 1 Replies

Forms Data Controls :: How To Convert Gridview Rows To Columns And Columns To Rows

Mar 4, 2011

I'm binding a gridview from a webservice with 30 columns and 10 rows, I need to print the same in a PORTRAIT, for that i decided to display columns as rows and

rows as columns like below:

EMP1 1 2 3 4
EMP2 1 2 3 4

View 3 Replies

Forms Data Controls :: How To Create A Control With Rows And Columns Like Sql Table

Jul 30, 2010

Iam working on an asp.net application.Recently client come with new requirement. Need a control which is similar to table or like gridview with rows and columns.It should allow user to enter data in the cells. And when the user press tab it should go to next cell and finally if we press enter key, it should validate the data entered in the current row and if data is correct it should create a new empty next row(like entering data manually in an sqlserver table). How can i implement this functionality? Can i use gridview / javascript to implement this functionality.

View 1 Replies

SQL Server :: Converting Rows To Columns?

Nov 13, 2010

This is how my table in db looks like

Remarks Id Remark

1 Rem1_aaa

2 Rem1_ccc

1 Rem1_bbb

2 Rem1_ddd

i want the output as:

Id Column1 Column2

1 Rem1_aaa Rem1_bbb

2 Rem2_ccc Rem2_ddd

View 4 Replies

SQL Server :: Transpose Rows To Columns In Datatable

Feb 23, 2011

This is datat table format :

TagName Timestamp Value
Tag1 21-2-2011 12
Tag1 22-2-2011 1
Tag2 21-2-2011 13

I want in this Format

TimeStamp Tag1 Tag2
21-2-2011 12 13
22-2-2011 1 0

View 6 Replies

SQL Server :: Delete Objects From Table Using Another Table To Select Rows?

Sep 14, 2010

I have one table named 'dbo.ac_Products' Within this table there is a column named 'ProductId' There is also another table named 'dbo.ac_CatalogNodes' Within this table there is a column named 'CatalogNodeId' and a column named 'CatalogNodeType'

I need to delete all the rows from 'dbo.ac_Products' and 'dbo.ac_CatalogNodes' where 'ProductId' = 'CatalogNodeId' and 'CatalogNodeType' = 1

View 4 Replies

SQL Server :: How To Update Table Value From Another Table With Limit Rows

Jan 20, 2011

I have table a and would like update table a whose values from table b, but not update all rows at table a. Only update record ID in table a match record ID in tableC.

Here is my query

update a
set a.Desc = b.Desc,
a.Value = b.Value
from TableA a, TableB b
where a.name = b.name
and a.ID = b.ID
and a.ID in ( select ID from TableC)

I only have 12 a.ID match TableC, but above query update whole TableA.

How to only update 12 record at TableA from TableB?

View 2 Replies

SQL Server :: Import All The Columns And Rows In An Excel File To A Database?

Aug 31, 2010

im using sqlbulkcopy to import all the columns and rows in an excel file to a database. My question is, if my database has 1 more extra column which i have to map it to a session variable and that extra column in the database is not found in the excel, isit possible to do something like dat?

View 3 Replies

Forms Data Controls :: Create An ASP Grid With Dynamic Columns With An Ability To Freeze Columns And Rows

Sep 20, 2010

I created a gridview that is made up of 4 gridviews and using a stored procedure to populate it. I create columns at runtime because the number of columns changes all the time.To make the grids editable I am adding template fields at runtime as I create the columns, this is to ensure that a user is able to edit the cells and some foot values update. Reason why I have four grids is to freeze rows and columns like in excel using javascript. The problem is that performance is very bad especially in IE, the grids take a long time to load. I am not sure if this is caused by the data load or the creation of text boxes. see some of the code below for my _aspx page:

[Code]....

View 1 Replies

SQL Server :: Update Two Columns In The Same Table?

Dec 25, 2010

I have tow colums

nickname, and name, and I allready filled them with information, like this

nikname = gino

name = longinos

What I want now is both to have the same information

nikname = longinos

name = longinos

I thought of somethig like this

update
Customer set name
= nikname
where custID
= custID

but it does not work, and I can't think of something good

View 5 Replies

SQL Server :: How To Get The Top N Rows From SQL Table

Aug 30, 2010

Recently i have come across one question in sql query

Question: Which SQL Query helps to view the TOP N rows From the particular SQL table?

View 3 Replies

SQL Server :: Pushing Columns Of One Table To Another After Filtering

Sep 16, 2010

I have 2 tables t1 and t2. In t1 I have 4 columns from that I want to insert only 2 columns to another table t2. I only want to send data which is in the form of IP address like (123.123.123.123). After eliminating nulls and other data.

View 7 Replies

SQL Server :: Comparing Rows In A Table?

Mar 11, 2011

I have a large database of user profile data. I need to be able to compare 1 row against all of the other rows, for all columns to find the best match.There are around 30 columns of data for each row. I need to be able to find the 5 best matching rows.

I.E.
Row 1 matches on 2 column's
Row 2 matches on 12 column's
Row 3 matches on 7 column's
Row 4 matches on 4 column's
Row 5 matches on 9 column's
Row 6 matches on 23 column's
Row 7 matches on 29 column's

In the end it will show me the data for rows 7, 6, 2, 5, 3 Now to make it even harder, Some of the columns are bit, some are varchar.Some of them may be a direct match, some will need to search if the column for row2 contains the text of row 1.

View 6 Replies

SQL Server :: How To Select All Columns Of Table But To Distinct By One Column

Dec 29, 2010

How can i select all columns of table but to distinct by one column? i am tryin to figure it out without success, i know how to make distinct (select distinct column from table, but i need all the values from the table and to distinct by Delcompany.

my line is:

[Code]....

View 13 Replies

SQL Server :: Search A Word In All The Columns Of A Single Table?

Sep 17, 2010

How can I search a word in all the columns of a table?

View 4 Replies

SQL Server :: Proposal - Payment System - Set The Table And Columns?

Jul 25, 2010

I have data for the payment system:
- Credit card number (Visa, Mastercard, etc ...)
- Paypal
- Moneybookers
- NETeller
- Etc ...

how to set the table and columns.

Current proposal:
Column AttributeName, in which I have text (credit card number, name on credit, email, etc ...)
Column Value, in which I have data about a particular attribute.

I wish that all data is stored in one table.I do not wish for any payment system, use the new table, as for example:

tbl_creditcardnumber, tbl_paypal, tbl_moneybookers, tbl_neteller ....

View 2 Replies

SQL Server :: Use A Conditional Split To Extract The Right Columns To The Right Table?

Oct 12, 2010

I have a package which imports several files on a regular bases . For the import I use a staging table. Now I want to split that stagingtable into two other (existing) tables with keeping the relation ( third table??) . In each record there is a dealerID which has to be injected also in the other two tables (the splittables).

How can I use a conditional split to extract the right columns to the right table? I only see that i can enter a expression for each column, but in fact i only want to split the table by "fingerpointing" the right columns. is that possible? And how should i put the relation between them in 'relation' table?

View 4 Replies

SQL Server :: Count How Many Rows Are In Data Table

Mar 5, 2011

I have a data table called Songs It has SongId as Primary Key of type INT SongName of Type VarChar UserId of Type Int. I simply want to check how many entries are in the Table already by The UserId before they insert more. So If there are already 3 songs by that User, I want to stop the insert process and warn them they have the maxium already. I think i am halfway there already using code below but problem is that UserId is of Type GUID, and not Int so I am missing something. On my Aspx, Page, I have a DetailsView for the Database Insert. I also have the following code using BusLogic Layer and DAL

SongsBLL
public int ScalarQuery(Guid ArtistId)
{
int returnValue = ScalarQuery(ArtistId);
return returnValue;
}
Code Behind ASPX page
This in in DetailsView_ Item Inserting Event
SongsBLL number = new SongsBLL();
currentCount = Convert.ToInt32(number.ScalarQuery(currentCount).ToString());..........

View 9 Replies

SQL Server :: Emailing Contents Of Table (Only Rows)

Dec 15, 2010

Let's say I have a table (Table1) with three columns (Col1, Col2, Col3) and two rows. Let's say I have a button on a page. I want to send the contents of those two rows in an email in the Click event handler of the button. Here's the SQL framework I've got:
[Code]....

View 11 Replies

SQL Server :: How To Iterate Through Rows Of A Temp Table

Mar 21, 2011

Suppose I have a temporary table (Shown below). The table is defined and populated in my stored procedure. After it is populated, I need to go through every row in the table. Here is what I need to do :

Check if Amount2 > Amount1 If Amount2 > Amount1 then set Amount1 = Amount2

It feels a little akward for me to use the temp table.

[code]....

View 2 Replies

C# - Filter Sql Server Table Rows Using Many Filters

Mar 23, 2011

I have a table called Student with a lot foreign keys that will be used after to filter students(table rows).The structure of this table is like:

StudentId GenderId DegreeId NatioanlityId
1 2 2 3
....

As a student can speak one or more language,the Sudent Table is linked to language table like this

StudentId LangaugeId
1 1
1 2
1 3

And a student can chose one or many subjects for exam:

StudentId ExamId
1 1
1 2
....

In my asp.net page I would like to filter students via checkbox using ajax for example, student having female and male gender with Degree 1,speaking language 1,2... I filter rows in a stored proc using user defined table,and I have to use a lot of IF statements like this

if(EXISTS(SELECT GenderId FROM @GenderTable))
if(EXISTS(SELECT DegreeId FROM @DegreeTable))
if(....)
else
if(...)

How can I avoid all the IF statements? I have more than 5 filters.It's boring.

View 1 Replies

SQL Server Deadlock While Inserting Rows In A Table

Oct 15, 2010

The topic of sql server deadlock has been discussed many times, however, I was unsure that even two simultaneous inserts on a table can end up in a deadlock situation. Scenario: While testing our application (SQL Server 2005 as backend, ASP.net 3.5) we inserted records into a table simultaneously (simplified overview) and that resulted into a deadlock for more than 70% of users.

I could not get a hang of this as how an insert is being deadlock as this is not a case of multiple resources. After a detailed analysis (of reproducing the bug by two users) I found that both the processes were holding a RangeS-S lock on the primary key index of the table and were trying to convert this into RangeI-N lock, that resulted into a deadlock and one transaction being killed.

Question: Can we avoid or reduce these kind of deadlocks as this is not a case of change in order of access of resources? Cant' we force the transaction to get exclusive lock initially so that it blocks the other process and avoid deadlock? What (adverse) effects that may have? Also could some one explain more about RangeI-N lock.

Isolation Level for this was "Serializable".

View 2 Replies

SQL Server :: Find Out Distinct Rows In Table

Sep 29, 2010

I have a one sql table, it contain 5 column id, ipaddress, status, datetime, value. I need to find distinct rows as per ipaddress column basic..

View 7 Replies







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