logo
Tags down

shadow

Finding MAX() from a serial number field which contains characters in SQL Server


By : madiejd
Date : October 15 2020, 08:10 AM
fixed the issue. Will look into that further Use the following to get the value as Integer CONVERT(INT, SUBSTRING(p_no, CHARINDEX('/', p_no, 0) + 1, 4))
Since you want the Max, you can use MAX(CONVERT(INT, SUBSTRING(p_no, CHARINDEX('/', p_no, 0) + 1, 4)))
code :


Share : facebook icon twitter icon

Finding serial number of USB drive without WMI


By : Sasa Darbka
Date : March 29 2020, 07:55 AM
Hope this helps The following link looks like a good place to start if you can use WMI. Volatile USB Serial Number Using C#.
You could implement a WMI soloution as this looks like it is pretty simple code and has been fairly extensivly tested. If you get a WMI error you could gracefully fall into another implementation using non WMI calls.

Finding all Records where a particular Field has more than "n" number of characters in Oracle


By : user2521450
Date : March 29 2020, 07:55 AM
With these it helps In Oracle, I am about to ALTER the structure of the table where I would be reducing the size of a certain field in a particular table. And, before I run an ALTER command, I would want to know the list of Records where the field has characters is more than the size that I am going to ALTER it to.
code :
select *
from employee
where length(address_1) > 40;

How do I count the number of characters in SQL server ntext (i.e. memo) field in an access query?


By : Siegi
Date : March 29 2020, 07:55 AM
should help you out ntext type doesn't work with LEN. This specific type as well as a few others are deprecated:
code :
ntext, text, and image data types will be removed in a future version of Microsoft SQL 
Server. Avoid using these data types in new development work, and plan to modify applications 
that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead. For more 
information, see Using Large-Value Data Types.

SQL query - Finding if something exists only if a field is a certain number (MS SQL Server 2012)


By : swathi suresh
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I need some help here. , You can use EXISTS:
code :
SELECT t.*
FROM mytable t
WHERE t.a IN (5,10,15,20)
AND (t.a <> 10 OR EXISTS(
    SELECT 1 FROM mytable t2
    WHERE  t.c = t2.b
) )

Finding number of occurrence of characters in a string in SQL Server


By : 龚杰洪
Date : March 29 2020, 07:55 AM
I hope this helps you . Suppose the string is "this is string"
code :
CREATE FUNCTION CountCharacterOccurences(@str nvarchar(max))
RETURNS TABLE
AS
RETURN
    WITH Nums(n) -- Generate numbers from 1 to LEN(@str)
    AS(
        SELECT 1
        UNION ALL
        SELECT n+1
        FROM Nums
        WHERE n+1 <= LEN(@str)
    )
    SELECT 
        SUBSTRING(@str, n, 1) AS char, 
        COUNT(*) AS count
    FROM Nums
    GROUP BY SUBSTRING(@str, n, 1)
DECLARE @str VARCHAR(max)
SET @str = 'this is a string';

SELECT * FROM  CountCharacterOccurences(@str)
char count
    3
a   1
g   1
h   1
i   3
n   1
r   1
s   3
t   2
Related Posts Related Posts :
  • SQL Order By: Specific Value First, then Ordering?
  • SQL Developer - SELECT statement with AVG calculation displaying multiple averages?
  • Microsoft SQL Server : return only the rows with the most recent date for each unique ID
  • How to create a queue like structure in SQL Server
  • Cross apply on columns on SQL server. Syntax error near )
  • Select count of subquery results, along with another field
  • SQL Server 2016 - Five Column to single row
  • Insert zero values for unexisting groups in Redshift
  • SQL LIKE '%...' in vba HTTP request
  • SQL Developer - How do I get MAX & AVG to draw from one column and filter from themselves?
  • How to optimize SQL query with multiple selects
  • Postgresql 11 - Create Procedure to Execute COPY function
  • Oracle VIEW - Convert VARCHAR2 to DATE and find MIN/MAX of DATE
  • In SQL, Main table should match with lookup table for the multiple columns
  • Very slow performance for inner join with restrictive where clause (very small subset of rows)
  • oracle sql 2 columns in one column
  • SQL query to get conflicting values in JSONB from a group
  • Two queries with same tables and join logic but different results
  • How to update a table joined with another table multiple times in Oracle?
  • Crystal Report how can I get data for every 5th of months
  • Getting all distinct values and sorting them by hour
  • Database Compatibility Level
  • Combine WITH statement with UNION
  • Self Nested SQL join
  • My store procedure only executes my first select statement while I wrote three?
  • Inserting Date gives error ORA-01861: literal does not match format string
  • Need to join row data into columns in Oracle
  • Syntax error Missing operator in my case statement
  • Filter the values from the source in merge query in mssql
  • How can i replace/convert number to string
  • Updating a table, on a button press, with selected information
  • Oracle SQL report generation without null
  • SQL get the names of the columns that are stored in a different table
  • Number masking & nls_parameter
  • Delete duplicate roles for SQL server
  • SQL Server: How to change collation of all columns of my select on the fly
  • SQL insert into statement leads to weird (cartesian product) result
  • check constraint sql server
  • Group specific number of rows together and generate a group id
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org