The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
20 views

Filtering the results of a SELECT query to avoid certain words in the value of a column?

I have a table called videos with a column named title and there is a set of words (around 50 words as of now but the number of words may increase) which is the knowledge base for filtering the ...
3
votes
1answer
50 views

Using an index for both asc and desc on a string column

I know a trick to make order by queries faster when we want to order by asc and desc. For integers store a negated value. So if I store -7,-11,-8,-5,-1,-2 the order by asc will give -11, -8, -7, 5, ...
0
votes
0answers
27 views

Order by Like Value and Count

My Name field values are "Name1 (AB)", "Name2 (AB)", "Name3 (CD)", "Name4 (EF)", etc. Is it possible to count the total "%(AB)" and the total "%(CD)" etc...in one query or will it require a sub query? ...
2
votes
3answers
192 views

Removing a string prefix

I have a string of numbers that I need to trim a portion from using TSQL. The string of numbers will always start with 101 then it will have a set of 0s and a set of random numbers. Example: ...
0
votes
0answers
21 views

Storing IDs of strings instead of strings?

I store every visit of a user to our site. In the table describing users (not visits!) I store his device name, device type (desktop, mobile, tablet), device manufacturer, browser name and version, ...
0
votes
1answer
53 views

MYSQL testing string field contains another altered string field

I have this table : mysql> desc mytab; +------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | ...
0
votes
4answers
4k views

Connect to sql plus from command line using connection string

Let's say I have a Oracle database. I have a username = x, password = y, database = z. Also I know the port = a, SID = b, Hostname = c. So how do I need to connect correctly? I used many options ...
0
votes
1answer
478 views

Split values from field and count them according to another field

I have following MySQL db structure: content ======= id | tags --------- 1 | ,abc,def,ghi, 2 | ,abc,foo, 3 | NULL 4 | ,foo,bar, categories ========== id -- 1 2 categories_to_content ...
0
votes
1answer
275 views

Looping through string, adding all numbers e.g. '123' = 1+2+3, demo with working loop included

This works to output the string 123456 as: 1 2 3 4 5 6 Code: declare @string varchar(20) declare @index int declare @len int declare @char char(1) set @string = '123456' set @index = 1 set @len= ...
0
votes
1answer
1k views

How to convert bytea to text value in postgres?

In my application I insert data in database using C code, since the strings I receive from an untrusted source I have escaped them using PQescapeByteaConn of libpq library. Which is working perfectly ...
1
vote
0answers
122 views

How to use variables in file paths in MySQL statements?

I have now a problem that I have to set paths through variables in queries like load data infile '/my/file/path/to/file.txt' into table database1.table2 fields terminated by '' lines terminated ...
3
votes
1answer
270 views

Splitting different parts of a string

I have an SQL Server database where there is a cell with a delimiter (\) separated string. An example of this string would be: category_path ============= RootCategory\Middle Category\Child ...
1
vote
2answers
166 views

Reason for using hexadecimal in NCHAR()?

I found this in some source code today: SELECT @Error = ERROR_NUMBER (), @ErrorMsg = N'An Error occured while populating the TABLE ' + @DestinationTableName + ...
4
votes
4answers
11k views

T SQL Table Valued Function to Split a Column on commas

I wrote a Table Valued Function in Microsoft SQL Server 2008 to take a comma delimited column in a database to spit out separate rows for each value. Ex: "one,two,three,four" would return a new table ...