Forum Replies Created

Viewing 9 posts - 16 through 25 (of 25 total)

  • Reply To: Missing numbers in a series

    DECLARE @s varchar(max)='1,2,4,5,7,8,11,12,13,15,17,19,20'

    ;WITH n AS
    (
    SELECT 1 x
    UNION ALL
    SELECT x + 1
    FROM n
    WHERE x < 20
    )
    SELECT x
    FROM n
    WHERE ',' + @s + ',' NOT LIKE '%,' + CAST(x...

    • This reply was modified 1 months, 2 weeks ago by naumon765.
  • Reply To: Missing numbers in a series

    hi hope this helps

    drop table if exists #abc

    create table #abc ( col1 varchar(100) )

    insert into #abc values
    (' 1,2,4,5,7,8,11,12,13,15,17,19,20')

    select * from #abc

    t-sql  solution

    ;WITH x AS

    (

    SELECT v =...

  • Reply To: Pattern match any 3 repeating letters

    hi hope this this helps

    1

  • Reply To: Build hierarchy multi-column table on data in 1 column based on string length

    hi hope this helps

    SAMPLE DATA

    DROP TABLE IF EXISTS dbo.SampleData;

    GO

    CREATE TABLE dbo.SampleData

    (

    Col1 VARCHAR(20)

    );

    GO

    INSERT INTO dbo.SampleData (Col1)

    VALUES

    ('A'),

    ('B'),

    ('A10'),

    ('A20'),

    ('B05'),

    ('A10Q'),

    ('A30P'),

    ('B05X'),

    ('A10QA'),

    ('B05XY'),

    ('A10QA01'),

    ('A10QA02'),

    ('B05XY99'),

    ('C'),

    ('C03'),

    ('C03C'),

    ('C03CA'),

    ('C03CA01'),

    ('D07'),

    ('D07M'),

    ('E99ZZ01');

    GO

     

    T-SQL solution

    SELECT

       Col1,

          CASE WHEN LEN(Col1) >= 1 THEN LEFT(Col1,1) END AS Level1,...

  • Reply To: Extract first numeric value from a string

    hi

    hope this helps

     

    DROP TABLE IF EXISTS SampleData;

    CREATE TABLE SampleData

    (

    col1 VARCHAR(max)

    );

    INSERT INTO SampleData (col1)

    select 'NYSTATIN SUSP 500000 UNIT = 5 ML (1 5 ML CUP)'

    UNION ALL

    Select 'NYSTATIN SUSP 0.75 UNIT =...

  • Reply To: find whether a upper case letter is there in a given string

    hi

    hope this helps

    DROP TABLE IF EXISTS SampleData;

    CREATE TABLE SampleData

    (

    col1 NVARCHAR(max)

    );

    INSERT INTO SampleData (col1)

    select 'Sarat'

    union ALL

    select 'qwerty'

    union ALL

    select 'AS123werTy'

     

    t-sql solution

    select

    col1

    ,case when

    col1 COLLATE Latin1_General_CS_AS <> lower(col1 COLLATE Latin1_General_CS_AS) then...

  • Reply To: Find a string with two dots

    hi hope this helps

    DROP TABLE IF EXISTS SampleData;

    CREATE TABLE SampleData

    (

    col1 NVARCHAR(max)

    );

    INSERT INTO SampleData

    (col1)

    select '10.4.'

    union all

    select '12.1.4'

    union all

    select '13.789'

    union all

    select '90.1'

    t-sql solution

    select * from sampledata where len(col1) - len(replace(col1, '.',...

    • This reply was modified 1 months, 2 weeks ago by naumon765.
    • This reply was modified 1 months, 2 weeks ago by naumon765.
    • This reply was modified 1 months, 2 weeks ago by naumon765.
    • This reply was modified 1 months, 2 weeks ago by naumon765.
  • Reply To: Radius Latitude Longitude

    hi hope this helps

    CREATE TABLE locations (

    id INT PRIMARY KEY IDENTITY(1,1),

    latitude FLOAT NOT NULL,

    longitude FLOAT NOT NULL

    );

    INSERT INTO locations (latitude, longitude)

    VALUES

    (45.123456, -111.123456), -- Center point

    (45.200000, -111.200000), -- Nearby

    (45.500000, -111.500000), --...

    • This reply was modified 2 months ago by naumon765.
    • This reply was modified 2 months ago by naumon765.
    Attachments:
    You must be logged in to view attached files.

Viewing 9 posts - 16 through 25 (of 25 total)