Hello,
I've been converting/normalizing data and inserting it to other tables.
What i would like to do is to create 2 records for a particular value if
it occurs in the denormalized table.
Any idea how i should do this?I assume you mean something like:
CREATE TABLE DenormTable
(
DenormID int PRIMARY KEY
, MainVal int
, Year2005Value int
, Year2004Value int
)
If so, you merely have to create an insert like so:
CREATE TABLE NormTable1
(
Norm1ID int PRIMARY KEY
, MainVal int
)
CREATE TABLE NormTable2
(
Norm2ID int IDENTITY(1,1) PRIMARY KEY
, Norm1ID int NOT NULL
, Val int
, Year int
)
INSERT INTO NormTable1 (Norm1ID, MainVal)
SELECT DenormID, MainVal FROM DenormTable
INSERT INTO NormTable2 (Norm1ID, Val, Year)
SELECT DenormID, Year2005Val, 2005 FROM DenormTable
INSERT INTO NormTable2 (Norm1ID, Val, Year)
SELECT DenormID, Year2004Val, 2002 FROM DenormTable
You can combine the two in a single statement, if necessary, with some CASE
statements or creating a temporary VIEW with a UNION.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
****************************************
*******
Think Outside the Box!
****************************************
*******
"Jason" <jasonlewis@.hotmail.com> wrote in message
news:u$%23PCme6FHA.564@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I've been converting/normalizing data and inserting it to other tables.
> What i would like to do is to create 2 records for a particular value if
> it occurs in the denormalized table.
> Any idea how i should do this?|||In my Delphi app connecting to Sql Server using ODBC.. When 3 or more users
updating the same table at the same time (Not the same record) there is a
delay for approx 10 sec, I tried to use Enterprise manager from another
machine to update the same table and found the same problem so the problem
is not in my program code..
Finally after trying to solve this i noticed that 1 pc is the reason of the
delay, and after changing this Client IP.. it work now great and if i change
the IP back to it's old value the problem raise again!!.
Could i know what is the relation between Sql server or ODBC and client
machine IPs'
any information will appreciated
"Jason" <jasonlewis@.hotmail.com> wrote in message
news:u$%23PCme6FHA.564@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I've been converting/normalizing data and inserting it to other tables.
> What i would like to do is to create 2 records for a particular value if
> it occurs in the denormalized table.
> Any idea how i should do this?
Thursday, March 22, 2012
adding 2 records
Labels:
adding,
converting,
create,
database,
inserting,
microsoft,
mysql,
normalizing,
oracle,
particular,
records,
server,
sql,
tables
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment