Questions tagged [patindex]

151 questions
0
votes
0 answers

T-SQL Select to Check Column For Non-English (Latin1) Characters

The default language on my database is set to SQL_Latin1_General_CP1_CI_AS. I'm looking to return results where the name field contains characters from another language, such as Arabic or Chinese): Albra اابومحمد I've tried the following pieces of…
user4637035
  • 23
  • 1
  • 2
  • 6
0
votes
2 answers

sql query to return results which match a search key but also retrieves records which are alphabetically after the search key

The title is a mouthful but I found it hard to explain. I had a previous web service which allowed a user to enter a search key e.g. 4, and that would return records which started with that search key e.g. 4, 4a, 4b. Now I've been asked to…
user2363025
  • 6,365
  • 19
  • 48
  • 89
0
votes
1 answer

Select first int before characters in string

Adding onto the logic behind this forum responce, how would I select the first int with a specific set of trailing characters in a string? In other words, I would like to extract "15 in" out of "this thing is 15 in long!" I've tried the following…
JCBWS
  • 48
  • 1
  • 2
  • 9
0
votes
1 answer

SQL Script patindex

I think i have some syntax error in my script but can't figure out where. I want to select the Integer that falls between a pair of ( ) begining from the right of a cell? Reason being, there might be another pair of brackets containing…
marilyn
  • 545
  • 3
  • 12
  • 19
0
votes
1 answer

SQL Server Compare data and replaced together

I have two string as below: ***ABCABCABCABCABC*** BBBTTTTTTTTTTTTTTTCCC I want to replace * position only from below string So results could be: BBBABCABCABCABCABCCCC BBBTTTTTTTTTTTTTTTCCC Is there any way to have elegant solution to using SQL…
clear.choi
  • 835
  • 2
  • 6
  • 19
0
votes
2 answers

Determine the position of a special character in the string in PHP

I have to determine the position of a special character in the string for example: E77eF/74/VA on 6 and 9 position (counting from 1) we have '/' so I have to change them to position number -> E77eF6749VA On MSSQL I could use PATINDEX but I need to…
tomipnh
  • 193
  • 3
  • 12
0
votes
2 answers

SQL- select only numbers from column which contains string

I have a table like this (first column contains id adn second column is varchar which contains string (some formulas)) - column_id column_formula 4686 4686 = 4684 - 4685 4687 4687 = ( 4681 / 1.205 / 4684 * 1000 ) 4717 …
omkar patade
  • 1,442
  • 9
  • 34
  • 66
0
votes
2 answers

SQL - Extract a numeric part of a variable length string

Here is an example: [U_TipTon]=118.7->59.35;[U_Haulge]=428.28->214.14 I need to extract just 118.7->59.35 as Tipton, and 428.28->214.14 in another column as U_Haulage. The length of the string is variable as well as the posision os my pattern…
0
votes
4 answers

Find IP addresses in SQL Server

I have over 10 million records that contain an IP address in SQL Server. I need to parse out the addresses into a separate column to further analyze them. I have tried using a PATINDEX which works but only covers one pattern for the IP address. The…
bm11
  • 43
  • 8
0
votes
2 answers

Finding first alphabetic character in a DB2 database field

I'm doing a bit of work which requires me to truncate DB2 character-based fields. Essentially, I need to discard all text which is found at or after the first alphabetic character. e.g. 102048994BLAHBLAHBLAH becomes:- 102048994 In SQL Server, this…
Paul Alan Taylor
  • 10,474
  • 1
  • 26
  • 42
0
votes
1 answer

IQueryable with String.Format and PatIndex

I am facing a issue when i try to used string.format on two db entities A, B and then using SqlFunctions.PatIndex on them IQueryable dataRecords = DbSet M_Data; dataRecords = dataRecords.Where(c =>…
Buzz
  • 6,030
  • 4
  • 33
  • 47
0
votes
0 answers

PATINDEX return wrong value?

Why does PATINDEX('%n%','nguyen') return value 6, not the first occurrence, but PATINDEX('%n%','nathan') return a value of 1, the first occurrence?
0
votes
2 answers

Finding pattern using patindex in SQL

We have zipcode column that has bad data entered by data entry person. Example: If someone doesn't provide a zipcode, data entry person usually enters 00000 or 0000000 (or 00, or 000 or 0). I need to design a query that will look into Zipcode…
NonProgrammer
  • 1,337
  • 2
  • 23
  • 53
0
votes
1 answer

SQL Select with Len - Conversion Failed?

This is my query: SELECT at.AssetTag, dp.Custodian, CASE WHEN PATINDEX('%_%', dp.Custodian) = '0' THEN dp.Custodian ELSE RIGHT(LTRIM(RTRIM(dp.Custodian)),LEN(LTRIM(RTRIM(dp.Custodian)) - PATINDEX('%_%', dp.Custodian))) END AS FirstName, CASE WHEN…
missscripty
  • 529
  • 2
  • 11
  • 30
0
votes
2 answers

extract a string from a stored proc definition

I need to check the library used by several stored procs that extract data from a remote server. I have (with SO help, see SO 21708681) built the below code: DECLARE @tProcs TABLE ( procID int IDENTITY, procObjectID…
Our Man in Bananas
  • 5,809
  • 21
  • 91
  • 148