How To Find Terms In A File Name: Regular Expression OR A String Function
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 Complete Forum Thread with Replies
Related Forum Messages:
Using A Regular Expression In MSSQL 2005 To Find Patterns Buried In A Field Full Of Misc Data
Thanks in advanace for taking the time to read this post. I am using MSSQL 2005 and have created a function that allows me to use regular expressions in my SQL queries. My question is I have a pattern buried in a field of misc data that I need to pull out just that pattern and discard the rest of the data. Here is the Regular Expression I am using select field1 from table1 where dbo.RegExMatch (field1,'[a-zA-Z]{4}[0-9]{6}[a-zA-Z]{2,4}')=1 This returns all values in the field that match the expression. What I want to do now is remove all data from the field on the left and right of the expression that does not match the expression. How would I accomplish this without reading through the 200k+ records and writing rules for every exception I run across? so I could have Gar b/a ge 'THE GOOD DATA' m/or1 ba4d da....ta. All I want to do is return 'THE GOOD DATA'
View Replies !
How To Convert A Returning String From Custom Code To A Function In Expression?
I have a custom code function that return string like: "SUM(Fields(Parameters!dept.Value + ""_1HeadCount"").Value) + SUM(Fields(Parameters!dept.Value + ""_2HeadCount"").Value) + SUM(Fields(Parameters!dept.Value + ""_3HeadCount"").Value) " How do I convert this string to a function inside the expression (in this case "SUM", "Fields", "Parameters!", etc.)? The expression of my TextBox show the string as a string instead of converting them to proper function and display the corrent value. The reason I need to build the string is because the Fields number is dynamic and I need a loop to increase the number in the field name. Any suggest is highly appreciated! Thanks, Tabbey
View Replies !
Regular Expression?
I need to remove all the [ and ] in every sql stmt where they are usedto close encircling numeric value, fyi, all these sql stmt areconverted from an Access db. For instance,select *from XYZtblwhere fieldA = [1] or fieldA = [2] or fieldA = [3]to beselect *from XYZtblwhere fieldA = 1 or fieldA = 2 or fieldA = 3-- and of course I'd have written in as follows, but that's not-- the pointselect *from XYZtblwhere fieldA IN (1,2,3)Thanks.
View Replies !
Regular Expression?
HiI'm looking to return rows from a table where a column is LIKE a keyword. This is my current code:SELECT DISTINCT business_name FROM Table WHERE business_name LIKE @keyword + '%' ORDER BY business_name ASCThe problem with this is that if a business is called "The White Ship Inn", and the keyword to match is "White Ship" it will not match. If i put another wild card in front of @keyword then this finds too many matches - i need it to match against columns which either start with the keyword, or have a whitespace in front of them. Is there some kind of T-Sql i can use or will i have to go down the regex route (using this (http://www.codeproject.com/KB/mcpp/xpregex.aspx)) ?cheers
View Replies !
Regular Expression..
Does SqlServer support Regular expression? I want to know if it's avilable or not... And if it's not available, I want to know any other efficient way to validate string.. manipulating Regular expression style validation. Thank you all...
View Replies !
Regular Expression
Hi Guys I have a table in which one of the column name is "NAME". I have to write query in which column is not null and if there is something then check for 'trust' or 'trustee' in the string. and if found don't pull that record. skip it who do i do these. Any help please.
View Replies !
SELECT And Regular Expression
Hi,I'm not a big friend of MSSQL, but I have to do one query I've done formySQL.But I don't know how...I have to select 'user' from 'db' where first letter is E or N, second is Bor 0 and after that there are 6 or 7 digits I know.How can I do that?In mySQL it would be something like:SELECT * FROM `table` WHERE `account` regexp '^[EN][B0]123456$' ORDER BY`Id`;Thanks in advance,Martin
View Replies !
Regular Expression Issue
I am trying to exclude all strings that has 'a' inside (I havesimplified the actual problem)select 1where 'bb b a dfg' like '%[^a]%'However, the above does not work. By the way, I can not use 'not like'such as:select 1where 'bb b a dfg' not like '%a%'Although the above will work but the idea is that I have to use 'like'and not 'not like'. This is partly because I have to exclude rows froman exclusion table (a table that has many rows that will be excluded).Actually I want to include all srings that has lets say // in it usinga regular expression. I would like to write it as (I am sure it willnot work):select 1where column like '%[^/][^/]%'That should exclude strings like: 'aaa // aa aa' or 'bb bbb // bb' etcand include strings like: 'aaa aa aa' or 'bb aa nn' etcIs there any way to write a regular expression to do it? Otherrwise Ihave to solve this problem without using regular expressions in theexclusion table.Thanks.
View Replies !
Regular Expression For Whole Words
I am try to build a query which only matches whole words and so far I've got this. Code: SELECT * FROM tblSearchWords WHERE CorrectSpelling LIKE '%[^a-zA-Z0-9]blah[^a-zA-Z0-9]%' This will return rows which contain the string 'blah' without any numeric or alphanumeric characters beside it. However it doesn't return the rows where 'blah' is either at the start or end of the string as it expects any character except a-zA-Z0-0. Is there any way to accept string when there is nothing on either side as well? Thanks, Goran
View Replies !
PATINDEX / LIKE - How To Do A Regular Expression In One Of These?
Hi I have a table which stores a big chunk of html text, which I have to search for and replace some strings. How can I write a query that makes use of regular expressions to do the following: Below is a block of example text ====================================================================== " src="http://aaaa/bbbb/cccc.nsf/blind%2010x10.gif?OpenImageResource" width=10> <img height=10 alt="" src="http://aaaa/bbbb/cccc.nsf/blind%2010x10.gif?OpenImageResource" width=10><img height=11 alt="" http://aaaa/bbbb/cccc.nsf/blablablabla?OpenDocument src="http://aaaa/bbbb/cccc.ns http://aaaa/bbbb/cccc.nsf/d8d4f0dfa09ba71142256cc50040ee51/ee9b4493dac727be422571c30027df61? OpenDocument" target=_self> ====================================================================== Now I want to search and replace the string that is highlighted in red with something like "FOUND" The below string is what I want to search for - I will used PATINDEX on the string below to find the start index of the string in the body, and then I will add on 114 to the when doing a replace: '%http://aaaa/bbbb/cccc.nsf/%some guid%/%some guid%?OpenDocument%' For example REPLACE ( TheField, SUBSTRING ( TheField, PATINDEX(''%http://aaaa/bbbb/cccc.nsf/%some guid%/%some guid%?OpenDocument%', TheField), ,114 ) , 'FOUND' ) QUESTION: what would the regular expression be and how does one type it in the query? I tried something like the below but it does not work, please advise ..... [a-z][0-9]{32} %/% [a-z][0-9]{32}
View Replies !
Using Regular Expression In Conditional Split?
I have as csv-file wich I import into an SQL Server table. Now I want to do some checks on it. I use a conditional split to direct data to the other tables (1 table for the correct data, 1 table for the rejected data). Is it possible to use a regular expression in a case in a conditional split to check if a columns has the right format? If yes? How do I do that? If no? What is the alternative? Thanks!
View Replies !
How To Format A Message With Regular Expression
Hello everyone I'm new with Reporting services, so my problem is that i want to show what filter the user enter exemple : Data between 12/1/2007 and 4/20/2008 I did all that with this statement : = "Briefing between "+ Parameters!FromDate.Value+ " and " +Parameters!ToDate.Value but when i want to dispaly another filter it doesn't show up like this : = "Briefing between "+ Parameters!FromDate.Value+ " and " +Parameters!ToDate.Value IIf( Parameters!Company.Value!="",Parameters!Company.Value,"") I am sorry i have to jump up into Sql reporting service without a good skills on expressions
View Replies !
Formating A Text Field Using Regular Expression
I'm trying to use the following as an expression in the format of a text box. (Reporting Services 2005) =System.Text.RegularExpressions.Regex.Replace(First(Fields!JOB_NBR.Value, "main"), "(w{2})(w{4})(w{1})","$1-$2-$3") however in the edit expression window, I have a red line under the word Replace. The mouse over tells me it is a "unrecognized identifier" Any idea's
View Replies !
Cannot Find The Database File Specified In The Connection String
can anyone help me with this error message Server Error in '/' Application. The SSE Provider did not find the database file specified in the connection string. At the configured trust level (below High trust level), the SSE provider can not automatically create the database file. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Configuration.Provider.ProviderException: The SSE Provider did not find the database file specified in the connection string. At the configured trust level (below High trust level), the SSE provider can not automatically create the database file.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [ProviderException: The SSE Provider did not find the database file specified in the connection string. At the configured trust level (below High trust level), the SSE provider can not automatically create the database file.] System.Web.DataAccess.SqlConnectionHelper.EnsureSqlExpressDBFile(String connectionString) +2546149 System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +87 System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +1121 System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +105 System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved) +42 System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +83 System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +160 System.Web.UI.WebControls.Login.AttemptLogin() +105 System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +99 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102 Version Information: Microsoft .NET Framework Version:2.0.50727.112; ASP.NET Version:2.0.50727.112
View Replies !
Replace Function And Regular Expressions
Is it possible to use the REPLACE function in SQL Server 2000 so thatit returns a string containing only alpha-numeric characters (muchlike using regular expressions)?Thank you in advance for any suggestion.Darren.
View Replies !
Extract Substring From String(Regular Expressions)
Hello forum, I need extract a substring form a string that follows a regular expressions --> T:1º/PQ:1/TALLA:2(MOD.51 100/150) T:<number>º/PQ:<number>... I need to extract only the numbers. The SUBSTRING functions is insuficient for me, because in some cases de number can be 1, 10, 100, 1000, ... I would like me use it as: SELECT RegularExpression (Field) Can you help me, please. Thanks for all in advanced. I will appreciate a lot your help.
View Replies !
How To Get Data From A Excel File To A Sql Database On A Regular Basis
Hello All,i have 2 excel files which i want to upload to sql database. i know how to upload to the folder. my question how to i use these excel files and convert them into tables in sql database.i have to do this on a regular basis. is there anyway i can do this. the 2 files when converted to tables, i need to create relationships etc. any suggestions or references please. i appreciate it. Thanks
View Replies !
Help,a Regular Text File How To Sql 2000 Table Code ?
help,a regular text file how to sql 2000 table code ?i have a text file as follow, line with ¡°|¡±and {LF},8|-000000186075919.|+000000000387820.|2008-03-31|20010423|9|-000000000003919.|-000000000123620.|2008-03-31|20010123|8|-000000018623419.|+000000000381230.|2008-05-30|20010423|i want to sign char(1)£¬year decimal(18,3) , month decimal(18,3), trandatesmalldatetime£¬update smalldatetime£¬after to sql table is as follow,sign year month trandate update8 -186075919.000 387820.000 3/31/2008 4/23/20019 -3919.000 -123620.000 3/31/2008 1/1/20018 -18623419.000 387820.000 5/30/2008 4/23/2001could you help me how write the sql code ?
View Replies !
Expression To Find 0
Hi i'd like to create a expression to find if the first character is 0 and if it is then don't display it, but if the first charactar is not 0 then its ok, am trying to do this within a drived column in SSIS
View Replies !
The SSE Provider Did Not Find The Database File Specified In The Connection String. At The Configured Trust Level (below High Trust Level), The SSE Provider Can Not Automatically Create The Database File.
The problem that I am having is that with Visual Web Developer I am creating a webpage and having it directly put online, so for example when I start a new ASP.NET page, I select the location to be HTTP, with the location http://MYWEBSERVER/Website and for the language and Visual BasicI notice a couple of things, first that there is no longer a a link under the Main toolbar "Website" selection called the ASP.NET configuration. So how can I configure what I want to have users be able to do? It seems that this choice is only available if I am building the ASP.NET page on my "localhost". So that is the first problem. So I am able to get the pages to work, atleast the things such as the textboxes to show up etc, (Even things as advanced as the "Login" box). How ever when I try to get someone to try to login I am taken to a page that has an server error. The error is: "The SSE Provider did not find the database file specified in the connection string. At the configured trust level (below High trust level), the SSE provider can not automatically create the database file. " The Stack Trace Errors are at the bottom. I think this is happening because the automatically generated databases are not getting built online as they are on my computer. On my computer I have MSSQL express. So either the databases are not getting built for some reason, (and I think that is the case as I don't see any in the folder). So I think that somehow I have to create a database on my server, and then somehow configure the ASP.NET file, perhaps in the Web.Config file to look for that new database. Is this the correct methodology? Is there some simpler way that I can just somehow upload things as they are and have them work correctly on my server? The error says that either the Server did not find the database or that the trust level was insufficient. I don't think that is it as I just looked again and I don't see any .MDF files. So how would I go about getting this to work right? Is there a way to do this with MySQL also? So that I don't have to use MSSQL? My server only allows 1 DataBase for that. Thanks and I hope my question makes sense. It is basically how can I get it to be able to create and check users etc. online? Brian [ProviderException: The SSE Provider did not find the database file specified in the connection string. At the configured trust level (below High trust level), the SSE provider can not automatically create the database file.] System.Web.DataAccess.SqlConnectionHelper.EnsureSqlExpressDBFile(String connectionString) +2555237 System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +87 System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +1121 System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +105 System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved) +42 System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +83 System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +160 System.Web.UI.WebControls.Login.AttemptLogin() +105 System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +99 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
View Replies !
Find In String And Return Part Of String
I am trying to find a way to find a certian character in a string and then select everything after that character. for example i would look for the position of the underscore and then need to return everthing after it so in this case yes_no i would return no
View Replies !
Capitalize A Text String/String Function Related
Hi Folks: How can I capitalize a string like 'JOHN DOE' into 'John Doe' with one SQL statement. SQL does provide string function like LOWER(char_expr) which would change the whole text string to 'john doe' and I don't want that. So far, in order to do that, I have to use a front-end development language like 'Omnis' which has a string function 'cap()' to capitalize the whole string, then update the back-end SQL with the new string. Thank you in advance for your time and advice. David Nguyen
View Replies !
Evaluate A String Expression
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 Replies !
Expression In Connection String
Hi, I use expressions in connection strings ..... ="Data Source=" & Parameters!resultServer.Value & ";Initial Catalog=" & Parameters!database.Value Problem is when i change the parameter server, before i am able to change the parameter database, the report errors out. How can i enforce the report server to wait till i am able to give it valid values for both server and database. Thanks.
View Replies !
Attempt FASTLOAD If Error Perform Regular Data Flow Transfer And Redirect Errors To Text File
I'm having problems designing a package to attempt to execute a fast load data transfer but failback to regular speed with error redirection in the event of an error. The way I designed this was to add one data flow task to my package called "DFT FASTLOAD". The data flow copies a table SRC to another table DEST in the same SQL Server database. In the error handler for the data flow task I copied the original data flow task and changed the name to "DFT REGULARLOAD with Error redirection". In this data flow task I did not use fast load and addtionally redirected errors to a text file. In the Data Flow Task "DFT FASTLOAD". I am copying from a varchar source field(with non-date strings) to a datetime destination field to force errors. However the Data Flow Task "DFT REGULARLOAD with Error redirection" never seems to start transferring data from source to destination. The data Flow Task "DFT REGULARLOAD with Error redirection" turns yellow (after the error occurs in "DFT FASTLOAD"), but no data is being transferred). It seems like it hangs. Do I need to increase the MaximumError Count or something? The data flow task "DFT FASTLOAD" does not turn red when the error occurs it just remains yellow, so i assume I'm on the right track since it seems the error is caught. I have added screenshots ... hopefully these screenshots will clarify my problem. DESIGN: http://i256.photobucket.com/albums/hh179/abzbank/DESIGN_FASTLOAD1.jpg http://i256.photobucket.com/albums/hh179/abzbank/DESIGN_FASTLOAD2.jpg http://i256.photobucket.com/albums/hh179/abzbank/DESIGN_FASTLOAD3.jpg http://i256.photobucket.com/albums/hh179/abzbank/DESIGN_FASTLOAD4.jpg http://i256.photobucket.com/albums/hh179/abzbank/DESIGN_FASTLOAD5.jpg http://i256.photobucket.com/albums/hh179/abzbank/DESIGN_FASTLOAD6.jpg RUNTIME: http://i256.photobucket.com/albums/hh179/abzbank/RUN_FASTLOAD7.jpg http://i256.photobucket.com/albums/hh179/abzbank/RUN_FASTLOAD8.jpg http://i256.photobucket.com/albums/hh179/abzbank/RUN_FASTLOAD9.jpg http://i256.photobucket.com/albums/hh179/abzbank/RUN_FASTLOAD10.jpg http://i256.photobucket.com/albums/hh179/abzbank/RUN_FASTLOAD11.jpg I can provide more details if needed... but really this is just a basic test. Any assistance would be appreciated!
View Replies !
Using Cint Function In Expression Editor
Hi, I am a new to Reporting Services... I am using RS2000 I am trying to apply cint function in the expression editor for the textbox eg. i type in =cint(Fields!firstfield.Value/Fields!secondfield.Value). This is returning error The value expression for the textbox €˜HoldDuration€™ contains an error: Arithmetic operation resulted in an overflow. Could you please let me know what I did wrong in this and how to correctly apply VB or any custom functions in the expression editor where the expession output would be a decimal value and you are interested in getting an integer value by rounding the fractional part.
View Replies !
Function With Expression To Return Values
I have created a function to return values, which works fine, but I can't do calculations in it. CREATE FUNCTION [dbo].[tf_Asset_Portfolio](@deal_id int, @as_of_date datetime) RETURNS TABLE AS RETURN ( SELECT DISTINCT dbo.Assets.issue_id, SUM(DISTINCT dbo.Assets.par_amount) AS par_amount, SUM(DISTINCT dbo.Assets.par_amount) AS market_value FROM dbo.Issue INNER JOIN dbo.Assets ON dbo.Issue.issue_id = dbo.Assets.issue_id INNER JOIN dbo.Issuer_Rating_History ON dbo.Issue.issuer_id = dbo.Issuer_Rating_History.issuer_id WHERE (dbo.Issuer_Rating_History.as_of_date <= @as_of_date) GROUP BY ALL dbo.Assets.issue_id, dbo.Assets.deal_id, dbo.Issue.default_date HAVING (dbo.Assets.deal_id = @deal_id) ) I need to do calculations on market value based on the default date. If default date isn't specified then it should be 100% of par amount. If default date is less than one year ago - 65% of the par_amount. If default date is one or more years ago - 0. I have no idea about how to do this and everything I try wont work. I created another function to do the calculations and this seems to work, but it only does one record instead of all of them. CREATE FUNCTION dbo.tf_Asset_Portfolio2 (@deal_id int, @as_of_date datetime) RETURNS @Market TABLE (issue_id int, par_amount money, market_value money) AS BEGIN DECLARE @ReturnDate datetime DECLARE @DD datetime DECLARE @PA money DECLARE @MV money DECLARE @ID int DECLARE @DateD int SELECT TOP 1 @ReturnDate = LAST_BATCH FROM master..sysprocesses WHERE SPId = @@SPID SELECT @ID = issue_id FROM Assets WHERE Assets.deal_id = @deal_id SELECT @PA = SUM(DISTINCT par_amount) FROM Assets WHERE Assets.issue_id = @ID AND Assets.deal_id = @deal_id SELECT @DD = default_date FROM Issue WHERE Issue.issue_id = @ID SET @DateD = DateDiff("yyyy", @DD, @ReturnDate) If @DD = Null BEGIN SET @MV = @PA END Else If @DD > @ReturnDate BEGIN SET @MV = @PA END Else If @DateD < 1 BEGIN SET @MV = @PA * .65 END Else If @DateD >= 1 BEGIN SET @MV = 0 END insert into @Market (issue_id, par_amount, market_value) values (@ID,@PA,@MV) RETURN END I need to combine the functionality of being able to return mutliple records that isn't in the 2nd function and being able to calculate the market value which isn't in the first one. Please help. Thank you in advance.
View Replies !
String Formatting Expression Problem
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 Replies !
String Parsing And Expression Builder....
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 Replies !
Expression In DataSource Conenction String
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 Replies !
Converting A String Expression To Proper Case
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 Replies !
Filters && Expression With String Values, Should They Work??
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 Replies !
Problem With Expression Based Connection String
We're using RS2005 and have a report that we want to be able to dynamically select what database server we use at runtime. For this report we are using private OLE DB datasources to connect to Sybase ASA 9 databases. I have created a parameter for the database server name and modified the datasource connection string ="Provider=ASAProv.90;Data Source=" & Parameters!db.Value This works fine in the IDE but when we publish to the server we get the following error: An error has occurred during report processing. Cannot create a connection to data source 'rpASA_02'. Database server not found I can create expression based connection strings against MSSQL and everything works fine on both the IDE and RS server. Why doesn't this work with OLEDB? Am I doing something wrong or is this an MS bug? tia -bruce
View Replies !
SUM Of Report Field With Expression Which Has COUNT Aggregate Function
Hi everyone, I have created a report which has 3 groups. The report output as shown below. I am having trouble getting the SUM of Total Credtis for each Org. Can't seem to get the total 42 and 16 (highlighted), but can get total unists 11 and 13. I get expression contains aggregate function. This is because Units assessed is the Count of IDs (details hidden from the report). Report has three groups Org , Assessor and Unit. Can someone please help me with this? Appreciate help. Thank you, Ski Org 1(Group1) Unit Credits Units Assessed(# of Trainees) TotalCredits Assessor 1 Unit 1 2 4 (Count of Ids) 8 (2*4) Assessor 2 Unit 2 1 2 2 (1*2) Assessor 3 Unit 3 5 2 10 (5*2) Unit 4 2 1 2 Assessor 4 Unit 5 10 2 20 -------------------------------------------------------------------------------------------------------- 11 42 ----------------------------------------------------------------------------------------------------------- Org 2 Assessor 3 Unit 1 2 3 6 Assessor 4 Unit 6 1 10 10 -------------------------------------------------------------------------------------------------------- 13 16 --------------------------------------------------------------------------------------------------------
View Replies !
Expression Based Connection String && Stored Procedures
I have been looking around on this forum and on other sources on the web about expression based connection strings in rs2005. From my own trials and from what others have reported it seems that you can not use expression based connection strings with stored procedures. Can anyone confirm that rs2005 does not have the ability to do this? Or alternatively has anybody been able to successfully use an expression based connection string with a stored procedure?
View Replies !
Frror: 4000 Max String Literal In Expression For Datareader Component
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 Replies !
Can I Apply A Database Function Or Assembly Call In An Expression For Filter Data?
I need to translate a user€™s regional setting into one of our own language codes before I send it through as a filter to the model query. If our language codes were the same, the filter would look like this in the report filter - Language Code = GetUserCulture() Which translates to this in the database query (for us english) - table.language_code = 'EN-us' And of course I need it to look like this - table.language_code = 'ENG' I would like the logic to be globally available to all report writers (ie not forcing each report writer to have an iif or case stataement). I was thinking custom assemblies or maybe a database function, but at this level of the filter, I cannot seem to figure out how to embed a database function call to apply to the filter criteria like this Language Code = dbo.ConvertFcnIWrote(GetUserCulture()) Or how I would access the custom assembly in the filter expression. Do you have a recommended implementation for this situation? Thanks, Toni Fielder
View Replies !
Sql String Find With &&
I have a visual studio 2005 app that has to match strings to something in a database. It works wonderfully until a string shows up with an & in it (so "this & that") The app wont find anything even though it should, the same query that is made in VS works just fine in enterprise manager I tried a replace on the & with the chr(), hex, and html reference for & and none of those work. We tried using different methods in VS to do the sql statement and commands. The statement surrounds the string with single quotes. If we take the & out, everything works fine. Turned off request valadation just in case. Any ideas?????
View Replies !
Find String
I want to find if a data string is somewhere in a table but i dontknow the table of the database or the field. Who can i searchanywhere?ThanksBrainjk
View Replies !
Find Database Objects That Contain A String
-- This stored procedure will let you search through your database -- to find various objects that contain a particular string. -- For example, you may want to see all tables and views that contain -- a particular column. use master IF (object_id('sp_FindReferences') IS NOT NULL) BEGIN PRINT 'Dropping: sp_FindReferences' DROP procedure sp_FindReferences END PRINT 'Creating: sp_FindReferences' GO CREATE PROCEDURE sp_FindReferences ( @string varchar(1000) = '', @ShowReferences char(1) = 'N' ) AS /****************************************************************************/ /* */ /* TITLE: sp_FindReferences */ /* */ /* DATE: 18 February, 2004 */ /* */ /* AUTHOR: WILLIAM MCEVOY */ /* */ /****************************************************************************/ /* */ /* DESCRIPTION: SEARCH SYSCOMMENTS FOR INPUT STRING, OUTPUT NAME OF OBJECT */ /* */ /****************************************************************************/ set nocount on declare @errnum int , @errors char(1) , @rowcnt int , @output varchar(255) select @errnum = 0 , @errors = 'N' , @rowcnt = 0 , @output = '' /****************************************************************************/ /* INPUT DATA VALIDATION */ /****************************************************************************/ /****************************************************************************/ /* M A I N P R O C E S S I N G */ /****************************************************************************/ -- Create temp table to hold results create table #Results ( Name varchar(55), Type varchar(12), DateCreated datetime, ProcLine varchar(4000) ) IF (@ShowReferences = 'N') BEGIN insert into #Results select distinct 'Name' = convert(varchar(55),SO.name), 'Type' = SO.type, crdate, '' from sysobjects SO join syscomments SC on SC.id = SO.id where SC.text like '%' + @string + '%' union select distinct 'Name' = convert(varchar(55),SO.name), 'Type' = SO.type, crdate, '' from sysobjects SO where SO.name like '%' + @string + '%' union select distinct 'Name' = convert(varchar(55),SO.name), 'Type' = SO.type, crdate, '' from sysobjects SO join syscolumns SC on SC.id = SO.ID where SC.name like '%' + @string + '%' order by 2,1 END ELSE BEGIN insert into #Results select 'Name' = convert(varchar(55),SO.name), 'Type' = SO.type, crdate, 'Proc Line' = text from sysobjects SO join syscomments SC on SC.id = SO.id where SC.text like '%' + @string + '%' union select 'Name' = convert(varchar(55),SO.name), 'Type' = SO.type, crdate, 'Proc Line' = '' from sysobjects SO where SO.name like '%' + @string + '%' union select 'Name' = convert(varchar(55),SO.name), 'Type' = SO.type, crdate, 'Proc Line' = '' from sysobjects SO join syscolumns SC on SC.id = SO.ID where SC.name like '%' + @string + '%' order by 2,1 END IF (@ShowReferences = 'N') BEGIN select Name, 'Type' = Case (Type) when 'P' then 'Procedure' when 'TR' then 'Trigger' when 'X' then 'Xtended Proc' when 'U' then 'Table' when 'C' then 'Check Constraint' when 'D' then 'Default' when 'F' then 'Foreign Key' when 'K' then 'Primary Key' when 'V' then 'View' else Type end, DateCreated from #Results order by 2,1 END ELSE BEGIN select Name, 'Type' = Case (Type) when 'P' then 'Procedure' when 'TR' then 'Trigger' when 'X' then 'Xtended Proc' when 'U' then 'Table' when 'C' then 'Check Constraint' when 'D' then 'Default' when 'F' then 'Foreign Key' when 'K' then 'Primary Key' when 'V' then 'View' else Type end, DateCreated, ProcLine from #Results order by 2,1 END drop table #Results GO IF (object_id('sp_FindReferences') IS NOT NULL) PRINT 'Procedure created.' ELSE PRINT 'Procedure NOT created.' GO
View Replies !
|