Forum Replies Created

Viewing 15 posts - 46 through 60 (of 89 total)

  • RE: Date period from 00:00 to 23:59

    That can work with

    where ((inf.vw_IXP_PSNEW_ADMS_AND_DIS.admdate_dte >= (DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0) -9 ))

    and (inf.vw_IXP_PSNEW_ADMS_AND_DIS.admdate_dte < (DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0) -1 )))

    It will check for the time for >=00:00 and upto <00:00 which mean expect value up-to 23:59

    Regards,

    Mitesh...

  • RE: Nulls and logic

    DECLARE @tbl1 TABLE

    (

    INT IDENTITY(1,1),

    A INT,

    B INT,

    C INT

    )

    DECLARE @tbl2 TABLE

    (

    INT IDENTITY(1,1),

    A INT,

    B INT,

    C INT

    )

    INSERT INTO @tbl1

    SELECT 1,2,NULL

    union all

    SELECT 1,2,3

    INSERT INTO @tbl2

    SELECT 1,2,null

    union all

    SELECT 1,2,4

    update T1

    set

    T1.A = T2.A,

    T1.B...

  • RE: Nulls and logic

    declare @A1 smallint

    declare @A2 smallint

    declare @B1 char(1) --could be null

    declare @b2 char(1) --could be null

    declare @C1 char(1)

    declare @c2 char(1)

    select @A1 = 1

    select @A2 = 1

    select...

  • RE: Query to display the following output

    DECLARE @string VARCHAR(1000)

    SET @string = 'aaa,bbb,ccc'

    DECLARE @tblNumber TABLE

    (

    ID INT

    )

    INSERT INTO @tblNumber

    SELECT TOP 100 ROW_number() OVER(order by s.object_id)

    from sys.objects o,sys.objects s

    select SUBSTRING(@string,id,CHARINDEX(',',@string+',',id)-id) from @tblNumber

    where ID <len(@string)

    AND SUBSTRING(','+@string,id,1)=','

  • RE: Find Last Day of the Month

    SELECT DATEADD(MM,DATEDIFF(MM,-1,getdate()),0)-1

  • RE: RowCount

    DECLARE @tblROWCOUNT TABLE

    (

    "Db name" VARCHAR(1000),

    "Table Name" VARCHAR(400),

    "Row Count" BIGINT

    )

    DECLARE @sql NVARCHAR(MAX)

    SELECT @sql = 'SELECT ''?'' ,o.name, i.rowcnt FROM ?.sys.sysobjects o, ?.sys.sysindexes'

    +' i...

  • RE: Financial Month

    DECLARE @Varmonth CHAR(2)

    SELECT @Varmonth = 04

    select @Varmonth =datediff(mm,'1899/04/01',DATEADD(mm,CAST(@Varmonth AS INT) ,0))%12 +CASE WHEN CAST(@Varmonth AS INT) = 3 THEN 12 ELSE 0 END

    select @Varmonth = REPLICATE('0',2-LEN(@Varmonth))+@Varmonth

    select @Varmonth

  • RE: List Count

    DECLARE @Numbertable table

    (

    ID INT PRIMARY KEY

    )

    INSERT INTO @Numbertable

    select TOP 1000 ROW_NUMBER() OVER(order by si.object_id)

    from sys.objects si,sys.objects s

    declare @mylist nvarchar(100)

    set @mylist = 'A,B, C, D , 1, 2,345, EFG, H,'

    select COUNT(string)

    from

    (

    select...

  • RE: Extend CHARINDEX with occurance matching

    DECLARE @Numbertable table

    (

    ID INT PRIMARY KEY

    )

    INSERT INTO @Numbertable

    select TOP 1000 ROW_NUMBER() OVER(order by si.object_id)

    from sys.objects si,sys.objects s

    DECLARE @separatolog TABLE

    (

    SeparatorLogID INT,

    ID INT IDENTITY(1,1) PRIMARY KEY

    )

    DECLARE @STR varchar(100) = 'ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE'

    DECLARE...

  • RE: Prepend Value to Delimited List

    DECLARE @Numbertable table

    (

    ID INT PRIMARY KEY

    )

    INSERT INTO @Numbertable

    select TOP 1000 ROW_NUMBER() OVER(order by si.object_id)

    from sys.objects si,sys.objects s

    DECLARE @separatolog TABLE

    (

    SeparatorLogID INT,

    ID INT IDENTITY(1,1) PRIMARY KEY

    )

    DECLARE @STR varchar(100) = 'FN,SP,TBL,091.8891'

    DECLARE...

  • RE: Prepend Value to Delimited List

    DECLARE @STR varchar(100) = 'FN,SP,TBL,091.889'

    DECLARE @Separator VARCHAR(10) = ','

    DECLARE @ValueAdd VARCHAR(10) = '80990'

    DECLARE @Action VARCHAR(10) = 'R'--1. P..PostFix 2. R..Prefix

    SELECT @STR =

    STUFF((

    SELECT...

  • RE: Function to get number of days in month

    DECLARE @dtDate DATETIME

    SET @dtDate = '2011/02/28'

    SELECT @dtDate= dateadd(mm,datediff(mm,0,@dtDate),0)

    SELECT datediff(dd,@dtDate,dateadd(mm,1,@dtDate))

  • RE: HOW To write this query?

    DECLARE @Fathers TABLE (FatherId VARCHAR(10), age INT)

    INSERT INTO @Fathers

    SELECT 'Father1', 12

    UNION ALL SELECT 'Father1', 17

    UNION ALL SELECT 'Father2', 22

    UNION...

  • RE: Jst a query......

    Dear,

    You have 6 column in table and you wanna to update 12 ?

  • RE: Jst a query......

    ;with cte as

    (

    select *,ROW_NUMBER() Over(partition by ttest.doctype ,ttest.doco order by ttest.doco) AS Rn from ttest,

    (select t.doctype as Rn1 from ttest t group by t.doctype)a

    )

    select doco,doctype,rn from cte

Viewing 15 posts - 46 through 60 (of 89 total)