Transposing Repetitive Serial Fields Into Table Structure

Nov 27, 2006

Dear All,

I'm attempting to create a query that will transpose repeated fields
into a single table structure. Can anyone think of how this can be done
as I'm stumped at the minute? I'd like to do this without having to
create a cursor due to the overheads and performance issues associated
with cursors. The table may also include additional fields which I'm
not interested in.

Serial Data is like this.............

IkeyIval
-----------------------------------------------
RAF_EMAILJoin Bytes!
RAF_FIRSTNAMEtestFirstName1
RAF_LASTNAMEtestLastname1
RAF_EMAILJoin Bytes!
RAF_FIRSTNAMEtestFirstName2
RAF_LASTNAMEtestLastname2
....

Transposed into table like this ..............

EmailFirstnameLastname
--------------------------------------------------------------------------
Join Bytes!testFirstName1testLastname1
Join Bytes!testFirstName2testLastname2
....

Any help, much appreciated ...

Kind Regards,

Tim

-------------------------------------------------------------------------------------

NOTE: these create temporary tables ....

DECLARE @XML TABLE
(
ikey VARCHAR(200),
ival VARCHAR(1000)
)

INSERT INTO @XML
SELECT 'RAF_EMAIL', 'testemail1@hotmail.com'
UNION ALL SELECT 'RAF_FIRSTNAME', 'testFirstName1'
UNION ALLSELECT 'RAF_LASTNAME', 'testLastname1'
UNION ALLSELECT 'RAF_EMAIL', 'testemail2@hotmail.com'
UNION ALL SELECT 'RAF_FIRSTNAME', 'testFirstName2'
UNION ALLSELECT 'RAF_LASTNAME', 'testLastname2'
UNION ALLSELECT 'FORM_CATEGORY', 'nothing'
UNION ALLSELECT 'NO_DOGS', '1'


DECLARE @RESULTS
(
EMAIL,
FIRSTNAME,
LASTNAME
)

View 1 Replies


ADVERTISEMENT

SQL Server 2008 :: Convert Data From 2 Tables To 1 Table With Transposing

Feb 9, 2015

There are 2 tables

1. Table Name : TRNNUM Field Name : TRNID
2. Table Name : TRNPRD Field Name : TRNID, PRDID

Sample of tables
Table TRNNUM
TRNID
-----
1234
2565
3458

Table TRNPRD
TRNID PRDID
----- -----
1234 AA
1234 BB
1234 CC
2565 CC
2565 EE
2565 FF
2565 HH
3458 AA
3458 BB

Desired output is
TempTable

TRNID PRDID PRDSEQ
----- ----- ------
1234 AA START
1234 BB START:AA
1234 CC START:AA:BB
2565 CC START
2565 EE START:CC
2565 FF START:CC:EE
2565 HH START:CC:EE:FF
3458 AA START
3458 BB START:AA

View 2 Replies View Related

Creating Serial Numbers In A Table.

Apr 2, 2001

In microsoft sqlserver 7.0 i like to what is function name to generate serial numbers in a table.

For ex: in sybase we have number* which will automatically generate unique
numbers for each row.

It will be great if you could reply at the earliest

Tanks
vijay

View 2 Replies View Related

Logs Table - Assign Serial Number To Techs

Jul 30, 2014

I have Logs table and want to assign a serial number to the techs using the following query

Select
Date,
Case_ID,
Site,
Dept,
Tech,
Start_Time,
ROW_NUMBER () OVER (PARTITION BY Date, Site, Dept, Tech ORDER BY Start_Time) as Row_Num
FROM
Logs
Where Date = Getdate()

I get the following results.

