How can I make pentaho spoon auto-create a table? - pentaho

I am having few issues with pentaho spoon: I want to copy a table from one database to another.
When I click on "copy table" in the tool menu, it auto creates the transformation for that. But when I run it then I get these issues:
The truncate table is ticked that's why I get the error that my table does not exist.
I have to manually un-tick that. Even then I get an error because the table is not created. I have to click on the SQL and then execute the query. Is there any way to automatically do it?
Third problem is that pentaho created table is not detecting the date field, so it's putting the date type as UNKNOWN. I have to manually change that to varchar. Is there any way to fix that or default to VARCHAR?

The UNKNOWN data type is typically a driver issue. What database are you using and do you have the right driver?
There is no way to automate the creation of the table within PDI - it's deliberate that it does not do this. You could however integrate PDI with a tool which does do this, something like dbDeploy is a good idea.
UPDATE There is now a way to automatically create tables, you can follow the blueprint here:
https://github.com/mattcasters/blueprints

Related

Oracle SQL developer bug

I'm trying to create a table with the create table GUI. It doesn't let me change the table names. Most of them are still on 'COLUMN'.
I tried editing using the GUI but the names revert back to 'COLUMN'.
It doesn't always automatically create a DDL. when it doesn't, it doesn't change/edit my table.
I've tried installing a different version but mlno luck.

BigQuery browser tool doesn't reflect table schema

We have a table in BigQuery, and we wanted to change the column name. So we queried all columns, and the one that we wanted to change we used an alias to rename it. It appears to have worked, however the table schema in the browser tool still shows the old column name. We refreshed the project, and it still shows the old column name.
We renamed the field from "has_info" to "ct_info":
Is this a bug in the UI?
This is an issue with the UI. The problem is that the UI has cached the schema from the old version of the table, and doesn't realize that it has changed. A complete browser-level reload of the table will fix the problem.
I'll file a bug to see if we can improve this.

Add Table from different databases on crystal reports

Im using Crystal Reports to connect to my SQL Server Database from an ERP(PRIMAVERA).
The Problem is, there's a default report that i want to change and put more fields.
The user who created the report, used the same tables as i want to use, but one, that is not in my database.
I want to add a new table to the Datasource, thats from another Database(my database) to the default report that i want to edit(wich has the default datasource same as mine, but one table different).
Is it possible? If it is, how can i do it?
Yes this is possible. In the Database Expert, simply choose (or create) the connection to the 2nd database. Then add the table to the report. Crystal will give you a warning, but you can bypass that and use the table.
If the report is being used as part of another application, it may not work, but if your running from Crystal, there should be no problem.

extract raw SQL query from a Crystal Report .rpt file

