Nth Pattern Position Of The String

Mar 12, 2008



Hi,

How can i find the 2nd comma position of a string, if i have multiple commas in my field. I need SQL Statement

Ex:

F1
Andy,David,Martin,
Sam,Dan,Philip,

I need the position should be

F1 F2
Andy,David,Martin, 11
Sam,Dan,Philip, 8

Thanks,
Mears

View 8 Replies


ADVERTISEMENT

T-SQL (SS2K8) :: Determine Which Pattern Comes First In A String

Aug 20, 2014

DelimitedSplit8k and PatternSplitLoop seem to have potential, but I'm just plain stuck on some things:

1. DelimitedSplit8k: the delimiter split the folder paths, but the pattern can be within the strings that result.
2. PatternSplitLoop: I would have to cross apply 16 times and have an awful WHERE clause to determine which of the four strings matched first.

Unless I'm missing something. Short example is below.

WITH testctes (string, pattern) AS (
SELECT 'oh_look_at_this.thing.hishers_stuffmine.craftyours_protein', 'his first' UNION ALL
SELECT 'i.am.a._thing.hershis_thingsmine.refrigeratoryours_potato', 'hers first' UNION ALL
SELECT 'path_like.things_minehers.some_elsehis_garbageyours_sneakers', 'mine first' UNION ALL
SELECT 'more_stuff.yoursminehershis_falafel', 'yours first'
)
SELECT string, pattern, ca.item, ca.itemnumber
FROM testctes
CROSS APPLY [dbo].[PatternSplitLoop] (string, '%his%') ca

View 9 Replies View Related

How To Get String Value In A Middle Position?

Feb 26, 2007

khosara writes "I have one parameter @String with value "My name is Khosara".
How to get the value only "Is khos".
Could you please help me, witch method shold i use.
Thank in advance."

View 3 Replies View Related

Reporting Services :: Exporting SSRS Reports To PDF With Background Pattern - Pattern Not Visible?

May 8, 2015

I tried creating one simple bar chart report in SSRS, with background fill with pattern "UpwardDiagonal", the stripes on the column when viewed insider report viewer control is quite prominently visible, whereas when exporting the same report to PDF the lines are very thin and dense and hence makes it very difficult to differentiate between one column with pattern inside and one without. I have even tried various other pattern like "LightUpwardDiagonal" and "WideUpwardDiagonal" but all have same result when exported to PDF.why?

View 2 Replies View Related

Finding Position Of Character Within A String

Aug 25, 2000

Hi,
I've got a situation where a table column is composed of decimal numbersthat have to be converted to whole numbers. I want to use CEILING and FLOOR functions to round them up or down, but how do I extract the part after the decimal point to evaluate which operation to apply? I don't think there is a function in sql server that looks for a position of a character within a string. I tried INSTR (the vb function) and that gave me an error msg.

Thanks

View 2 Replies View Related

Last Position Of The Specified Expression In A Character String

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

Finding The Character Position Of Nth Occurence In A String.

Jun 15, 2001

Hi Friends:

I usually run this query in Oracle to find out the position of a character in a string from first position to the nth occurence.

For example, I run the following queries in oracle to get the desire result.

SQL> select instr('DADADAQQQA','A',1,1) FROM DUAL;

INSTR('DADADAQQQA','A',1,1) -- First occurence of 'A' from start.
---------------------------
2

SQL> select instr('DADADAQQQA','A',1,2) FROM DUAL;

INSTR('DADADAQQQA','A',1,2) -- Second occurence of 'A' from start.
---------------------------
4

SQL> select instr('DADADAQQQA','A',1,3) FROM DUAL;

INSTR('DADADAQQQA','A',1,3) -- Third occurence of 'A' from start.
---------------------------
6

SQL> select instr('DADADAQQQA','A',1,4) FROM DUAL;

INSTR('DADADAQQQA','A',1,4) -- Forth occurence of 'A' from start.
---------------------------
10


Is there ay equivelant way in Transact- SQL? If not, can anybody suggest the solution?


--Raj

View 4 Replies View Related

Can Import TXT File By String Start / End Position

May 23, 2012

I'm trying to import a large .txt file into SQL but a regular bulk insert will not do as there are no delimiters. Each line contains roughly 1080 bytes of data that are scrunched together. (1 byte - represents one character) The only thing I know for sure is the start and end position for each column entry which is fixed-format. For example:

