Questions tagged [string]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
34 views

How do you combine the input of three parameters into one?

I'm working on a query that will run via C# to SQL server. I'm trying to make the query flexible and provide parameters for all the inputs. Here is the query: SELECT Test_Matrix.tblTestMatrix....
2
votes
1answer
33 views

Prefix scale for UTL_MATCH.JARO_WINKLER_SIMILARITY

This is a repeat of a previous question from several years ago that did not receive an answer. Oracle has a string matching package, UTL_MATCH, which contains the subprogram JARO_WINKLER_SIMILARITY. ...
1
vote
3answers
56 views

Is there a more concise way in Postgres to extract a portion of a string?

I'm using Postgres 9.5. I have a table with a column that records URLs. Sometimes the URL has a query string and sometimes it does not. I would like to extract the URL, minus any query string, so I ...
3
votes
1answer
143 views

reverse the characters of a string without changing the position of the numeric value in T-SQL

With T-SQL, I'm trying to find the easiest way to reverse the characters of a string without changing the position of the numeric value. So for string: abc223de11 have edc223ba11
0
votes
1answer
23 views

SQL Server 2017 - Extracting source and target column names within a string containing column mappings

I have the following format string stored in text (could be any number of columns): col1_source|col1_target;col2_source|col2_target;col3_source|col3_target;... I'm trying to come up with an ...
0
votes
2answers
37 views

How to chop off X number of characters across multiple records?

Hello all! I have a field that contains geographical locations in the city-state format: Boston, MA Los Angeles, CA Helena, MT ... The field spans for some 230 records. My task is to chop off the ...
1
vote
2answers
108 views

SELECT i.c.w. a COUNT and INNER JOIN gives different results with string literals and numeric values when they are used in a WHERE clause

I have a MySQL query: SELECT p.informationProvider as pGLN, p.productID, p.productStatus FROM tblproducts AS p WHERE -- informationProvider is of type varchar(14) p....
-2
votes
2answers
55 views

How to convert a multi-row result set into a single-row text separated by commas

I'm using this query select Name, valueType from mytable where ID = 1 and getting this table: But I need to covert the result set into something like: 'idGasto int, noTicket string, fechaFact ...
4
votes
2answers
106 views

String comparison without CASE statements?

Is there a shorter more terse way to do a string comparison in SQL Server without wrapping it in a CASE WHEN ... THEN 1 END? In PostgreSQL, I can do SELECT c, c='foo' FROM ( VALUES ('foo'),('bar') ) ...
1
vote
1answer
125 views

Is there any string compaction option for PostgreSQL?

I have a table like this: CREATE TABLE BLOG( CATEGORY CHAR(32) ); Category is a column, which stored enum values. For example, I have 1 millions of rows and 10 unique values of Category. Let'...
6
votes
2answers
4k views

Conditional string concatenation in PostgreSQL

I have a table parcels which currently contains the columns owner_addr1, owner_addr2, owner_addr3. Sometimes, one or both of the latter two fields is empty. I want to combine them into a single new ...
0
votes
1answer
155 views

MariaDB are bitwise operators defined on strings?

Is the behavior of BITAND, (bitwise and) defined in MariaDB over strings? SELECT '0011' & '0011', 'ff' & 'ff', 'yy' & 'YY', '5' & '5'; +-----------------+-------------+-------------+--...
1
vote
1answer
228 views

Does a Levenshtein distance involve some computation for each single row?

Let's say I have, in a SQL DB, a table with 2 columns: id integer, description text and 100,000 rows. The column description has always < 20 characters. If I want to: SELECT * FROM mytable WHERE ...
5
votes
4answers
25k views

Find if any of the rows partially match a string

I want to see if a table contains any sub-string of a given string. Let's say I have a string somedomain.com In database I have: blabladomain.com testdomain.com domain.com I need to make a ...
3
votes
1answer
193 views

Test if a string is a valid, unquoted identifier?

I'm just wondering if there is an established method for testing if a string can be used as an unquoted PostgreSQL identifier? (unquoted because almost any string can be a quoted identifier). I ask ...
0
votes
1answer
35 views

Value of columns inOracle tables

I have many schemas in one oracle databse named SCHEMA1, SCHEMA2...SCHEMA999 I want to find specific value of column named "JN_OSUSER" which is string 'Ed.Spencer' How to find in every table, in ...
0
votes
0answers
28 views