Date Case ID Site DeptTechStart TimeRow_Num
7/28/14 10023 TartvilleMaintcAmy P.7:301
7/28/14 56789 TartvilleMaintcRem W.8:051
7/28/14 23098 TartvilleMaintcAmy P.8:352
7/28/14 70004 TartvilleMaintcAmy P.9:103
7/28/14 12708 TartvilleMaintcMag O.10:001
7/28/14 10004 TartvilleMaintcAmy P.12:304
7/28/14 40056 TartvilleServiceJoe F.7:301
7/28/14 23458 TartvilleServiceJoe F.7:552
7/28/14 69200 TartvilleServiceRus T. 7:301

Please notice the cases in Maintc department. See how Amy P.'s shift is broken by Rem W. and Mag O. But the Row Number does not recognize this, it still says Amy P's case as 2 and 4 the even though Rem's and Mag's cases were in between.

This is what I really wanted.

Date Case ID Site DeptTechStart TimeRow_Num
7/28/14 10023 TartvilleMaintcAmy P.7:301
7/28/14 56789 TartvilleMaintcRem W.8:051
7/28/14 23098 TartvilleMaintcAmy P.8:351
7/28/14 70004 TartvilleMaintcAmy P.9:102
7/28/14 12708 TartvilleMaintcMag O.10:001
7/28/14 10004 TartvilleMaintcAmy P.12:301
7/28/14 40056 TartvilleServiceJoe F.7:301
7/28/14 23458 TartvilleServiceJoe F.7:552
7/28/14 69200 TartvilleServiceRus T. 7:301

I tried many combination of columns for Partition by () and Order by () and the best I can get is the result at the top. How should I achieve it.

View 1 Replies View Related

Creating A Table In SQL Server With Fields From Other Tables And Some Fields User Defined

Feb 20, 2008

How can I create a Table whose one field will be 'tableid INT IDENTITY(1,1)' and other fields will be the fields from the table "ashu".
can this be possible in SQL Server without explicitly writing the"ashu" table's fields name.

View 8 Replies View Related

How Remove Repetitive Rows

Apr 9, 2008

Boss,
Forget abt all.

My input table consist of ONLY TWO columns. And this is my table
(INPUT TABLE)
Time Action
17:42 SELL
17:43 BUY
17:44 SELL
17:45 SELL
17:46 SELL
17:47 BUY
17:48 BUY
17:49 SELL
17:50 SELL

When ever ACTION columns data is repeating remove that repetitive data rows.

(i mean to say Bold characters rows want to remove)

And finally my output should like this

(OUTPUT TABLE)
Time Action
17:42 SELL
17:43 BUY
17:44 SELL
17:47 BUY
17:49 SELL

View 5 Replies View Related

Repetitive Tasks Across Databases

Oct 25, 2007



Does anyone have any piece of sql that can help with the following.

1. I have to perform repetitive tasks across about 13 databases on 13 different servers involving
a. Alter table drop constraint
b. Alter table drop column

Is there anyway i can pass the database connection details into a procedure and run the task from one database and execute these tasks?

This means I do not have to physically log into the different servers and execute these tasks.

Thanks.




View 4 Replies View Related

Combine 4 Tables Without Repetitive Records

Oct 29, 2006

How to write a sql to combine the 4 tables into one without repetitive records? The 4 tables have exactly the same fields.

The tables do not have primary key. The fields to identiry the rows is name and dob. In the case the name and dob is same for two records, the one with latest date_created is selected.


Thanks

View 9 Replies View Related

How To Remove Repetitive Data Rows?

Apr 9, 2008

Hi, i am very struggle to find out.

My input table consist of TWO columns. And this is my table
(INPUT TABLE)
Time Action
17:42 SELL
17:43 BUY
17:44 SELL
17:45 SELL
17:46 SELL
17:47 BUY
17:48 BUY
17:49 SELL
17:50 SELL

When ever ACTION columns data are repeating remove that repetitive data rows.

(i mean to say Bold characters rows want to remove)

And finally my output should like this

(OUTPUT TABLE)
Time Action
17:42 SELL
17:43 BUY
17:44 SELL
17:47 BUY
17:49 SELL

View 3 Replies View Related

Transposing?

Jul 23, 2005

I have a set of data coming in from a text file that looks like:Date ID Value01/01/2005 1 Value101/01/2005 2 Value201/01/2005 3 Value301/01/2005 4 Value401/01/2005 5 Value501/01/2005 6 Value601/01/2005 7 Value701/02/2005 1 Value101/02/2005 2 Value201/02/2005 3 Value301/02/2005 4 Value401/02/2005 5 Value501/02/2005 6 Value601/02/2005 7 Value7There are 450 "ID"s per day and there will be ~30 days per month thatrepeat these 450 IDs and values. I could potentially reduce this tobetween 80 and 100 IDs. I would like to create a table that lookslike:Date ID1 ID2 ID3 ID4 ID5 etc...01/01/2005 Value1 Value2 Value3 Value4 Value501/02/2005 Value1 Value2 Value3 Value4 Value501/03/2005 Value1 Value2 Value3 Value4 Value5What is the best way to do this? Any built-in SQL commands to assist?Any tricks with DTS?Thanks!Dave

View 1 Replies View Related

Transposing

Jul 20, 2005

Hello!I need to transpose some columns into rows and rows into columns. Iknow, tha i can do it by cursor, but i don't know how make it...I read a lot about it, but still don't understand...Can someone help me?*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!

View 8 Replies View Related

Transposing SQL Tables

Mar 12, 2008

hi there, i've got a Maconomy table that needs to be normalised. I'm fairly new to T-SQL and was hoping i could get advice on this forum. Possibly copy the below tables into Excel to make better sense.

i would like to PiVot/transpose the below table to so that the 8 types of HEADER are the columns but include the NOTENUMBER (i.e. this below table would give an output of 2 rows)

any takers?

NOTENUMBERHEADERAMOUNT1STRING1DATE1
1100030Insurance cost44
1100030Leasing cost300
1100030PropertyID0N3100023424
1100030PropertyModel0Nokia 3100
1100030PropertyName0Cell Phone
1100030PropertyYear0 2003.01.11
1100030Scheduled end date0 2004.12.20
1100030Tax cost463
1100031Insurance cost50
1100031Leasing cost400
1100031PropertyID0N3100023424
1100031PropertyModel0Siemens
1100031PropertyName0Cell Phone
1100031PropertyYear0 2003.01.11
1100031Scheduled end date0 2004.12.20
1100031Tax cost500

View 14 Replies View Related

Database Automatically Creates Xxx_Temp Table While Modifying / Updating Table Structure .

Dec 16, 2007

Hello friends,

I am new to the SQL Server 2005 development.

From last 1 week or so, i have been facing very strange problem with my sql server 2005s database
which is configured and set on the hosting web server. Right now for managing my sql server 2005 database,
i am using an web based Control Panel developed by my hosting company.

Problem i am facing is that, whenever i try to modify (i.e. add new columns) tables in the database,
it gives me error saying that,

"There is already an object named 'PK_xxx_Temp' in the database. Could not create constraint. See previous errors.
Source: .Net SqlClient Data Provider".

where xxx is the table name.

I have done quite a bit research on the problem and have also searched on the net for solution but still
the problem persist.

Thanks in advance. Any help will be appreciated.

View 5 Replies View Related

Transact SQL :: Dynamically Alter Schema Of Stage Table When Source Table Structure Changed?

Oct 25, 2015

we have a table in our ERP database and we copy data from this table into another "stage" table on a nightly basis. is there a way to dynamically alter the schema of the stage table when the source table's structure is changed? in other words, if a new column is added to the source table, i would like to add the column to the stage table during the nightly refresh.

View 4 Replies View Related

Transposing Rows To Columns

Jul 31, 2006

I hope someone can help me with my problem. I have searched theinternet for days for a solution, but nothing i found seemed to work.The following is what i have now:appartmentid code100306 Wip100306 Zandbak100306 Glijbaan100306 Klimrek100306 Schommel100321 Glijbaan100321 SchommelThis results are made with this query:selectappartment.appartmentid,listvalue.codefrom appartmentinner join appartmentlistvalue on appartmentlistvalue.appartmentid =appartment.appartmentidinner join listvalue on appartmentlistvalue.listvalueid =listvalue.listvalueidThe following is what i need:100306 Wip, Zandbak, Glijbaan, Klimrek, Schommel100312 Glijbaan, SchommelAs you can see is this example, not all appartments have the samenumber of results. Can anyone tell me if this is possible?Many thanks,Sakymoto

View 5 Replies View Related

Transposing Rows Into Columns

Jul 20, 2005

Hello,is there any quite easy solution for the problem of transposing the rowsinto the columns? I have the following table with some data in it:dealer date 09.00 10.00 11.00 12.00 13.00 14.00-----------------------------------------------------------------1 2004-10-01 1/1 2/3 3/3 3/4 4/5 0/31 2004-10-02 0/1 1/3 1/3 1/4 3/5 1/3/and so on.../I'd like to prepare a SELECT query in the stored procedure that willdisplay this data in the following form:dealer date hour reservations------------------------------------------------------------------1 2004-10-01 09.00 1/11 2004-10-01 10.00 2/31 2004-10-01 11.00 3/31 2004-10-01 12.00 3/41 2004-10-01 13.00 4/51 2004-10-01 14.00 0/31 2004-10-02 09.00 0/11 2004-10-02 10.00 1/31 2004-10-02 11.00 1/31 2004-10-02 12.00 1/41 2004-10-02 13.00 3/51 2004-10-02 14.00 1/3Is it possible to do it using some simple solution? I saw some possiblesolutions but they are a bit confusing. Any ideas? Thanks in advance....:: fabio

View 2 Replies View Related

Transposing Rows And Columns

Mar 3, 2008

I am trying to find a way to transpose rows and columns for a dataset.

In otherwords I would like to take a dataset that looks like this

col1 | col2 | col3
--------*---------*----------
Value 1 | Value 2 | Value 3

And change it to one that looks like this:

Name | Value
-----*---------
col1 | Value 1
-----*---------
col2 | Value 2
-----*---------
col3 | Value 3


Is there a T-SQL way to do this?

Thanks,
Jacob

View 3 Replies View Related

Transact SQL :: Table Structure - Inserting Data From Other Temp Table

Aug 14, 2015

Below is my table structure. And I am inserting data from other temp table.

CREATE TABLE #revf (
[Cusip] [VARCHAR](50) NULL, [sponfID] [VARCHAR](max) NULL, GroupSeries [VARCHAR](max) NULL, [tran] [VARCHAR](max) NULL, [AddDate] [VARCHAR](max) NULL, [SetDate] [VARCHAR](max) NULL, [PoolNumber] [VARCHAR](max) NULL, [Aggregate] [VARCHAR](max) NULL, [Price] [VARCHAR](max) NULL, [NetAmount] [VARCHAR](max) NULL,

[Code] ....

Now in a next step I am deleting the records from #revf table. Please see the delete code below

