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
 General SQL Server Forums
 New to SQL Server Programming
 Another Simple Q...

Author  Topic 

gigli92
Starting Member

5 Posts

Posted - 2011-07-14 : 08:18:26
Hello again guys,

I have 2 Temp Tables [Description] and [ Institution] , I want to have these two in one Table.

----------
They are both Tables that look like this:

Table1; #T1
|Description|
blabla
blahblah
blagblag

Table2; #T2
|Institution|
Inst1
Inst2
Inst3

I want to get it like this:

Table3; #T3
|Description| |Institution|

blabla Inst1
blahblah Inst2
blagblag Inst3

They are already in Sortorder.
I just need to get them nex to eachother..

Last time i asked was something almost the same.
I used this query

Create Table #T3
(
[From] Datetime
,[To] Datetime

)

INSERT INTO #T3
SELECT #T1.[From]
, MIN(#T2.[To])
FROM #T1
JOIN #T2 ON #T1.[From] < #T2.[To]
GROUP BY #T1.[From]




Select * from #T3

Drop Table #T3
Drop Table #T2
Drop Table #T1

It did work for the datevalues, but it won't work here ? :s

THANKYOU

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-07-14 : 08:22:09
See my second comment here:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=162975

Corey

I Has Returned!!
Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2011-07-15 : 15:37:36
People cannot read your mind, so post your code and clear specs if you really want help. Please post real DDL and not narrative or your own personal programming language. Learn to use ISO-11179 rules for the data element names, avoid needless dialect and use ISO-8601 temporal formats, codes and so forth. Please tell us what SQL product and release you are using. Tell us if you can change the DDL or if you are stuck with it.

>> I have 2 temp tables “Description” [only one and of nothing in particular]] and “Institution” [institution what? name? Size, location], I want to have these two in one table. They are already in sort order. I just need to get them next to each other. <<

NO, NO, NO! Tables have no ordering by definition! Let me repeat that, BY DEFINITION! What you are trying to do is take two decks of punch cards and glue them side by side.

Stop programming and read a book on SQL and RDBMS. I like THE MANGA GUIDE TO DATABASES myself.

--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-07-15 : 16:12:00
Go to Top of Page
   

- Advertisement -