Storing a lot of text / string data strategies - analysis and solution

I have a LOB application backed by SQL Server 2016. Over the past few weeks, theres been issues whereby the SQL Server start throwing timeout errors - which has led to a bit more digging into the ...
13
votes
2answers
751 views

Is there an efficient way to see the cause for “String or binary data would be truncated”?

This is a follow-up on this question. It is also related to this feature request from Microsoft. However, many years have passed and several major releases reached the market since it was reported. ...
4
votes
2answers
1k views

Equivalent to PostgreSQL's Dollar-quoted String Constants for SQL Server

Is there an equivalent of PostgreSQL's Dollar-quoted String Constants, on SQL Server? I would like to enter HTML string literals that would potentially contain single or double quotes in them. ...
5
votes
2answers
1k views

Optimizing a Query for splitting strings with a known size

I have a Column that has a . as a delimiter, it looks like so.... abc.efg.hij I want a query that turns this into three columns, Col1, Col2, and Col3. I am wondering what the fastest way to do this ...
1
vote
2answers
104 views

SQL regex PostgreSQL

Let's consider a table like that: id | name 1 | This is a test sentence 2 | is a sentence TeST 3 | This a IS test sentence 4 | iS a tEst sentence tHis 5 | This a test sentence is How ...
5
votes
1answer
3k views

varchar(MAX) text cuts off while going more than 8000 characters inside a procedure

I have a procedure in which i have declared a variable with datatype varchar(MAX), declare @str varchar(MAX); set @str='select * from Table1...' print (@str); exec (@str); but when the text ...
1
vote
1answer
488 views

How do you unescape “C-like backslash escape sequence” that come from a function?

This will unescape the \n\n sequence. SELECT E'\n\nFOO'; But if that same sequence comes from a function, what do you do. CREATE FUNCTION asdf() RETURNS text AS $$ SELECT '\n\nFOO'::text $$ ...
5
votes
5answers
1k views

PostgreSQL: how can I shorten a multi-word string to few words?

I'm using PostgreSQL 9.5.6. I have space separated multi-word strings that I need to shorten to say 3 words? I've looked at the documentation and in order to use the substring() functions I need to ...
3
votes
2answers
4k views

Is there an easy way in PostgreSQL to escape newlines, carriage returns, and tabs?

Let's say I want to escape these to see a similar string SELECT * FROM ( VALUES (E'\r\n\t FOO BAR \t\n\r') ) AS t(str); How do I get the c-style escapes, \r\n\t FOO BAR \t\n\r back out? SELECT * ...
0
votes
2answers
262 views

DevExpress formats columns differently if they're all numbers

I have a table with a 'Code' column, defined as varchar. However, if you have only numbers in some of the records, for this field, and you search on these records in our application, the results in ...
2
votes
2answers
5k views

How do you count the occurrences of an anchored string using PostgreSQL?

If I have a string in a column on a row in a table like this 1 2 2 2 2 2 2 How would I count the occurrence of a substring 2 inside the string. Assume nothing other than a space-delimiter of " ". ...
3
votes
2answers
2k views

How could i search between two string type date

Consider these two tables. I use persian dates, so I have to declare startdate and enddate as a string(nvarchar(10)). crt table: id title startdate enddate -------------------------- 1 xyz 1395/...
0
votes
1answer
251 views

Return result set as string

I have a table with SELECT fName, lName FROM person It returns 3 results I want to return a concat(fName, ' ', lName) and 2 "and"s in between each concat. Jon Snow and Margaery Tyrell and Peter ...
1
vote
1answer
590 views

Mixture of byte and character semantics in Oracle DB

Are there any issues having a mixture of byte and character semantics in a table? E.g. Location table: location_type varchar2(3 byte) location_name varchar2(50 char) How about a schema having a ...
11
votes
2answers
4k views

SQL Server - NTEXT columns and string manipulation

I have a table with an NTEXT column called comments. I have a second string, let's call it anothercomment (a varchar) that needs placing inside a given comments string after the word UPDATEHERE. ...
1
vote
2answers
2k views

Remove both Special Characters and String Characters from output SQL Server