DELETE
FROM #revf
WHERE fi_gnmaid IN (
SELECT DISTINCT r2.fi_gnmaid
FROM #revf r1, #revf r2

[Code] ...

I don't want to create this #rev table so that i can avoid the delete statement. But data should not affect. Can i rewrite the above as below:

SELECT [Cusip], [sponfID], GroupSeries, [tran], [AddDate], [SetDate], [PoolNumber], [Aggregate], [Price], [NetAmount], [Interest],
[Coupon], [TradeDate], [ReversalDate], [Description], [ImportDate], MAX([fi_gnmaid]) AS Fi_GNMAID, accounttype, [IgnoreFlag], [IgnoreReason], IncludeReversals, DatasetID, [DeloitteTaxComments], [ReconciliationID],

[Code] ....

If my above statement is wrong . Where i can improve here? And actually i am getting 4 rows difference.

View 5 Replies View Related

Using LIKE To Find Any Of Fields In One Table In Fields Of Another

Jul 31, 2013

I have a list of items in one table and a field (pageName) in another table that may contain one of the aforementioned items somewhere within that field. There is no fixed position within the field where the itemNo may be so I can't just use SUBSTRING(pageName,2,5) in(select itemNo from tblItem).

Logically, it's like I need to combine IN and LIKE: select pageName where pageName LIKE IN %select itemNo from tblitemNo%..LIKE can only handle one comparison string.

View 5 Replies View Related

Copy Records From One Table To Another Table With Same Structure

Jan 20, 2007

Hi allI have two tables in SqlServer with Exactly Same Structure,I want to Copy all Records fromone of them to another one.I came across to "Insert....select..." statement But i have two problem
1) I don't know any thing about Columns name!!! i just know they have same structure and as far as i know , "Insert...select..." need the Column list to operate correctly, am i right?
2) these two table have One Prinary Key column with IDENTITY feature.
Any Help Greatly appriciated.Regards.

View 6 Replies View Related

SQL Server 2012 :: Transposing Data Using Pivot And Unpivot

Jun 5, 2015

My table structure is like

col1 col2 col3 col4 col5 col6
abc. def. 3fg. 59j. 567. 596040
abc. def. 3fg. 59j. 567. 596042
abc. def. 3fg. 59j. 567. 596043
abc. def. 3fg. 59j. 567. 596044
edf. ijk. rkl. 1fh. 567. 596045
edf. ijk. rkl. 1fh. 567. 596046
edf. ijk. rkl. 1fh. 567. 596047
edf. ijk. rkl. 1fh. 567. 596048
edf. ijk. rkl. 1fh. 567. 596049

And I am trying to get the above data , gel them ino col 6 by comma separated

col1 col2 col3 col4 col5 col6
abc def 3fg 59j 567 596040,567 596042,567 596043,567 596044
edf ijk rkl 1fh 567 596045,596046,596047,596048,596049

Can I get an example query for this...

View 1 Replies View Related

What And Why Is Better Table Structure?

Mar 7, 2008

Structure Number1 
Category: CategoryId(P.K.), UniqueName, CreatedDate, ModifiedDateCategoryNative: CategoryId(F.K.), LanguageId(F.K.), NativeName, Description, Importance, IsVisible, CreatedDate, ModifiedDate
Structure Number2 
Category: CategoryId(P.K.), UniqueName, CreatedDate, ModifiedDateCategoryNative: CategoryNativeId(P.K.), CategoryId(F.K.), LanguageId(F.K.), NativeName, Description, Importance, IsVisible, CreatedDate, ModifiedDate
Can anyone tell me that between above 2 structure what is better and why?
I just add CategoryNativeId(P.K.) in Number 2 structure.

View 2 Replies View Related

Table Structure

Mar 17, 2004

Dear all,

how can I use a store procedure to get the structure of a table like data type, length, description etc.

I have used sp_columns to get the information but it can't get the description of each field.

Thanks.

View 1 Replies View Related

Table Structure

Jul 13, 2004

How can I get the structure of a table?
With MySql I can do it this way: DESC | DESCRIBE <tablename>

Thank you,

Dirk
Dirk.Ulrich@gmx.de

View 5 Replies View Related

I Can Really Use Some Help.Table Structure

May 4, 2004

How can I setup a table structure for the diagram shown in the attached bitmap?

1) I need to create a product using labour and materials.
2) I need to create hardware using labour and materials.
3) I need to be able to include some hardware in some products.
4) Some materials in the product are made of a culmination of materials. E.G., Concrete is made of sand, stone, and cement.

Any suggestions?

So far I have :


USE NORTHWIND

Create Table tbProducts (
ProductID int NOT NULL,
Product varchar(50)
)

go

ALTER TABLE tbProducts
ADD CONSTRAINT tbProducts_pk PRIMARY KEY (ProductID)
GO

CREATE Table tbMaterials (
MaterialID int NOT NULL,
Material varchar (50)
)

GO

ALTER TABLE tbMaterials
ADD CONSTRAINT tbMaterials_pk PRIMARY KEY (MaterialID)
GO

CREATE Table tbLabour (
LabourCode char (2) NOT NULL,
Labour varchar(50)
)

GO
ALTER TABLE tbLabour
ADD CONSTRAINT tbLabour_pk PRIMARY KEY (LabourCode)
GO

CREATE Table tbProductMaterials (
fkProductID int NOT NULL,
fkMaterialID int NOT NULL,
Quantity Float NOT NULL
)

GO
ALTER TABLE tbProductMaterials
ADD CONSTRAINT tbProductMaterials_pk PRIMARY KEY (fkProductID, fkMaterialID)
GO

ALTER TABLE tbProductMaterials
ADD CONSTRAINT tbProductMaterils_fk FOREIGN KEY (fkMaterialID)
REFERENCES tbMaterials (MaterialID)

GO
ALTER TABLE tbProductMaterials
ADD CONSTRAINT tbProductMaterils_Product_fk FOREIGN KEY (fkProductID)
REFERENCES tbProducts (ProductID)
GO

CREATE TABLE tbProductLabour (
fkProductID int NOT NULL,
fkLabourCode char(2) NOT NULL,
Manpower int NULL DEFAULT(0),
Hours float NULL DEFAULT(0.0)
)

GO

ALTER TABLE tbProductLabour
ADD CONSTRAINT tbProductLabour_pk PRIMARY KEY (fkProductID, fkLabourCode)
GO

ALTER TABLE tbProductLabour
ADD CONSTRAINT tbProductLabour_fk FOREIGN KEY (fkLabourCode)
REFERENCES tbLabour (LabourCode)

GO

ALTER TABLE tbProductLabour
ADD CONSTRAINT tbProductLabour_Product_fk FOREIGN KEY (fkProductID)
REFERENCES tbProducts (ProductID)

GO

CREATE TABLE tbHardware (
HardwareID int NOT NULL,
Hardware varchar(50)
)

go

ALTER TABLE tbHardware
ADD CONSTRAINT tbHardware_pk PRIMARY KEY (HardwareID)
GO


CREATE Table tbHardwareMaterials (
fkHardwareID int NOT NULL,
fkMaterialID int NOT NULL,
Quantity Float NOT NULL
)

GO
ALTER TABLE tbHardwareMaterials
ADD CONSTRAINT tbHardwareMaterials_pk PRIMARY KEY (fkHardwareID, fkMaterialID)
GO

ALTER TABLE tbHardwareMaterials
ADD CONSTRAINT tbHardwareMaterials_fk FOREIGN KEY (fkMaterialID)
REFERENCES tbMaterials (MaterialID)

GO
ALTER TABLE tbHardwareMaterials
ADD CONSTRAINT tbHardwareMaterials_Hardware_fk FOREIGN KEY (fkHardwareID)
REFERENCES tbHardware (HardwareID)
GO

CREATE TABLE tbHardwareLabour (
fkHardwareID int NOT NULL,
fkLabourCode char(2) NOT NULL,
Manpower int NULL DEFAULT(0),
Hours float NULL DEFAULT(0.0)
)

GO

ALTER TABLE tbHardwareLabour
ADD CONSTRAINT tbHardwareLabour_pk PRIMARY KEY (fkHardwareID, fkLabourCode)
GO

ALTER TABLE tbHardwareLabour
ADD CONSTRAINT tbHardwareLabour_fk FOREIGN KEY (fkLabourCode)
REFERENCES tbLabour (LabourCode)

GO

