Talend Open Studio line wrap causing sql statement invalid - talend

I am using Talend Open Studio for Data Integration 6.2.1.
When using the component tPostgresqlRow, I entered sql statement in the query field of the component.
Sometimes the sql statement is too long and Talend automatically line wrap the statement. It will make the sql statement not executable.
How to disable line wrap in Talend Open Studio? Or is there another way to execute sql statement?

I suppose you do not have reach the maximum sql statement length!
So, as a work around, try to put your statement to a global variable, then use it in tPostgresqlInput.
Hop this helps.
TRF

Related

Delete command in SQL

I want to delete 10 rows from access data
Oledbcommand cmd = new oledbcommand("Delete Top 10 From [Log], cnn);
cnn. Open();
cmd.ExecuteNonQuery();
But I have Syntax error in DELETE statement
The SQL syntax seems fine for SQL Server. (I assume you use SQL Server, because you use brackets for delimiting table or view Log. Sorry if I'm wrong...)
I think you got the error, because you forgot a closing quote for the SQL statement in your OleDbCommand constructor. And casing is sensitive in C#. You could try this:
OleDbCommand cmd = new OleDbCommand("Delete Top 10 From [Log]", cnn);
If you get a SQL related error, my assumption might be wrong and you need to look up the specific SQL syntax for the database system that you are using.
Tip: If you are using SQL Server, you may also look into the specialized SqlCommand class and corresponding classes in the System.Data.SqlClient namespace. They offer additional support for SQL Server functionality.

SQL Server 2008 Auditing - reports

Other than using SQL statement like
SELECT * FROM fn_get_audit_file('C:\SQLSvrAuditing*', default, default), are there good reporting available for SQL Server auditing? Even if there are useful query templates, it will be helpful.
No, there is no elegant solution for reading *.sqlaudit files.
One option is to use the fn_get_audit_file function, like you said. You can use the exact column list, and add a WHERE condition to narrow down the results. E.g.
WHERE action_id IN ( 'LGIF' , '%AU%', 'SL', 'IN', 'DR', )
Another option is to use the Log File Viewer utility in SQL Server Management Studio.

Talend How to read multiple refcursors returned from Oracle sp

I have called an Oracle Stored Procedure which is returning 7 refcursors in Talend Open Studio 5.3.
I want to read all the refcursors and create a single XML file.
I got this working. I have linked the t_parserecordset with t_Oraclesp and then I flowed all the cursors in a t_main component. After that I have created a t_parserecordset for each cursor with input link from t_main component and read the columns.
Now it is working fine.

TSQL - export query to xls /xslx / csv

I have a complicated dynamic query in TSQL that I want to export to Excel.
[The result table contains fields with text longer than 255 chars, if it matters]
I know I can export result using the Management Studio menus but I want to do it automatically by code. Do you know how?
Thanks in advance.
You could have a look at sp_send_dbmail. This allows you to send an email from your query after it's run, containing an attached CSV of the resultset. Obviously the viability of this method would be dependent on how big your resultset is.
Example from the linked document:
EXEC msdb.dbo.sp_send_dbmail
#profile_name = 'AdventureWorks2008R2 Administrator',
#recipients = 'danw#Adventure-Works.com',
#query = 'SELECT COUNT(*) FROM AdventureWorks2008R2.Production.WorkOrder
WHERE DueDate > ''2006-04-30''
AND DATEDIFF(dd, ''2006-04-30'', DueDate) < 2' ,
#subject = 'Work Order Count',
#attach_query_result_as_file = 1 ;
One way is to use bcp which you can call from the command line - check out the examples in that reference, and in particular see the info on the -t argument which you can use to set the field terminator (for CSV). There's this linked reference on Specifying Field and Row Terminators.
Or, directly using TSQL you could use OPENROWSET as explained here by Pinal Dave.
Update:
Re;: 2008 64Bit & OPENROWSET - I wasn't aware of that, quick dig throws up this on MSDN forums with a link given. Any help?
Aside from that, other options include writing an SSIS package or using SQL CLR to write an export procedure in .NET to call directly from SQL. Or, you could call bcp from TSQL via xp_cmdshell - you have to enable it though which will open up the possible "attack surface" of SQL Server. I suggest checking out this discussion.
Some approaches here: SQL Server Excel Workbench
I needed to accept a dynamic query and save the results to disk so I can download it through the web application.
insert into data source didn't work out for me because of continued effort in getting it to work.
Eventually I went with sending the query to powershell from SSMS
Read my post here
How do I create a document on the server by running an existing storedprocedure or the sql statement of that procedure on a R2008 sql server
Single quotes however was a problem and at first i didn't trim my query and write it on one line so it had line breaks in sql studio which actually matters.

T-SQL escape quote character

NOTE: It's probably a duplicate but I can't find working answer.
Following is what i'm trying todo, notice a ' in the value. How do I fix this?
INSERT INTO [pugraider].[dbo].[Realms]([Name]) VALUES('Aman'Thul')
I use MS SQL Server Management Studio 2008.
EDIT: I'm writing a script to populate a lookup table (ID<->Name).
This will work:-
INSERT INTO [pugraider].[dbo].[Realms]([Name]) VALUES('Aman''Thul')
Ordinarily the only reason to have such hardcoded values in T-SQL is in DB construction code such as initialising look up tables.
Otherwise this code might be a result of string concatenation to build up some T-SQL from some input source. If that is the case its worth finding ways to avoid it since it can open your application to SQL injection attacks.