I've got an .rpt file that I did not write and can find no documentation about. I want to be able to review the SQL that is generated from this report so that I can figure out, well, what data it was pulling and what WHERE clause parameters were used.
I can open it up and see the report layout. But when I select Database|Show SQL Query... the report tries to connect to the data source. The problem is, the data source being used is unknown to me, probably an ODBC connection used by whoever wrote the query. All I can do at that stage is 'Cancel' and I'm back to looking at the report designer.
Am I missing something? Can I get to the SQL query without connecting to the datasource? It seems like viewing the selection criteria shouldn't be dependent on a data connection.
Thanks.
version: Crystal Reports 2008
I know that this is an old thread, but I encountered this same problem. Effectively we used to have a database/application that has since been aquired by an external agency.
Although they now have the database/application they don't have access to crystal reports, so we can't just send them the old report that we used to run. Likewise we can't run it as we don't even have the database set up anywhere.... So instead our plan was just to extract the SQL code generated by the report and forward that on.
We experienced the same problem, but the solution is actually pretty simple.
If you don't have access to the original data source, just create a new 'blank' datasource (such as an ODBC connection). As long as the connection to the datasource works (i.e. it is some kind of valid datasource this it works fine). When running the 'Show SQL' option point the report to this datasource. As long as you don't try to actually run the report (and only show the SQL) the operation wont fail. This worked for our situation anyway. (Crystal Reports 2008)
(I can give more details if it helps in any way.)
It should be possible to find out some details about the existing datasource, by selecting Database > Set Datasource Location... .
As well as enabling you to change the datasource location, this should show you some information about the current datasource, such as which type of datasource is being used, and possibly (dependant on the type of driver) the name of the database. It is likely to be less helpful if (as you surmise) the datasource is ODBC, but if it uses a native driver there may be something useful.
Without the password, I'm not sure how much you can do. It seems "Show SQL Query" requires to report to run first, then generate the SQL plan.
It's not ideal, but you could go to Database > Visual Linking Expert to at least see the tables and how they are joined, and the go to the Record Selection Formula Editor and see what the custom WHERE statements are.
Viewing the SQL of a Command in a Crystal Report File
There are times you have just the report file, but not the associated database structure that the report uses.
This is common when dealing with example reports of functionality you wish to mimic.
This is a workaround ONLY to allow you to see the SQL of a Command that a Crystal Report is based on, when you don't have the underlying database connection that the report is based on.
In essence, the dialog box has to be satisfied before it will show the SQL, so we fool it with a legitimate Data Source, just not one that would work with the SQL that is actually in the SQL Command.
Why does a report use a command? Doesn't Crystal Reports have the ability to link tables?
When a Crystal Report is based on a record set that is too complex for the table linking functionality within Crystal Reports, the report can instead be based on a SQL Query, usually developed/tested in another editor tool and pasted into the command. This allows advanced SQL functions to be utilized.
If you don't already have a Data Source on your computer set up that you can connect to, you will need to build one first.
A simple Microsoft Access .mdb file saved in a simple location will suffice.
I placed mine with the path C:\A_test\test.mdb to make it easy to find.
If you don't have one, google for a sample mdb file and download it, saving it with a name and location you can remember. (You won't ever actually open this file, but just connect to it.)
Once you have the file saved, open the ODBC Administrator and create a New Data Source.
(you can get to the ODBC Administrator quickly from Start > type ODBC in the Search)
On the User DSN tab, click the Add button.
Scroll down the driver list to Microsoft Access Driver (*.mdb), select it and click the Finish button.
In the Data Source Name box, type a name (I used MyTest).
Click the Select Button and select the mdb file you saved from a previous step, click OK.
Click OK again. You will see your new Data Source listed by the name you gave it. Click OK.
You now have the data source you will need for the next steps.
Open the Crystal Report you want to see the SQL command for, and click on Database Expert button or Database>Database Expert Menu.
Under Selected Tables, right click on the Command and choose View Command
The Data Source Selection Box appears. Select the Data Source you created (or one you already use) and click the Finish button. The View Command box should open with the SQL in the left pane. Copy the SQL into your favorite text editor.
Whats happening is that the crystal reports needs a database to connect to regardless if its the original source DB or not.
Create a local database or use a database stored on a server, added it to your ODBC Datasources and use it when connecting. After a successful connection you should be able to view the SQL query without an error.

Is there a special sp on SQL server 2008 to get a table change script?

I wonder how management studio generates the change table scripts each time i change a table, especially when i change the datatype from 'text' to 'varchar(max)'.
Peace,
Ice
Update: Concerning the already given Answers i want to precise my question, after say thank you for your posts.
Now, it is like already said, ssms generates the scripts on demand but i want to write a script to identify all the tables in a given database with datatype [text] and change them to [varchar(max)]. So the easy part is to scan the dictionary to find the tables and columns, the harder part is to generate the mentioned scripts which copies all the rows into the new structur.
--> Yes i can work manually thru the list of tables and click in ssms to get the scripts, but there are almost 200 tables... better a computer do that work, isn't it?
If what you're asking is "Given a table, is there an easy way to get the DML used to create that table?" then I don't believe you can just run a system SP and get it. You'd need write something that selected from the system tables to get columns and datatypes, indexes, and everything else.
I wish there was an easy way to generate the same scripts SSMS does (like right-click -> "Modify" on a stored procedure), but it doesn't seem to be that easy.
When you change a table using the Management Studio table designer, the script is already prepared in the background, and you can simply click on the "Generate change script" icon to view it (and copy it if you like).
In SQL 2008, the "Generate change script" option is in the "Table Designer" menu.
If you're asking what it does, it's quite simple: SQL will create a new table with the new structure, copy all the data from the old table, drop the old one and rename the new one. If you open the script as described above, you'd see that.