Forum Replies Created

Viewing 15 posts - 196 through 210 (of 568 total)

  • RE: Making SP more better

    karthimca07 (10/31/2009)


    for example if 10 items purchased i looped it and SP called for 10 times.

    Hi,

    Unless see your code, it’s hard to advice!, Post your...

  • RE: selecting only 1 row among date columns

    sql2000-915039 (10/30/2009)


    I need t-sql to display only those rows with the most recent date.

    select name,max(date),max(col1)...

    from MYTABLE

    GROUP BY name

  • RE: SQL Join Query Needed

    Hi,

    Along with Gianluca nice approaches also try this

    Use Gianluca sample data

    select a.SalesCode,

    a.SalesRep,

    max(a.Dept) [From],

    max(b.Dept) [TO],

    min(a.JoinDt),

    max(b.JoinDt)TransferDt

    from @Transfers a ,

    @Transfers b

    where a.TransferDt is not null

    and a.SalesCode = b.SalesCode

    and a.SalesRep = a.SalesRep

    and...

  • RE: Min of row values instead of particular column value

    Hi,

    Assumption of min value among the columns in the each row

    try this

    declare @A123 table

    (

    ID int,

    col1 int,

    col2 int,

    col3 int

    )

    insert into @A123

    SELECT 1, 1, 2, 3

    UNION

    SELECT 2, 6,...

  • RE: How to Get a ResultSet Count

    GilaMonster (10/26/2009)


    @@RowCount returns the row count of the last statement to be executed. The last statement that ran before you captured the rowcount was SET NOCOUNT OFF. That will obviously...

  • RE: How to Get a ResultSet Count

    Hi Gail,

    Thanks, but the results vary by set nocount on/off

    CREATE PROCEDURE TestRowCount AS

    begin

    SELECT * FROm sysobjects

    end

    GO

    EXEC TestRowCount

    SELECT @@RowCount

    RESULT

    some rows and

    row count = 2170

    alter PROCEDURE...

  • RE: How to Get a ResultSet Count

    Hi,

    The same method mentioned by bit bucket

    Exec Get_Name 'Usa'

    Select @@rowcount

    Ensure that, your procedure should not having/use of SET NOCOUNT ON/OFF.

  • RE: Stored procedure for Financial Year Insert

    manikandan-1115962 (10/24/2009)


    yes i need to raise error of date range exceeds more than 1 year from start date

    01)

    declare @stdate datetime,@todate datetime

    set @stdate = '2009-01-10'

    set @todate = '2009-10-10'

    if datediff(year,@stdate,@todate)<= 1

    begin

    insert mytable

    ....

    ....

    end

    else

    begin

    print'DATE...

  • RE: Stored procedure for Financial Year Insert

    manikandan-1115962 (10/24/2009)


    My Parameters will be Start Date And End Date Only...

    End Date should not greater than 1 year from start date..

    Ex.. Start date: 01.04.2009

    End...

  • RE: Commit update

    Krasavita (10/22/2009)


    How can I right code that I want every 100 records to commit?

    Try this

    set rowcount 100

    begin tran

    update MYTABLE

    set COL1 = 'COL1'

    where COL1 = 'COL2'

    after found no error then commit...

  • RE: Problem with Drop & reccreate a staging table

    999baz (10/20/2009)


    IF EXISTS (SELECT * from sysobjects

    WHERE id = object_id(N'[ANZ].[dbo].[TableStage] ') AND

    --type in (N'U'))

    OBJECTPROPERTY(id, N'IsUserTable') = 1)

    ...

  • RE: How to copy datas into temp tables?

    select col1,col2,col3 into #TableB

    from TableA

    group by col1,col2,col3

    having count(*)> 1

    select * from #TableB

    now the #TableB table having the duplicate data of the TableA

  • RE: find whether this string is a substring of another row

    Try this

    create table #temp

    (

    keys int,

    users varchar(10),

    addr varchar(50),

    report varchar(50)

    )

    insert into #temp

    select 1,'abc','add-1','rep-01'

    union all

    select 2,'abc','add-1','rep-01 rep-02'

    union all

    select 3,'bcd','add-2','rep-01'

    union all

    select 4,'bcd','add-2','rep-02'

    union all

    select 5,'cde','add-2','rep-01'

    union all

    select 6,'cde','add-2','rep-02'

    select users,addr,report,

    replace(report,'rep-01','') trims,

    (case when ((replace(report,'rep-01',''))='') or ((replace(report,'rep-01','')) = report)...

  • RE: Problem using a Searched Case statement

    In the BOL the definition for the case statement

    Simple CASE function:

    CASE input_expression

    WHEN when_expression THEN result_expression

    [ ...n...

  • RE: Sum(A) by B but use the first row for C?

    Hi mark,

    The sample data may be like this

    create table #temp

    (

    uid1 varchar(5),

    col1 int,

    col2 int

    )

    insert into #temp

    select 'A',10,15

    union all

    select 'A',15,25

    union all

    select 'B',25,10

    union all

    select 'B',35,15

    union all

    select 'C',50,25

Viewing 15 posts - 196 through 210 (of 568 total)