I am looking to remove some string characters in an output that I have so that it only shows numbers rather then letters and numbers. My Query is: Select DISTINCT t.processed 'Title', (Select max(...
3
votes
2answers
960 views

Remove substring from one column and put it on other column

I have a table like this: CREATE TABLE `mytable` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `column1` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `column2` varchar(255) COLLATE ...
2
votes
2answers
438 views

“Sniff” SQL queries being sent out from my computer

I'm a student working on pulling certain information from an SQL server here at work. I don't have sysadmin privileges and my attempts at receiving them have not been met with success. It's a big ...
1
vote
1answer
35 views

Using a join operation with conditionals

I have two tables that I'm working with in my database. I am using SQL Server 2014. One is 'versions', that contains version_id, version_number, start_date, end_date and server_id. The other is '...
2
votes
3answers
147 views

Extract string in PostgreSQL 9.2

I got the following column: full_path "gorfs"."absolute_pathname" It keeps the path of a BLOB, like on the example below: Note that the 4865 is the account_id.The path is always like: /userfiles/...
0
votes
0answers
28 views

SQLite text columns

When having a table in SQLite that has a TEXT data type, is there any implication if the length of the contained string differ significantly?
1
vote
1answer
579 views

Loop over string literals as input to function PostgreSQL 9.4

I have a function called update_total which looks like this: CREATE OR REPLACE FUNCTION update_total (table_name CHARACTER VARYING, year CHARACTER(4), donor_type CHARACTER VARYING, donor_code ...
1
vote
1answer
385 views

What is the best SSIS Tasks for String Parsing database fields

What is/are the best SSIS Tasks to use in order to search for string patterns. This relates to standardizing address information. My developer does not have a confident grasp on using Regular ...
9
votes
2answers
6k views

Likes or votes for posts

I am making a small program where users makes posts or write blogs. On those posts, other users can like or dislike the post as in facebook or upvote or downvote the post as in stackoverflow. I would ...
2
votes
1answer
38 views

Which databases provide string pooling?

Suppose I have many data objects that include very many share very many identical strings (e.g. tags, URLs, "DEBUG"/"TRACE"/"INFO", etc...). Which databases (if any) pool identical strings ...
2
votes
1answer
2k views

What indexing to be used over string columns(text type) with string length around 3000 characters

I am using open source columnar dbms (postgresql+Cstore). I am trying to speed up the response time of queries. My database has tables with strings mostly. String columns contain huge data (up to ...
7
votes
1answer
7k views

Why do string functions on SQL based database servers start at position 1 instead of 0? [closed]

This has always bothered me. It seems that string functions in SQL based servers always start at position 1 (at least this is the case with MySQL, SQL Server, Oracle and Postgres). For example the ...
1
vote
2answers
559 views

trim is not working for few string

I want to trim dot (.) from a column value. Just say string is "Mr." and I need to trim the dot from the string. I am expecting "Mr" Lets say, I have two fields in my table id | value 1 ...
2
votes
0answers
19k views

List of escape sequences for Postgresql string data types

I'm trying to find the documentation of a complete list of escape sequences for string data types in Postgresql. So for example, if you need to escape a quote character inside of a quoted string, you ...
0
votes
1answer
2k views

MySQL trigger if new value is not equal to varchar

StackExchange, I'm trying to create a trigger in MySQL (before insert) that gives an error if the new value of "sifra" is not S, P, K, A or Z, but it I'm getting an error even if the said criteria is ...
1
vote
2answers
862 views

Split String Function

I have a question regarding this Split String function Aaron Bertrand recommends here. With it you can extract information between two slashes. Now if I want to extract not only one piece of info ...
9
votes
3answers
61k views

Convert string numeric values with comma as decimal separator to NUMERIC(10, 2)

I have an SQL table of varchar columns which contain Greek formatted numbers (. as thousand separator and comma as decimal separator) The classic conversion CONVERT(numeric(10,2),REPLACE([value],',',...
1
vote
1answer
476 views

What's the most efficient way to perform a case insensitive search for a word in a text field?

What is the most efficient way to perform a case insensitive search for a word in a TEXT (or CLOB) field? I've been using WHERE LOWER(body) LIKE '%word%' but I think the calls to LOWER() might be ...
3
votes
2answers
16k views

How to separate name string by the spaces in the name in T-SQL

I have a list of names, such as: Doe John James, Doe Jane and Doe Henry Albert Sr I need to split those out into the four component parts of the name (if the name has four parts) to put each of them ...