String Formatting Expression Problem
May 27, 2008
I have what should be a simple string formatting issue -- removing all alpha characters from a phone number. T-SQL below is simple and works just fine:
declare @home_phone as char(14);
set @home_phone = '(123)979-3206';
set @home_phone = REPLACE(@home_phone,'-','');
set @home_phone = REPLACE(@home_phone,'(','');
set @home_phone = REPLACE(@home_phone,')','');
The condensed version below works equally well:
set @home_phone = REPLACE((REPLACE((REPLACE(@home_phone,'(','')),')','')),'-','');
Either script above returns correct result:
select @home_phone;
Result = '1239793206'
HOWEVER, within SSIS Derived Column expressions, this function fails to remove parentheses. First of all, Expression Builder doesn't like outer single quotes (turns red) which I resolved by using double quotes resulting in the following expression:
REPLACE(home_phone,"-","") + REPLACE(home_phone,"'('","") + REPLACE(home_phone,"')'","")
Unfortunately, this expression fails to remove parentheses and instead returns: '(123)9793206'
I've tried several different permutations--no inner single quotes; adding more inner single quotes; etc., but so far no success. Any suggestions would be much appreciated!
View 15 Replies
ADVERTISEMENT
Mar 2, 2012
I'm trying to put conditional formatting on a field, that behaves as follows:
The data in the field is varchar, and sample data is either:
NULL
3.0 :0
11.7 :1 (these are ratios of a sort)
I want to evaluate the first 3 characters of the string as numbers.
Example:
Mid(fieldvalue,1,3) = "3.0" or "11."
Any data that is greater than 1.99, I want to make the background dark red, anything else including nulls, zebra formatting. I have the following expression built so far and it appears to work, except when the value is null. If the value is null, it leaves the background color white.
This is the warning: [rsRuntimeErrorInExpression] The BackgroundColor expression for the text box "Asthma" contains an error: Input string was not in a correct format.
=iif(
isnothing(Fields!Asthma.Value)
,(IIf(RowNumber(Nothing) Mod 2 = 0,"#b8cce4","#dbe5f1"))
,(iif(mid(Fields!Asthma.Value,1,3)>1.99
,"DarkRed"
,IIf(RowNumber(Nothing) Mod 2 = 0,"#b8cce4","#dbe5f1"))))
My logic is, if the field is null, zebra format, if mid of the value is > 1.99, dark red, everything else zebra formatting. As I said, this seems to work except for nulls.
View 2 Replies
View Related
Jan 29, 2007
hey there
Using Reporting Services 2005
I have a date time field
Fields!CreatedDate.Value which I am grouping on and Counting on an ID Field
result of grouping is this
7/13/2006 12:00:00 AM 1
7/21/2006 12:00:00 AM 11
8/7/2006 12:00:00 AM 3
8/8/2006 12:00:00 AM 2
I know if I put (Month(Fields!CreatedDate.Value)
I get this result
7 1
7 11
8 3
8 2
What I really want is
July 12
August 5
how do I do this please
thanks
View 1 Replies
View Related
Mar 25, 2008
I have created a report that uses a fairly complex IIF statement to sum the data. That part works just fine. Now I need to format the font color so negative values show in red. Is there a way to reference the individual cell (by its textbox name maybe?) in the Expression Editor?
For example, if tb_Orders was the name of the textbox that sums the data, I'd like to write something like:
=switch(tb_Orders < 0, "Red")
I could just copy the IIF statement but I'd rather keep things simple. This way, if I need to change the formulas, I don't have to change all of the conditional formatting as well.
Is this possible?
Rob
View 4 Replies
View Related
Jul 10, 2006
What is the equivalent SSIS expression for this C expression to format an unsigned integer by padding it with leading zeros?
sprintf(publ_doc_id, "%010u", id)
View 1 Replies
View Related
Apr 24, 2015
Is it possible to format part of an expression?
I have an expression:
=(Fields!Intervention_Date_Of_Service.Value & vbcrlf & Fields!Intervention_Comment.Value & Fields!Intervention_ID.Value )
I would like my report to display Fields!Intervention_Date_Of_Service.Value underlined
i.e.,
"4/6/2015 12:45:00 PM"
Applied Data Script
ID 76584
View 2 Replies
View Related
Apr 11, 2008
Can I build an expression that allows me to change the field size of a column or row in SSRS2005?
View 5 Replies
View Related
Apr 14, 2008
Hi, I've a string like :
'...,,,,,123456789,,,,,,.........876564532$$££^^(.........,,,,,'
I'd like to know if there is a way to replace everything between these two integers (well, actually we can say two words as they are in the string format) with a single comma (i.e ,) and remove everthing leading and trialing to these two numbers please ?
In short , I would like to see the above line after string manipulation as follows :
'123456789,876564532'
Thanks for your help.
View 18 Replies
View Related
Jul 26, 2004
I am well stuck in the mud right now.
Here is the problem. I am trying to write this: strLink2 = "<a href='JavaScript:OpenFile(" & strFileName & ")'>" & strFileName & "</a>" to SQL and then return it to a datagrid when I want it.
Easy enough, and as such all is well except for the fact that the Javascript doesn't work. In the grid it gets written as JavaScript:OpenFile(myfile). I need to add the single quotes around the file name so it writes JavaScript:Open('myfile').
I now know many ways that do not work. Any help would be greatly appreciated.
View 5 Replies
View Related
Dec 9, 2007
Is there anything in SSIS that enables simple string reformatting?
For example I'd like to convert the character string 1234567.89 to 1,234,567.89.
I used to do this with an edit pattern in Cobol, but I can't see anything in the Expressions editor....
View 4 Replies
View Related
Sep 12, 2007
I have a string in which I am combining several fields. Is there a way to add formatting to the string as well
="Baud: " & Fields!BAUDRATE.Value & " DL Status: " & Fields!COMMSTATUS.Value
Example, I want my fields to appear in bold and string in normal.. I can't do this in an individual textbox due to space constraints
View 1 Replies
View Related
Jul 9, 2013
'17686568 - Bill Statement - 11/16/2006 - Stm. Date - 10/27/2006'
Above is the data string that I am trying to pull the information from. Here is the function I'm currently using:
cast(substring(c.itemname,charindex('Bill Statement - ',c.itemname)+18,10) as varchar)
...which gives me what i want most of the time, but beacuse the date is not equally formatted through out the database and the date can look like 5/4/2012 and using the above formula it will show up as 5/4/2012 -
So my question is how can i trim off the dash part when the data shows up like 5/4/2012 - ?
View 3 Replies
View Related
Aug 9, 2006
Hi,
I have a table which has expression as a column and the data looks similar to the following .
ID (int) Expression (nvarchar data type)
1 8*(1/2)-6
2 278*(1/4)-2
3 81*(3/5) +4
I now have the expression as an nvarchar. (Ex: 8*(1/2)-6)
Now I need to evaluate this expression and output the result (which is -2 in above Ex) .Can someone give me idea on how do I evaluate the expression which is available as a string. I need to write a procedure for this.
I am unable to cast/convert nvarchar to float/int
Any sample code would be greatly appreciated.
This a very urgent requirement for me.Please get back
Thanks
Swapna
View 8 Replies
View Related
Jul 10, 2007
Hi,
could you help me. I'd like to get last position of the specified expression in a character string(a fast solution for DB)
Thanks for youe help
View 5 Replies
View Related
Oct 10, 2007
I can't figure this one out. I don't have enough knowledge of the string functions I guess.
I need to pull a value out of a variable I setup in a for each loop. The value is the filename/path of each source file being processed. Let's say the variable that has the source file path is called VAR1.
One sort of off topic thing I've noticed is when watch the variable in bebug mode and I look at the value of VAR1 it has double back slashes. Here's an example of the value of VAR1:
"\\L3KRZR6.na.xerox.net\C$\Documents and Settings\ca051731\Desktop\Project4\DPT_20070926.ver"
How come the back slashes have been doubled? And do I need to account for that when I start parsing the string value?
Anyway, I need to grab part of the filename from VAR1 and I need the value populated at the start of the for each loop container - ideally when I capture VAR1 in the for each container. I'll be using the string in drop table, create table and create index statements before the actual Data Flow task within the overall package
In the above example I need to grab the characters before the underscore and after the last \. So I'd need the string "DPT" captured in this example.
The actual string could be 1 to 3 characters long, even though this example has it as 3 long.
Underscores could exist anywhere in the actual UNC path once this package is moved to our actual system environments so I can't key off of the underscore.
Because I can't count on the string being a fixed lenght I can't just use a positional string function and grab specific text starting/ending at specific points.
Is there a way to use the various string functions in the expression builder to grab the text between the right most underscore and the right most back slashes or something like that? Ideally I'd like to setup a new expression based packed scope variable called VAR2 and build it using string functions applied to VAR1.
View 1 Replies
View Related
Dec 4, 2007
I'm not exactly sure how to phrase this problem. If I'm going about this the wrong way, any pointers would be appreciated.
I am using an expression for a data source connection so I can decide which server/database to use at runtime. I also need to pass credentials to use for that connection. The only way I'm able to get this to work is to specify "No Credentials" for the data source and then pass a DataSourceCredentials to the report throught the report viewer. This works, for the most part, but puts a "Change Credentials" link in the report viewer.
What I think would be much better is if I could specify the credentials in the connection string that I pass. However, everything I've tried so far has not worked. I get errors complaining that the compination of options is invalid or that the report server cannot find the credentials of "unknown keyword: User Name". All by trying various combinations of things.
How do other people go about this? I've seen blogs implying that this is not such a big deal (that credentials CAN be passed over in the connection string). Hopefully I'm missing something simple here. If I have no choice, the "Change Credentials" link will not be the end of the world, but that's very sloppy. The people viewing this report will not know anything about the database credentials and I'd rather not show them somthing as inviting as a link that can get them off track.
Thanks for your help!
-C
View 3 Replies
View Related
Oct 22, 2000
How would I convert an expression like on of these to all upper case first letters with remaining letters lower case? VB has a function for that but sql doesn't seem to. I thought about having a loop go through each character to check for spaces. I've written a couple of similar pieces of code in VB when a while ago, but is there a better way? Thanks :)
Just a couple of typical examples of how the data should appear ~
payment, credit card ==> Payment, Credit Card
butcher & singer ==> Butcher & Singer
View 1 Replies
View Related
Dec 7, 2007
Any idea why this expression would not work in SSRS?
Based on a expression on a group textbox I get 0 records that match:
=Iif(Fields!ACCRUAL_CODE.Value <> "A", CountDistinct(Fields!LOAN_NBR.Value), 0)
I've evaluated in the proc & there should be a count of 29 records.
I found a work around by using this in the stored proc & I get my record count:
ACCRUAL_CODE = CASE WHEN BASE.ACCRUAL_CODE = 'A' THEN 0 ELSE 1 END
and changed the expression in SSRS to this & it works:
=sum(Fields!ACCRUAL_CODE.Value)
Is this a known issue with strings? From searching on this site I see that string evaluations are widely used so I do not see why it wouldn't work. I've also see this when filtering the dataset on anything that is a character. Any suggestions?
View 3 Replies
View Related
Mar 1, 2014
I need to verify data in a column and do pattern matching on the string in each field.
I've create a CLR Function that will verify the element against the patter and return a True or Fales....
I have only used reg expressions once and am struggling mightly. I'm bacially here. A
I need to match a pattern that each word in the string will be a Capital letter.
ex. The beginning of the day - Fail
ex. The Beginning Of The Day - Pass
[URL] .....
View 2 Replies
View Related
Jul 15, 2010
Within the MDX "Action expression" of a url-action I need to replace some text from a string that is used in building the URL.
replace("hellowhatever","what","")
The above syntax errors out, is this type of formatting possible with MDX action expressions?
View 3 Replies
View Related
Apr 3, 2015
I have written a query to search for a string in an expression by the number of it's appearance. Script is like this:
DECLARE @Expression VARCHAR(8000) = 'abcd_e_fgh',
@SearchString VARCHAR(10)= '_',
@OccuranceNumber SMALLINT = 1
DECLARE @SearchIndex INT = 0, @SearchIndexPrevious INT = 0, @Sno INT = 0
WHILE @Sno < @OccuranceNumber BEGIN
[Code] .....
Here i'm trying to search "_" in expression "abcd_e_fgh" where it is appearing for first time. it gives me 5 correctly. Now when i change the @OccurenceNumber to 2 or 3, it gives correct values 7 and -1 respectively. However now when i change it to 4, it gives me 5. So when it's trying to check for fifth appearance of "_", it's not actually giving 0 or -1 but repeating the value 5.
View 9 Replies
View Related
Apr 15, 2006
Hi, I have a datareader component of which i am dynamically setting its sqlcommand statement with expression (click the background of dataflow > properties > expressions). Now my sql select statement has about 600 fields so that makes my expression statment "select field1, field2, .....from table1 where field2 >=" + @[User::dateforfield2] but when i evalute the expresssion (which is right), i get the error: A string literal in the expression exceeds the maximum allowed length of 4000 character and i think its because of the fields in my select statment causing my string literal to grow more than 4000 characters. Is there any way to increase the max string literal for expressions. Please help.
View 1 Replies
View Related
Oct 15, 2007
hi,
i am using a forEach look to import each file within a folder, but i also need to calculate the dataset related ot these files.
the file are named as:
ff_inbound_20071008_1.csv
ff_inbound_20071008_2.csv
where for file ff_inbound_20071008_1.csv:
ff => flat file
inbound => dataset of this csv
20071008 => date
1=> file count
having in mind that they are store in the variable as a full path:
z:myFlatFilesexportsproj01ff_inbound_20071008_2.csv
i need to extract the dataset and the date for each file.
how can i extract these terms from the file name?
many thanks,
nicolas
View 4 Replies
View Related
May 7, 2012
Having trouble casting GETDATE() to a string value (DT_STR) using expression builder? I want to concatenate the current date to some text used in a send mail task.
View 5 Replies
View Related
Jul 26, 2015
Error: The variable "$Package::LocalConfigDB_ConnectionString" was not found in the Variables collection. The variable might not exist in the correct scope.
Error: Attempt to parse the expression "@[$Package::LocalConfigDB_ConnectionString]" failed and returned error code 0xC00470A6. The expression cannot be parsed. It might contain invalid elements or it might not be well-formed. There may also be an out-of-memory error.
View 3 Replies
View Related
Jan 12, 2006
I previously had an ASP.NET 1.1 site running on my IIS 6.0 server (not the default website) with Reporting Services running in a subdirectory of that website. I recently upgraded to ASP.NET 2.0 for my website and was greeted with an error when trying to view a report. The error was very non-descript, but when I checked the server logs, it recorded the details as "It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process."
First of all, I could not figure out where and how to do this. Secondly, I decided to try to also change the Reporting Services folders to run ASP.NET 2.0 and when I did, I was greeted with the following message when attempting to view a report:
"Failed to load expression host assembly. Details: StrongName cannot have an empty string for the assembly name."
Please help.
View 7 Replies
View Related
Feb 8, 2007
Error 3 Error loading MLS_AZ_PHX.dtsx: The result of the expression ""C:\sql_working_directory\MLS\AZ\Phoenix\Docs\Armls_Schema Updated 020107.xls"" on property "ConnectionString" cannot be written to the property. The expression was evaluated, but cannot be set on the property. c:documents and settingsviewmastermy documentsvisual studio 2005projectsm l sMLS_AZ_PHX.dtsx 1 1
"C:\sql_working_directory\MLS\AZ\Phoenix\Docs\Armls_Schema Updated 020107.xls"
Directly using C:sql_working_directoryMLSAZPhoenixDocsArmls_Schema Updated 020107.xls
as connectionString works
However - I'm trying to deploy the package - and trying to use expression:
@[User::DIR_WORKING] + "\Docs\Armls_Schema Updated 020107.xls"
which causes the same error to occur
(Same error with other Excel source also:
Error 5 Error loading MLS_AZ_PHX.dtsx: The result of the expression "@[User::DIR_WORKING] + "\Docs\Armls_SchoolCodesJuly06.xls"" on property "ConnectionString" cannot be written to the property. The expression was evaluated, but cannot be set on the property. c:documents and settingsviewmastermy documentsvisual studio 2005projectsm l sMLS_AZ_PHX.dtsx 1 1
)
View 4 Replies
View Related
Oct 28, 2015
I have created 1 report with 2 datasets. This report is attached to the 1st dataset.For example,1st one is "Smallappliances", 2nd is "Largeappliances".
I created a tablix and, the 1st column extracts Total sales per Sales person between 2 dates from 1st dataset (Small appliances). I used running values expression and it works fine.
Now, I would like to add another column that extracts Total sales per sales person between 2 dates from 2nd dataset (Large appliances). I am aware that I need to use Lookup expression and it is giving me the single sales value rather than the total sales values. So, I wanted to use RunningValue expression within lookup table to get total sales for large appliances.
This is the lookup expression that I added for the 2nd column.
=Lookup(Fields!salesperson.Value,Fields!sales_person.Value,RunningValue(Fields!sales_amount.Value,
sum, " sales_person"),
"Largeappliances").
I get this error when I preview the report.An error occurred during local report processing.The definition of the report is invalid.An unexpected error occurred in report processing.
(processing): (SortExpression ++ m_context.ExpressionType)
View 7 Replies
View Related
Aug 18, 2005
Hello all,I have a strange problem that i need some advice on. I have the following field called FILENO. It is a SQL 2000 field with the Data Type set to Char (7). The following sql statement works perfectly:SELECT TOP 1 RTRIM(FILENO) AS TEST, RIGHT(DATEPART(Yy, FILENOYEAR), 2) AS YEAR FROM tblRecordsWHERE RIGHT(DATEPART(Yy, FILENOYEAR), 2) = '05'ORDER BY FILENO DESCIt returns the correct data, 0050. Now, what i'm trying to do is add 1 to the value so i can get the next available number which is 0051. But, when i run the following sql statement, i get 51 instead of 0051.SELECT TOP 1 RTRIM(FILENO+1) AS TEST, RIGHT(DATEPART(Yy, FILENOYEAR), 2) AS YEAR FROM tblRecordsWHERE RIGHT(DATEPART(Yy, FILENOYEAR), 2) = '05'ORDER BY FILENO DESCDoes anyone have an idea how to solve this? Thanks.Richard M.
View 1 Replies
View Related
Feb 28, 2001
I'm working as a consultant for a project and I have been having constant issues with the in house "database guru" about stored procedure formating.
He insists I use a format similar to this:
create procedure getUser @UserId int = NULL
as
select
UserName
, UserPassword
, UserRole
from
Users
join
UserRole
on
User.ID = UserRole.ID
where
User.ID = @UserID
and
User.Active = 1
where as I prefer this format:
create procedure getUser
(
@UserId int = NULL
)
as
select UserName,
UserPassword,
UserRole
from Users
join UserRole on User.ID = UserRole.ID
where User.ID = @UserID
and User.Active = 1
Now normally I don't argue about style issues but I find his format confusing and it bothers me that it senselesly wastes lines make the stored procedure longer than necessary.
I'd love to get some comments on this issue or reference to any discussions on issues such as this.
Thanks
View 2 Replies
View Related
Apr 9, 2008
Hello -
Does anyone know why SQL Server Reporting Services formatts SQL weird? -- If I type a SQL statement in notepad or notepad++ and then paste it in Reporting Services it will change the whole structure and "expand" it out to three or four times its size.
Thanks
Adam
View 3 Replies
View Related
Mar 10, 2015
I have a scenario where in I need to use a comma delimited string as input. And search the tables with each and every string in the comma delimited string.
Example:
DECLARE @StrInput NVARCHAR(2000) = '.NET,Java, Python'
SELECT * FROM TABLE WHERE titleName = '.NET' AND titleName='java' AND titleName = 'Python'
As shown in the example above I need to take the comma delimited string as input and search each individual string like in the select statement.
View 3 Replies
View Related
Dec 12, 2006
Hello All,
Is it possible to format an integer to a float value with 2 decimals in an sql query.
If yes, Please help?
View 2 Replies
View Related