Force linebreak in VS05 SSRS textbox - reportingservices-2005

In a VS05 SSRS report I have a field coming back from the database that I concatenated together.
Ex:
SELECT Field1 + ' ' + Field2
I'm wanting to show this in a single textbox on the report but with a line break between the two fields.
I've tried:
Field1 + '\r\n' + Field2
but of course, no luck.
What special characters can I use to force a line break in my cell?

You can add line breaks in SQL by concatenating CHAR(10) + CHAR(13) to your values.
However I'd advise you to do formatting in the report rather than the database. In this case you would use the Visual Basic character vbCrLf in the texbox.

Related

How to retain double quotes in a column while loading a file using SQL Loader

I am trying to load a txt file with | (pipe) delimiter to an Oracle table via SQL loader utility. All the fields are enclosed with double quotes. But there are some text fields in the files that have additional double quotes in addition to the enclosed ones that needs to be retained. All the table columns are defined as VARCHAR. Here's the control parameters am using
OPTIONS (DIRECT=TRUE,SKIP=1)
LOAD DATA
CHARACTERSET UTF8
INFILE aaa.txt
APPEND INTO TABLE info_table
FIELDS TERMINATED BY "|"
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
This is my sample file
"1"|"High "Gold Tip" Tea, 600"
"2"|""10000 Beers, Wines & Spirits""
Table should be loaded with the below details
Record 1:
Column 1 - 1
Column 2 - High "Gold Tip" Tea, 600
Record 2:
Column 1 - 2
Column 2 - 10000 Beers, Wines & Spirits
Unfortunately, there's nothing much to be said.
File format is bad. You can't enclose values into characters that are used in those fields themselves. As data contain double quotes, you'll have to optionally enclose values into something else, not double quotes.
However, as you already split values with pipe characters, what do you need double quotes to optionally enclose those field values? Omit them from the file and you won't have any problem (of such kind, of course; who knows what might come next, but that's another story).

Delphi Adoquery SQL add or text

I'm trying to update my database in Delphi, but I'm not getting it right.
What I want is simple. This is my code:
form1.ADOQuery1.SQL.Clear;
form1.ADOQuery1.SQL.Add('Update Table1 set mark=' +Form1.Edit4.Text);
form1.ADOQuery1.ExecSQL;
So basically, what I want is the Text written in the Edit to go into my database with the UPDATE function, where my database table is table1 and the field is named mark.
There is not enough information in your question to provide a definitive answer. However, I can make an estimated guess.
What you have shown would only work successfully if mark is defined as an ordinal or boolean field, and the user is entering appropriate numeric/boolean values into the TEdit.
But, if the mark field is defined as a textual field instead, you need to wrap the Text value in quote characters, otherwise you will produce invalid SQL syntax.
Imagine you entered a Text value of 'hello world'. Your original SQL statement would end up being the following, which is invalid syntax:
Update Table1 set mark=hello world
You need to wrap text values in quote characters instead:
Update Table1 set mark='hello world'
Or:
Update Table1 set mark="hello world"
For example:
form1.ADOQuery1.SQL.Add('Update Table1 set mark=' + QuotedStr(Form1.Edit4.Text));
Or:
form1.ADOQuery1.SQL.Add('Update Table1 set mark=' + AnsiQuotedStr(Form1.Edit4.Text, #34));
It is important to use a function like (Ansi)QuotedStr() to avoid SQL injection attacks. This is done by ensuring any embedded quote characters in the input text are escaped property. Otherwise, if you just did something like this instead:
form1.ADOQuery1.SQL.Add('Update Table1 set mark="' + Form1.Edit4.Text + '"');
The user could enter a text value like '"; <arbitrary SQL here>' and really reek havoc with your database.
The safer approach is to use a parameterized query instead, and let ADO handle any necessary SQL formatting for you (make sure TADOQuery.ParamCheck is true):
form1.ADOQuery1.SQL.Clear;
form1.ADOQuery1.SQL.Add('Update Table1 set mark=:Mark');
form1.ADOQuery1.Parameters.ParamByName('Mark').Value := Form1.Edit4.Text;
form1.ADOQuery1.ExecSQL;

While exporting data from Oracle PLSQL to Excel, format issue is coming

I am trying to export data from Oracle PLSQL to Excel.
The data type of one of the column is VARCHAR2.
The Column conatins value like 00798019859217.
But after exporting, the value in excel is something like this 7.9802E+11.
PLease let me know how to resolve this and the reason for this format issue.
Thanks in advance.
Do the following:
Select the column with single quotes, say
SELECT ("'" || COLUMN_NAME) AS COLUMN_NAME, OTHER_COLUMNS FROM MY_TABLE
Output will be like:
'ABC0157976
'00798019859217
Export the output to an excel.In excel "A" column values will be
'ABC0157976
00798019859217 (Single quote will not be visible for number only values)
Select the entire "A" row and clear all single quotes with replace all option. You will get final excel as.
ABC0157976
00798019859217
Since it is a text field and non-numeric characters are also expected to be present, the step#3 is required. If it is going to be only numeric characters, then step #3 can be ignored.
This is happening due to excel where the number auto casted. As #HamidP said try exporting as csv and check with opening in notepad or text, and check whether the number displaying fully or not. If so then you can open the same in Excel with small options change such
Right click the cell and click format option and make it cell format as text and then save the excel.

Showing only actual column data in SQL*Plus

I'm spooling out delimited text files from SQL*Plus, but every column is printed as the full size per its definition, rather than the data actually in that row.
For instance, a column defined as 10 characters, with a row value of "test", is printing out as "test " instead of "test". I can confirm this by selecting the column along with the value of its LENGTH function. It prints "test |4".
It kind of defeats the purpose of a delimiter if it forces me into fixed-width. Is there a SET option that will fix this, or some other way to make it print only the actual column data.
I don't want to add TRIM to every column, because if a value is actually stored with spaces I want to be able to keep them.
Thanks
I have seen many SQL*plus script, that create text files like this:
select A || ';' || B || ';' || C || ';' || D
from T
where ...
It's a strong indication to me that you can't just switch to variable length output with a SET command.
Instead of ';' you can of course use any other delimiter. And it's up to your query to properly escape any characters that could be confused with a delimiter or a line feed.
Generally, I'd forget SQL Plus as a method for getting CSV out of Oracle.
Tom Kyte has written a nice little Pro-C unloader
Personally I've written a utility which does similar but in perl

Regex for searching Database-Statements in VisualStudio

I am currently working on a rather large project in Visual Studio 2008 with a lot of Database-Statements. The Statements are held in strings like this:
string stmt = "SELECT ID, OTHER " +
"FROM TABLE " +
"WHERE CONDITION";
I was wondering how to find all Statements via regex. So I am not so good at regex, but maybe someone got any idea? I don't know if it's impossible because of the multilining? Does it work with the search inside Visual Studio?
EDIT to answer of Clement: Well SQL-Statements are not only SELECT-Statements, in my case there are also a lot of UPDATE- and INSERT-Statements. But what if there other eg. CREATE-Statements?
CTRL + F, Choose "Active Project", and specify "SELECT" as token, no ?
Run a regular expression that uses the '|' operator which acts as an or. An example would be this:
Text To Search
"INSERT INTO table; SELECT * FROM table; UPDATE table; DELETE FROM table"
RegEx expression
INSERT|SELECT|UPDATE|DELETE
This returns these values along with their index
INSERT
SELECT
UPDATE
DELETE

Resources