Forum Replies Created

Viewing 15 posts - 226 through 240 (of 568 total)

  • RE: get data between dates

    kiran_ramisetti (9/24/2009)


    that query need to written based on duedate,

    current date =2009/09/23

    but i have tasks on 21st, 22nd, 25th and 28th of 9th month and 2009

    when i select current date(2009/09/23) then...

  • RE: will SUM (NULL values) give 'N/A'

    create table #N

    (

    id int null

    )

    insert into #N values (null)

    insert into #N values (1)

    insert into #N values (2)

    select

    sum(isnull(id,0))[total sum],

    count(id)[total Valid row],

    count(isnull(id,0))[total row]

    from #n

    select isnull(cast(id as varchar),'N/A')[id] from #n

  • RE: Calculating Profiles of Data

    David-155102 (9/29/2009)


    I can see is that the possible divide by zero is not being handled.

    Handle the divided by zero error for this statement by

    from #Temp

    group by id, item, f_year...

  • RE: Calculating Profiles of Data

    select id, item, f_year,

    sum(case when f_month = 01 then qty else 0 end)/sum(qty)*100 as 'P1',

    ...

  • RE: Exec @SQL not working

    WebTechie38 (9/28/2009)


    I would like the actual rows returned.

    Hi,

    Some of the parameter you declared for the dynamically sql may leave it as null i.e. your not set the value for all...

  • RE: SP with substring

    declare @result varchar(20)

    select @result = 'testdb/sysdb'

    select PATINDEX('%/%',@result)

    select left(@result,PATINDEX('%/%',@result))

    select replace(@result,left(@result,PATINDEX('%/%',@result)),'')

  • RE: sql stored proc does not process input variables correctly

    svenk7 (9/25/2009)


    CREATE procedure [dbo].[prc_de_yn_generic_ced] @field_name varchar(30),

    @table_name varchar(50)

    as

    declare @countint

    declare @d_code varchar(500)

    SET @d_code = (Select dcode from t1 where field_name = @field_name)

    If @table_name = 'tw_STK_Import'

    begin

    set @count = (select...

  • RE: Script 2 SPs and exec one of them against all user databases

    Compile of the SP in different DB from a statement.

    This may be done by using of the dynamic sql statement.

    However show your existing used statement that will help to better...

  • RE: how to group by in tsql

    kabi (9/25/2009)


    Select * from tablename order by schooltname desc,state ,city

    Bit modify the kabi code

    select IDENTITY(int, 1,1) AS [ID],schooltname, state, distict, city into #MYTABLE from MYTABLE

    order by schooltname desc,state ,city

    select...

  • RE: DISTINCT

    Use of the distinct to avoid the same value repeated (duplicate) records in the full rows,

    And try this

    select distinct

    isnull(d.[name],'Unknown')as depot_name

    ,isnull(d.,'Unknown') as depot_code

    , d.[status]

    ,cast(floor(cast(d.[last_date] as float)) as smalldatetime)as last_date

    FROM [dbo].[Depot]...

  • RE: Need help in creating Stored Procedure for searching database

    exec sp_MSforeachdb "select '?' As DatabaseName,name from ?.dbo.sysobjects where name like ('%MYTABLE%')"

  • RE: Performance question and advice??

    The data range error, depends on the type of the date we have stored

    1)Date only.

    2)Date with time.

    For all situations, I preferred the method like

    Select column1

    from myTable

    where date >=...

  • RE: Collation setting for all user databases

    Single DB

    select databasepropertyex('MY_DB', N'collation')

    All DB

    EXEC sp_msForEachDB ' select databasepropertyex(''?'', N''collation'') '

  • RE: converting Columns into Rows

    Dave Ballantyne (9/22/2009)


    Simple enough with a union

    select Job ,Name1_1 ,city1_1 , phone1_1

    from table

    union all

    select Job ,Name1_2 ,city1_2 , phone1_2

    from table

    union all

    select Job ,Name1_3 ,city1_3 , phone1_3

    from table

    union all...

  • RE: Group by help needed

    [Code]

    select a.sort, a.type, max(a.Date), b.Price, a.Name

    from @tbl a

    inner join (select sort, type, max(Price) Price

    from @tbl

    group by sort, type, Name) B

    on a.Sort = b.Sort

    and a.Type = b.type

    and a.Price =...

Viewing 15 posts - 226 through 240 (of 568 total)