Forum Replies Created

Viewing 10 posts - 466 through 475 (of 475 total)

  • RE: A quick query puzzle:

    Hi

    Here's another variation that should do the trick. No function this time, just a query

    create table #t1(name varchar (100))

    GO

    INsert into #t1

    select '1234ABC123456XYZ1234567890ADS'

    GO

    INsert into #t1

    select 'cbv736456XYZ543534534545XLS'

    GO

    INsert into #t1

    select 'cbv736456XYZ543534534545XLS2134488'

    GO

    ;with...

  • RE: A quick query puzzle:

    Hi

    You could try the following

    CREATE FUNCTION replace6plusint(@s1 varchar(100)) RETURNS TABLE AS RETURN

    WITH

    firstRun AS (

    SELECT replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(@s1,'0','^'),'1','^'),'2','^'),'3','^'),'4','^'),'5','^'),'6','^'),'7','^'),'8','^'),'9','^'),'^^^^^^','------') a

    UNION ALL

    SELECT replace(a,'-^','--')

    FROM firstRun

    WHERE a like '%-^%'

    ),

    secondRun AS (

    SELECT replace(a,'-','x') b, charindex('^', a) p

    FROM...

  • RE: Consolidate Overlapping Date Periods

    Hi

    I thought that I would try something out of left field with this as a matter of interest. I use Geometry a lot and thought it would be interesting...

  • RE: Restart runningtotal when predetermined value is reached

    You could try the following

    I'm sure that this can be improved though and I don't know if it will scale very well as it is recursive.

    IF OBJECT_ID('TempDB..#table','U') IS NOT NULL

    ...

  • RE: Intresting Question need answer ASAP

    Shame there isn't implicit conversion for money to int in the following

    SELECT -(~$) It would have made a good answer

  • RE: Intresting Question need answer ASAP

    Not the shortest but interesting

    SELECT COUNT(*)

  • RE: Sum with Multi Category and Group By Acc No ?

    Hi

    You could try the following. Of course it will only work for the three TransType_IDs

    SELECT SUM(CASE WHEN TransType_ID = 0 THEN AMOUNT ELSE null END) SumAmount_TransType_ID_0

    , SUM(CASE WHEN TransType_ID...

  • RE: Order by a column keeping the families together

    You could try this

    ;WITH cte AS (

    SELECT a.itemid, a.date

    , 0 level

    , null parentid

    , a.itemid rootid, a.date rootdate

    , CASE WHEN EXISTS(SELECT 1 FROM @tableB k WHERE a.itemid = k.parentid) THEN 1...

  • RE: UNION TWO TABLES WITH ONLY ONE COLUMN IN COMMON

    You could try the following query.

    select f.Path, f.FolderName, f.FolderSize, d.FileName, d.FileSize

    from @Folders f

    left outer join @Files d on f.Path = d.Path

    group by grouping sets ((f.Path, Foldername, FolderSize), (f.path, d.FileName,...

  • RE: How to Make Scalar UDFs Run Faster (SQL Spackle)

    Very interesting article and it will make me think about the way I use functions (and statistics!) from now on.

    I hit a problem with recursion using the InitialCapFaster function

    SELECT b.string...

Viewing 10 posts - 466 through 475 (of 475 total)