This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Generating random strings with T-SQL
I need to generate a random string with alpha and numeric characters inside a trigger.
The string must have a length of 15 and uppercase.
Someone have an idea?
This is far from an optimal solution, but it will work as specified:
select char(rand()*26+65)+char(rand()*26+65)+char(rand()*26+65)
+char(rand()*26+65)+char(rand()*26+65)+char(rand()*26+65)
+char(rand()*26+65)+char(rand()*26+65)+char(rand()*26+65)
+char(rand()*26+65)+char(rand()*26+65)+char(rand()*26+65)
+char(rand()*26+65)+char(rand()*26+65)+char(rand()*26+65)
Example output:
WCZOVRCIRELAJUT
generate a GUID and take just the first 15 characters?
Generate a bunch of random numbers and translate to their ASCII values?
Related
This question already has answers here:
Using T-SQL, return nth delimited element from a string
(14 answers)
Split string and take last element
(15 answers)
Closed 2 months ago.
I have a string like this
0011.06.123.7-0
SELECT STRING_SPLIT(NUMBER,'.')
returns
Values
0011
06
123
And now I only and always need the third value, in this case '123'
How do I select this proberly?
I already tried to get the third value with the Rownumber, but that didn't worked out.
This question already has answers here:
How to invert a permutation represented by an array in-place
(3 answers)
Closed 8 months ago.
Let's say I have an array of N elements, each element representing a unique integer between 0 and N-1. Let's say I want to find the index of a given integer, I can loop through the array and return the index when I find the number. Since this is inefficient, I could make a second array, so that for first_array[10] = 55 we'd obtain second_array[55] = 10.
Now let's say that I don't want to create a second array and I want to do the switch in-place. Is there a clever way to do this, clever meaning no extra allocation, no crazy deep recursion and no searching through the whole array N times? Does this kind of operation have a name? I feel like this is a problem that must have already been solved but I can't imagine what it could be called.
Edit: This is a question about an algorithm, the answer, being an algorithm, should work the same regardless of the programming language.
if the question is about javascript, you can simply use indexOf() method.
in your case:
first_array.indexOf(55); // it will return index of **55** in first_array
This question already has answers here:
Reference for a dynamic range
(1 answer)
Row-wise textjoin of dynamic array with lookup
(2 answers)
Closed 1 year ago.
For simplicity, let us consider a number columns that are filled with values generated by the SEQUENCE formula with a variable number of rows (common for all columns).
What I would like to obtain is another column array (with the same variable number of rows) where each row or element of the array is a TEXTJOIN formula of the elements of that row.
The first small issue is that while it is possible to refer to a single array, e.g. A1#, it is not possible to refer to a range of them and do something like A1#:F1#. It is somewhat inconvenient but I could add the individual arrays to the TEXTJOIN formula (A1#,B1#,C1#,D1#,...). [Correction: It is actually possible to do so]
The main problem is that I have not found any way to get the corresponding concatenated strings for each of the rows. I do not know if I have not found the way or it is simply not possible. A VBA alternative would not be ideal but could be considered as well.
This question already has answers here:
Find number deleted from array
(2 answers)
Closed 5 years ago.
I have two arrays a and b. a always has one element more than b, and the arrays are mixed.
a = [1,5,7,2,4]
b = [2,4,7,1]
I want to find the extra element in a. The output should be 5.
What is the best approach in ruby? Is it good idea to use loop?
I think this is the best built-in function to get what you expect
(a - b).pop
This question already has answers here:
Combine two Arrays into Hash
(8 answers)
Closed 6 years ago.
If i have two arrays containing about 20 separate values is it possible to combine the two into a hash? With the contents of one array acting as the keys and the other as the values?
Sure, very simple
Hash[[1,2,3,4].zip([5,6,7,8])]
=> {1=>5, 2=>6, 3=>7, 4=>8}
But it might be a problem if the arrays have not the same size.