Create a big table with huge number of columns? - sql

How can I create a table with 1000 row and at least 64000 columns. As I know, SQL database and Microsoft Excel suppot only 30000 and 16384 columns per table, respectively. How can I create such a table? Is there any solution? I want to use this table as an input for RapidMiner studio!

If you are determined to create this beast it would require a work around the column limit.
My suggestion would be 10x~6401 column tables with an ID/Key to link each row.
Join together the ten tables like so:
select * from
Table1
join Table2 on Table1.ID = Table2.ID
join Table3 on Table1.ID = Table3.ID
etc etc
Whether this would work as a singular input for RapiMiner, I'm not sure

Related

Compare a column in one table against a whole other table?

I know that SQL joins exist but that is only for one column against another column in another table. Is there any way to do something similar with one column against a whole table? I'm trying to figure out if the people that exist within one organization are a certain kind of employee. The problem is I have all the people in a organization listed within a column in one table while the classification for people is scattered throughout various columns in another table.
While I will answer this, I recommend you do one of those schoolkids tutorials on SQL. This question is at such a basic level you'll probably just get confused by the answers anyway...
From your question I would gather that the tables are probably modeled incorrectly to start with (not normalized well enough). But if you want to join a column to all the columns in another table you can do it in two ways:
SELECT COLUMN_1 FROM TABLE_1 T1 INNER JOIN TABLE_2 T2 ON T1.COLUMN_1 = T2.COLUMN_1
UNION ALL
SELECT COLUMN_1 FROM TABLE_1 T1 INNER JOIN TABLE_2 T2 ON T1.COLUMN_1 = T2.COLUMN_2
UNION ALL
... (just change the column name on each row)
(works best if you copy/paste this into Excel with a macro and a list of column names from table 2).
2) More complex: create a view or subquery where you first union all columns in table 2 one by one (hopefully they all have the same type!) and then join to the subquery, which now acts as a table with just one column.
3) Start pivoting table 2. Not going into that one, too complex for your current level.
Yes, you can Basically if you have one Table and then you want to filter out some name from there and then you can use joins
and the second part is yes you can add multiple conditions with the help of where clause.
and id you want to join on multiple conditions then also you can do with and condition

MS SQL Server 2017- Merging large tables automatically

Using Microsoft SQL server 2017, I want to merge two tables into a 3rd table.
Is there a way to have it defined automatically, without a query?
If it is not possible, I would like to mention that both tables contain a large amount of columns, therefore I look for an efficient query that will not make me write each column name.
Demonstration:
Original tables are Table1,Table2, column structure is as below:
Table1:
(Column1,Column2,Column3)
Table2:
(Column4,Column5,Column6)
My goal is to create Table3. Table3 is based on Table1 LEFT JOIN Table2 ON Column1=Column4.
Table 3:
(Column1,Column2,Column3,Column4,Column5,Column6)
Create it as a view.
CREATE VIEW table3 AS
SELECT Column1,Column2,Column3,Column4,Column5,Column6
FROM Table1 LEFT JOIN Table2 ON Column1=Column4
You can then reference table3 in other queries exactly like an ordinary table.

Merge multiple tables in SSIS or SQL command

I'm facing a problem with fetching data from multiple sources. It would be great if you can provide your ideas to design the SQL query.
I have to take data from two tables and INSERT it into a third table.
INPUT
TABLE 1
- TaskOrderNumer
- MemberID
TABLE 2
- ReferenceID
- MemberID
OUTPUT
TABLE 3
- TaskRefID
- PatID
My input table has TaskOrderNumber and MemberID. Right now I'm joining TABLE1 and TABLE2 based on MemberID. I'm getting the corresponding ReferenceID from TABLE2 and mapping it into PatID of TABLE3. The TaskOrder Number in TABLE1= TaskRefID in TABLE3.
I'm currently doing this using SSIS components. I want to make sure that the correct data is MERGED. I'm not able to map the TaskOrderNumber to TaskRefID. Can you please help me design the solution.
You can simply query the information you are trying to display. I am not sure I would even bother with SSIS here unless your sources aren't SQL.
select t1.TaskOrderID as TaskRefID
,t2.ReferenceID as PatID
into Table3 --Added this as edit.
from Table1 t1
join Table2 t2 on t1.MemberID=t2.MemberID

Drop column in DBVisualizer-query

I'm looking for a way to drop single columns from an extended query in DBVisualizer. I have a couple of tables with more than one hundred columns each. Using a number of subqueries I want to drop a single column from one of the tables, something like that:
select *
from table1 a
join table2 b
on a.key = b.key
drop b.key;
I defenitely do not want to write down all the single columns, because the query is supposed to be used for a long time and the tables get new columns to often to change the query each time.
Is there a way to do this?
Thanks
Felix

How to combine identical tables into one table?

I have 100s of millions of unique rows spread across 12 tables in the same database. They all have the same schema/columns. Is there a relatively easy way to combine all of the separate tables into 1 table?
I've tried importing the tables into a single table, but given this is a HUGE size of files/rows, SQL Server is making me wait a long time as if I was importing from a flat file. There has to be an easier/faster way, no?
You haven't given much info about your table structure, but you can probably just do a plain old insert from a select, like below. The example would take all records that don't already exist Table2 and Table3, and insert them into Table1. You could do this to merge everything from all your 12 tables into a single table.
INSERT INTO Table1
SELECT * FROM Table2
WHERE SomeUniqueKey
NOT IN (SELECT SomeUniqueKey FROM Table1)
UNION
SELECT * FROM Table3
WHERE SomeUniqueKey
NOT IN (SELECT SomeUniqueKey FROM Table1)
--...
Do what Jim says, but first:
1) Drop (or disable) all indices in the destination table.
2) Insert rows from each table, one table at a time.
3) Commit the transaction after each table is appended, otherwise much disk space will be taken up in case of a possible rollback.
4) Renable or recreate the indices after you are done.
If there is a possibility of duplicate keys, you may need to retain an index on the key field and have a NOT EXISTS clause to hold back the duplicate records from being added.