col1 (1,3)
col2 (4,6)
col3 (7,7)
col4 (8,30)
col5 (31,39)
...
colN (1050, 1080)

This occurs for X,XXX,XXX rows. So for each row, I want to pull in the column info based on the string position of the data.

How can I do this in SQL? All I have found so far is bulk insert entry...

View 1 Replies View Related

T-SQL (SS2K8) :: Start Position Of Number Value In A String

May 2, 2014

In t-sql 2008 r2, I would like to know how to select a specific string in a varchar(50) field. The field in question is called 'CalendarId'.

This field can contain values like:

xxIN187 13-14 W Elem
HS321 13-14 D Elem
IN636 13-14 C Elem
030 13-14 clark middle.

What I am looking for is the first position that contains a number value for the length of 3. Thus what I want are values that look like the following: 030, 636, 187.What I know that I want is substring(CalendarId,?,3).The question mark is where I want the starting location of a number value (0 to 9) of the value in CalendarId . I tried pathindex but my syntax did not work.

View 6 Replies View Related

Any Function That Returns The Position Of A String In A Column?

Dec 12, 2007

Hello!
Is there a function that gets the name of a column and a string as arguments and returns the position of this string in the column given?

Thank you in advance.

View 1 Replies View Related

SQL Server 2012 :: Query To Find Distinct Multiple Instances Of A Pattern In A String?

Apr 30, 2015

One of my varchar columns in a table has multiple key words enclosed in a pattern of special characters.

