Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 help to query

Author  Topic 

ibin
Starting Member

26 Posts

Posted - 2009-10-07 : 09:33:41
hi,

following are three tables and i want to update the date column in the third table with data from 1 and 2. Any help and query would be great....

Table1
Col1 Col2 Desc1- date Desc2-date Desc3-date

Table2
id Desc
C11 Desc1
C12 Desc2
C13 Desc3

Table3
Col1 Col2 id Date





Sachin.Nand

2937 Posts

Posted - 2009-10-07 : 09:46:27
Can u pls explain it a bit more on how you want to acheive it?
Pls post some sample data & the desired output as it will be of much help.

PBUH
Go to Top of Page

ibin
Starting Member

26 Posts

Posted - 2009-10-07 : 10:35:34
The possible way i can brief.. i want to update the #main table 's actdate and date column with values of #temp.

Let me know if i failed to communicate

CREATE TABLE #Temp (
LinkID varchar(6),
Desc1-actdate datetime,
Desc1-date datetime,
Desc2-actdate datetime,
Desc2-date datetime)
)
INSERT INTO #Temp (LinkID , Desc1-actdate, Desc1-date,Desc2-actdate, Desc2-date) VALUES ('ABC','1/1/2009','1/2/2009','1/3/2009','1/4/2009')
INSERT INTO #Temp (LinkID , Desc1-actdate, Desc1-date,Desc2-actdate, Desc2-date) VALUES ('def','3/1/2009','5/2/2009','1/3/2009','1/4/2009')
INSERT INTO #Temp (LinkID , Desc1-actdate, Desc1-date,Desc2-actdate, Desc2-date)VALUES ('ghi','4/1/2009','6/2/2009','1/3/2009','1/4/2009')

CREATE TABLE #Lookup(
ID varchar(6),
Desc nvarchar(max))
INSERT INTO #Lookup(ID , Desc) VALUES ('a1','Desc1')
INSERT INTO #Lookup(ID , Desc) VALUES ('a2','Desc2')
INSERT INTO #Lookup(ID , Desc) VALUES ('a3','Desc3')

CREATE TABLE #Main (
LinkID varchar(6),
LookupID varchar(6),
actdate datetime,
date datetime
)
INSERT INTO #Main (LinkID , LookupID , actdate ,date) VALUES ('ABC','a1','1/2/2009','1/3/2009')
INSERT INTO #Main (LinkID , LookupID , actdate ,date) VALUES ('ABC','a2','1/2/2009','1/3/2009')
INSERT INTO #Main (LinkID , LookupID , actdate ,date) VALUES ('def','a1','3/1/2009','5/2/2009')
INSERT INTO #Main (LinkID , LookupID , actdate ,date) VALUES ('ghi','a3','4/1/2009','6/2/2009')
Go to Top of Page
   

- Advertisement -