ALTER TABLE tbHardwareLabour
ADD CONSTRAINT tbHardwareLabour_Product_fk FOREIGN KEY (fkHardwareID)
REFERENCES tbHardware (HardwareID)
GO



This table structure does not include anything about accounts and item 4) making materials from 1 or more other materials (E.G., Concrete).

Any hints how to incorporate these outstanding items?

Mike B

View 3 Replies View Related

How 2 Get The Table Structure Using T-SQL

Sep 11, 2006

How can I get my table structure (columns, their types, whether it s an Identity column) using T-SQL
pls
Thanks you

View 5 Replies View Related

Table Structure

Mar 10, 2007

Hi

How to write a query for table structure which looks like
SQL Design table.


thanks

asm

View 15 Replies View Related

Structure Table ..

Dec 13, 2007

I'm new in creating tables. and I was asked to create table(s) to capture information using SQL server 2005 (express edition)

please read below and share your thoughts and opinions o what's the efficient and best way to structure the tables.

I need to capture user's input daily and every hour, text can be from 20-100 characters, and my company is expecting to have 50,000+users in the future...Also the hrs's text can be stored for max 120 days, after that data would be deleted from the table(s)
An example is put all together, (not sure if it is the right and efficient way)

An example is put all together, (not sure if it is the rigth and effectient way) and if database would support that.. and if it will be fast enougth to search for data

(table structure) - (example with 3 users)
userId | timestap | message
1 12/12/2007 10:00 some message
1 12/12/2007 11:00 some message
1 12/12/2007 12:00 some message
1 12/12/2007 13:00 some message
1 12/12/2007 14:00 some message
2 12/12/2007 10:00 some message
2 12/12/2007 11:00 some message
3 12/12/2007 12:00 some message
3 12/12/2007 13:00 some message
3 12/12/2007 14:00 some message ...etc..



Thank you..

View 11 Replies View Related

Table Structure

Feb 28, 2008

Hi Guys,

I have another question.

Is there a query to display the structure of a certain table?
e.g. display the columns, data type,...etc.

TIA

View 7 Replies View Related

Table Structure In XML

Jul 20, 2005

Hi,I am new to XML and need a structure of table in XML format, which needsto be created as a table in another server.The Source and destinationservers are SQL Server 2000. Could anyone help me on this.Balaji.S.--Posted via http://dbforums.com

View 1 Replies View Related

Best Structure For The Table

Feb 11, 2008



Hi,
I have one field "Status" with 15 different types of values. Like 1, 2, 3, 4 .. 15.
Now this Status field contains the values like this:
Id Status
1 1,2
2 3
3 1,2,3
4 13,15

What is the best way to organize this information in SQLServer table?
My idea is Create one table with the following volumns: ID, Status1, Status2, Status3, ... Status14, Status15.

Now the above data look like this:
Id Status1 Status2 Status3 ... Status13 Status14 Status15
1 1 1 0 0 0 0
2 0 0 1 0 0 0
3 1 1 1
4 0 0 0 1 0 1

So, In future If they add new column they can easily add column like status16.
And status table look like this
Status
StatusID Description
1 a
2 b
..
15

Thanks in advance

View 6 Replies View Related

Question On Table Structure

Jun 24, 2007

 All,On my aspx page i have 2 sets of checkboxlists, each with a number of items and i am storing that info in my db. currently i have my table set up this way: InfoID--PK autoUserID-intCheckBoxList1ID-intCheckBoxList2ID-int  So a user can select more than 1 item in each checkbox, so this table will contain multiple user-ids and each id from the respective checkboxes. My question is, is there a better way to store this data? I hope this is clear, any input would be greatly appreciated.Thank you.  

View 2 Replies View Related

Change The Table Structure

Aug 30, 2007

Hi....I execute select statement on three tables and i get the following table: 




ID


Value


Name




1


10


color




2


20


color




3


30


color




4


40


color

View 5 Replies View Related







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