Eg: William Shakespeare was an English [##poet##], [##playwright##], and [##actor##], widely regarded as the greatest [##writer##] in the English language and the world's pre-eminent [##dramatist##]. He is often called England's national [##poet##] and the "Bard of Avon". His extant works, including some collaborations, consist of about 38 plays, 154 [##sonnets##], two long narrative [##poems##], and a few other [##verses##], of which the authorship of some is uncertain. His plays have been translated into every major living language and are performed more often than those of any other [##playwright##].

I need to write to query to find all distinct key words that are enclosed within [## and ##]. My query should yield the following results from the string in the example above

[##actor##]
[##dramatist##]
[##playwright##] -- 2 occurrances, but I need it only once in my result set
[##poems##]
[##poet##] -- 2 occurrances, but I need it only once in my result set
[##sonnets##]
[##verses##]
[##writer##]

I need to run this on a large table, so I am looking for the best possible way to minimize any performance issues.

Just give you sample code, I have provided below 2 separate snippets, one with table variable and another with temp table.

DECLARE @MyTable TABLE (MyString VARCHAR (8000))
INSERT @MyTable VALUES ('William Shakespeare was an English [##poet##], [##playwright##], and [##actor##], widely regarded as the greatest [##writer##] in the English language and the world''s pre-eminent [##dramatist##]. He is often called England''s national [##poet##] and the "Bard of Avon". His extant works, including some collaborations, consist of about 38 plays, 154 [##sonnets##], two long narrative [##poems##], and a few other [##verses##], of which the authorship of some is uncertain.

[code].....

View 7 Replies View Related

Pattern Matching - Searching For Numeric Or Alpha Or Alpha-Numeric Characters In A String

Aug 18, 2006

Hi,

I was trying to find numeric characters in a field of nvarchar. I looked this up in HELP.





Wildcard
Meaning



%


Any string of zero or more characters.



_


Any single character.



[ ]


Any single character within the specified range (for example, [a-f]) or set (for example, [abcdef]).






Any single character not within the specified range (for example, [^a - f]) or set (for example, [^abcdef]).

Nowhere in the examples below it in Help was it explicitly detailed that a user could do this.

In MS Access the # can be substituted for any numeric character such that I could do a WHERE clause:

WHERE
Gift_Date NOT LIKE "####*"

After looking at the above for the [ ] wildcard, it became clear that I could subsitute [0-9] for #:

WHERE
Gift_Date NOT LIKE '[0-9][0-9][0-9][0-9]%'

using single quotes and the % wildcard instead of Access' double quotes and * wildcard.

Just putting this out there for anybody else that is new to SQL, like me.

Regards,

Patrick Briggs,
Pasadena, CA






View 1 Replies View Related

SQL Pattern Matching

Mar 20, 2008

Hi everyone. I'm developing a web search engine using asp and SQL Server 2000. I need to return records that matches with a string entered by users. In example, suppose my database to have this structure and it's filled like this:

ID NAME KEYWORDS
--- ------- -----------
AA025 NAME1 attached, atic, common, business, hotels
AA026 NAME2 headache, medicin, aspirins, heat, health
AA027 NAME3 at, services, music, electronics

suppose that user enters 'at'. By now, i'm using this pattern '%<input_text>%'. So in this example, pattern would be '%at%'. As i remarked in the fields above, the three fields matches, and that's not what i'm looking for. I want that the result of that query be just the last field, with 'AA027' ID.
Thanks in advance guys.
Cheers.

View 14 Replies View Related

70-441 Exam Pattern

Jan 30, 2008



hi can any one help me to get the pattern of 70-441 exam.
i need information total number of question in the exam..
and will there be any simulation as 70-431 exam.

View 3 Replies View Related

Design Pattern Question

Sep 15, 2005

Say I have an object that can be created by some users and not others.  And, I have a method something like - function createObject(userId as Integer, objectName as String).  The method calls a stored procedure using the two input arguments as parameters.Now, what I am wondering is this; I am obviously going to check in my SP to ensure that the user has the rights to create the new object before inserting the new record, and there will be an output parameter to send the new record ID back to the method, but do Ia) have a separate output parameter to report on the success of the creation (e.g. @Err Int OUTPUT)b) use the existing output (used to send the new record ID back) and send an error code (e.g. if newRecordId = -9999)c) somehow try to cause a failure of the SP that can be caught in a try/catch blockThanks in advance,Martin

View 1 Replies View Related

Unicode And Pattern Matching

Mar 30, 2015

I've been trying to find and filter out data that can cause FOR XML to fail with the error:FOR XML could not serialize the data for node ?? because it contains a character (0x0006) which is not allowed in XML.I thought it would be simple, just identify the rows that don't match the XML spec URL...

However, the following doesn't work.
select fieldname
from tablename
where fieldname
like N'%[^'+nchar(0x9)+nchar(0xA)+nchar(0xD)+nchar(0x20)+N'-'+nchar(0xD7FF)+N']%'

Not only does this fail to find the offending rows, when I checked by inverted it by taking out the "^" it still returns no rows.When I reduced 0xD7FF down to 0xFF it returns data, but I cannot add the other range back in without all rows not matching.I've experimented with values and found 0x02E9 was the highest I could go without all values vanishing. Even then, numbers lower than that caused a large variation in the number of rows returned.My Field is NVarchar(100) in SQL_Latin1_General_CP1_CI_AS.

View 1 Replies View Related

[Fwd: Reverse Pattern Matching]

Jul 23, 2005

View 2 Replies View Related

Fill Pattern In Columns

Aug 22, 2007



We have a collection of charts, some of which we use the gray scale for the palette (users only have B&W printers). We need to use the same patterns in other charts for consistency. The only option I see in Edit Chart Value-->Appearance-->Series Style-->Fill is Gradient. Is there any way to pick a fill pattern?

The pattern is the diagonal lines slanting down from left to right. It is the third column in the gray scale, so I have tried to add a dummy column as the first column, so that my column would have this pattern. However, the chart allows for space width wise for the first column, so there is a blank space on the chart. I have the Data Output checked to No.

Any other ideas, I would appreciate it!

View 2 Replies View Related

CONTAINS With Variable Search Pattern?

Jun 7, 2007

I have two simple tables:


CREATE TABLE summaries ( summaryId int identity, summary varchar)CREATE TABLE phrasesToSearchFor ( phrase varchar)


I want to do this:

SELECT summaryFROM summariesWHERE CONTAINS(summary, <any of the values in phrasesToSearchFor>)

I've tried every weird permutation of the query I can think of, but can't find a way to make it work. Can anybody help?

Bonus Question:

I've got a function dbo.getPhraseToSearchFor(userId) that returns a phrase depending on the value of userId. I want to get a result table of (userId, summary) where for every user, I use dbo.getPhraseToSearchFor(userId) to figure out what to search the full-text catalog for. The docs say you can use a scalar function anywhere a scalar value is expected, but apparently that doesn't apply in this case -- you can't do CONTAINS(summary, dbo.getPhraseToSearchFor(23))

View 1 Replies View Related

LIKE Pattern Searching Using CONTAINS Or FREETEXT

May 15, 2007

Hi,



We are using FULLTEXT searching for searching the title column in SQL 2005 table.

We are aware that using CONTAINS we cannot search middle of the string like the way we do using LIKE '%text%'.



Is there any alternative way of acheiving this functionality using FULLTEXT search or any other ways of doing this keeping in mind performance.



Any feedback on this is greatly appreciated.



thanks and regards,

Krishna.

View 3 Replies View Related

Transact SQL :: Getting A Sequence Pattern?

Apr 30, 2015

I need a simple tSQL code that will produce an array sequence values that has gap with 2 or more consecutive values, which can vary - so 2 or 3 or 4 between sequence of number.  For example, I want it to return a series with a  gap or space of 2-  So it should return 1, 2, 5, 6, 9, 10.. or a gap of 3 -  1,2 ,6,7,11,12.. etc I  know a single gap is quite simple using a recursive cte, but I haven't been able to find how to get this kind of result.

View 14 Replies View Related

Search For Pattern Within The Text In A Column

Dec 11, 2007

hi
i have a table with a column which contains a large paragraph of data.
i need to search for a pattern within this text and update it.
 
for example  the column contains 4096 char.
within this text, i search for a pattern"qwerty" and convert it to "asdfgh".
any ideas how this can be done?
i'm using sql server 2000
 i have to write something like
UPDATE [DB].[dbo].[Table] SET [Column1] = '.............', WHERE ..........
any help will be appreciated.
 
 

View 4 Replies View Related

Like Pattern Matching - Problem With Param

Mar 19, 2008

I've decalred this stored procedure with a simple where and like statement. The problem is I don't see any result.
Here is my code


create procedure sp_Select_ProfileNames
@NameSearch varchar(50)
as
select ProfileFirstName +' '+ ProfileLastName as ProfileName
from Profiles
where ProfileLastName like '%@NameSearch%';


When i change this line:
where ProfileLastName like '%@NameSearch%';
to
where ProfileLastName like '%Bil%';

I see names starting with Bil, but when i enter Bil as param, I don't get anything.

What's wrong here ?

View 2 Replies View Related

Case Sensitive Pattern Match

Aug 31, 2005

I am trying to do a select statement with SQL 2000 for all recordscontaining any number of lowercase letters. I have tried the following2 statements and they both seem to match both lowercase and uppercaseletters.SELECT * FROM customers WHERE name LIKE '%[a-z]%'SELECT * FROM customers WHERE name LIKE'%[abcdefghijklmnopqrstuvwxyz]%'Can anybody help?

View 4 Replies View Related

Looking For Table Design Pattern For Different Value Types

Jan 3, 2007

Hi,

I need to store a list of parameters in a database. Each parameter has a name, description, comment and a value. Easy so far.

However the values are of different types. Each individual parameter has a value which may be of type int, decimal, string, boolean, custom type etc.

Which table design pattern is most appropriate?
We have a heated in-house discussion and I need supporting arguments.


Options explored so far:

1) (De-)serializing the value to a string-type.
2) Adding a column for each type, using only one column at a time.
3) Adding extra value-tables, one table for each type.
The disadvantages for each option are obvious and the basis for our discussion.

Your help in this matter will be appreciated.
Regards, Tonn

View 5 Replies View Related

Pattern Matching With Multiple Values

Aug 25, 2006

I want to check for multiple patterns in a particular column.
For one pattern I can write e.g.
SELECT * FROM <TablName> WHERE ColumnName LIKE '%abcd%'.


My requirment is to select all rows for which column value matches with many patterns.I will fetch the patterns in a subquery
e.g. (SELECT '%'+name+'%' FROM <TableName>)

Any thoughts?

View 10 Replies View Related

Pattern Extraction Table Value Function

Aug 9, 2007


I need a table value function for extracting strings matching a particular pattern from a long string.

e.g. I have a table called cs_Posts, it has a column called FormattedBody, this value can be something like:




Code Snippet<p>this is the 1st photo <a href="http://jvcwebdev:81/cs/blogs/hllee/DSC00884.JPGhttp://jvcwebdev:81/cs/blogs/hllee/DSC00884.JPG">http://jvcwebdev:81/cs/blogs/hllee/DSC00884.JPG</A< A>>" border="0" alt="" /></a></p>
<p>this is the 2nd photo<a href="http://jvcwebdev:81/cs/blogs/hllee/scene%20photos/DSC00859.JPGhttp://jvcwebdev:81/cs/blogs/hllee/scene%20photos/DSC00859.JPG">http://jvcwebdev:81/cs/blogs/hllee/scene%20photos/DSC00859.JPG</A< A>>" border="0" alt="" /></a></p>





When this long string is input, the table value function should 2 rows:
http://jvcwebdev:81/cs/blogs/hllee/DSC00884.JPG
http://jvcwebdev:81/cs/blogs/hllee/scene%20photos/DSC00859.JPG

Any idea?

View 4 Replies View Related

Pattern Matching Or Find And Replace In SQL Query

Oct 29, 2007

I have a table called MessageBoard.  It has a column called Messages.
A user can type text including any html tags through a text area ans when he saves it by clicking a button, the content typed by the user is saved in the MessageBoard Table (in the Messages) column.  So once saved, the html tags are kept intact.  If I have to find and replace certain html tags, what kind of SQL Query I have to write?
For example I want to find all the <pre> </pre> tags and replace it with <p> </p> tags.  How do I do this?

View 6 Replies View Related

How To Pattern Matching For Zero Or Single Character In SQL Select?

Apr 22, 2005

The LIKE keyword in SELECT WHERE can use wildcard



%
Any string of zero or more characters.

_
Any single character.
but how to Pattern Matching for "zero or single character"?

View 10 Replies View Related

T-SQL (SS2K8) :: Isolating A List With Pattern Search

Jul 14, 2014

I'm trying to pull up a report of restored databases from our bug tracking software to audit and see if any of them can be taken down, and having some trouble figuring out how to pull the list of databases out of the entire request text, since they usually come in via email. Some sample data is below with the paltry beginning of a solution that I came up with.

WITH bug (BugID, BugComment) AS (
SELECT 1, 'Hello DB_001000, DB_001000, DB_001000 Blick'
UNION ALL
SELECT 2, 'Hi DB_001000 DB_001000 DB_001000 DB_001000 Flick'
UNION ALL
SELECT 3, 'Urgent DB_001000 DB_001000 Glick'

[Code] ....

View 6 Replies View Related

Pattern Matching And Full-text Search

Aug 30, 2007

I'm not quite sure that this is possible but, I figured that I would check with you experts out there before trying a new approach. I've done quite a bit of research and have not seen anyone quite figure this out yet.

We have a SQL Server 2005 application that stores and indexes documents to the database as an image data type. I'm able to do full-text queries against the documents without any trouble. I begin to run into problems when trying to pattern match social security numbers and drivers licenses stored in a full-text index. I have a user defined function that I call which runs my regular expression that checks for hits of a ssn or license number in the index. I have no problem getting hits when the data sits in a column.

I do need to mention that I have no trouble when searching for a ssn with a fixed value and where I know the ssn (ex: 123-45-6789). I am actually trying to find the existence of the pattern of ###-##-#### (ex: ^d{3}-d{2}-d{4}$) anywhere in the index.
Any help would be very much appreciated.

View 1 Replies View Related

Graph Fill Colour With Hatch Pattern

Jul 16, 2007

i want to apply a hatch pattern to the fill colour on my bar graph and it doesn't work. i select fill colour, then i select hatch colour, i preview and it doesn't show the hatch pattern.



i would use gradient only i use 2 colours the same (hence why i want to differ them in a way other then colour) and they show up the same in the legend - legends don't display gradients

View 1 Replies View Related

Unspecified Error -2147467259 Using Singleton Pattern

Dec 5, 2007

Hello, we've developed an application that runs on AXIM X51, if it is an important to know.

The data layer handles the connection using the singleton pattern, a bit of code of this is:

(....)
Private Shared ceConnection As SqlCeConnection
(....)

Public Shared Function GetConnection() As SqlCeConnection
Try
If (ceConnection Is Nothing) Then
ceConnection = New SqlCeConnection(Me.connectionString)
End If

If (ceConnection.State = ConnectionState.Closed) Then
ceConnection.Open()
End If

Return ceConnection
Catch ex As Exception
Throw ex
End Try
End Function

(....)

So far nothing strange. We started experiencing problems when the end-users get an "Unspecified error" which later debugging it we got the href value inside the exception object is -2147467259 and nothing else. And if that wasn't enough I couldn't replicate the error in my pocket.

The only way I got the same error was removing the SD Card where the db is located at the same time the application was still open.

Does anybody experienced the same problem??? I researched about this kind of errors "when the device is just restored from the suspend mode" but with out luck.


Please, I really appreciate any help with this issue. Any comment will be more than welcome.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved