Forum Replies Created

Viewing 15 posts - 1 through 15 (of 21 total)

  • RE: Query Help

    If you can use the user defined function, you can try this solution....

    1. Define a function

    -------------------------------------------------

    CREATE FUNCTION dbo.spGetList

    (

    @Empid varchar(10)

    RETURNS varchar(100) AS 

    BEGIN

    declare @list varchar(100)

    set @list=''

    select @list=@list+ ','+ Phno from...

  • RE: A little SQL help, please?

    Try this.....

    insert into table_reports

    select distinct t1.user_id,t2.report_name,t2.descr  from table_reports t1 cross join table_reports t2

    where t1.user_id+t2.report_name not in (select distinct user_id+report_name from table_reports)

  • RE: dynamic sql stored proc

    You can try (this works, if stage is not in sequence)

     

    update tempdata  set end_date=(select start_date from tempdata t2

    where t2.svc_id=tempdata.svc_id and t2.stage=(select min(stage) from tempdata t3 where t3.stage > tempdata.stage)

    )

     

    ---...

  • RE: sp with input parameters

    Try this:

    CREATE Procedure sp_abc 

     (

      @Userid int =0  

    &nbsp

    As set nocount on

    if @userid=0

       Begin   

           Calculate data for all users

       End

    Else

       Begin   

           Calculate...

  • RE: need help with query

    Try this.....

    select t1.Client_Rep ,t1.begin_work,max(t2.end_work) as workend,datediff(hour,max(t2.end_work),t1.begin_work)

     as diff  from tempdata t1

    join tempdata t2 on t1.Client_Rep =t2.Client_Rep 

    where t1.begin_work > t2.end_work

    group by t1.Client_Rep ,t1.begin_work

    having datediff(hour,max(t2.end_work),t1.begin_work) > 1

     

     

     

  • RE: UDF Parameter passing in Query

    You can try this... (if your function returns  "total")

    Select Sum( dbo.TestSharesTable1( b.InvestID, @Count )&nbsp as total

    From App_position b

    Where b.portID = @PortID

  • RE: @ sysmbol in SP paremeter ?

    Try using

    select * from Program where Executable = @Psuedo program

     

     

  • RE: Convert a Group By Row Result into Columns (holy grail...)

    You can use dynamic sql

     

    ---------------------------

     

    DECLARE

    @CHAR       VARCHAR(50),

    @TCHAR  VARCHAR(50),

    @CHARLEN       INT,

    @BEGIN      INT,

    @END        INT,

    @Eventlist varchar(100),

    @eventcount int,

    @SQL VARCHAR(5000),

    @MYSQL VARCHAR(200)

     

     

     

    SET @SQL=''

    set @eventlist=''

     SELECT @EventLIST=@EventLIST+ISNULL(S.eventid,'')+','  FROM

    (SELECT DISTINCT eventid FROM agentevents ) S

    SET @MYSQL='SUM(CASE WHEN eventid...

  • RE: Help with Joining Tables to show record for each Period

    Can you try ....

    select p.perioidID, isnull(amount,0) from

    Period p left outer join transactions t on p.periodid=t.periodid

    It will be more helpful, if you can provide some sample data.

  • RE: Syntax help requested

    Try this....

    declare @traceid int

    exec sp_trace_create @traceid output, 8

  • RE: link

    Thanks much frank.

    Actually I used to program in java and C++.

    Now I'm much into sql server, and Cold Fusion. So just want to refresh my java/c++ skills.

    I'll...

  • RE: select statement w/case statement

    What do u mean by "make this into one record" ? Can u exalain in detail how u want ur output to be?

  • RE: Evaluating a string arithmatic expression

    I assumed that test table has values like this

    testid elapsedtime ...

  • RE: Evaluating a string arithmatic expression

    In which format are u storing the data in Elapsedtime column. Is it exactly the way u mentioned- like h m s?

  • RE: Evaluating a string arithmatic expression

    I think this might help you.

    declare @temp varchar(50),@sql varchar(100)

    set @temp='5h 15m 35s'

    set @sql='select '

    set @sql=@sql + REPLACE(REPLACE(REPLACE(@temp, 'h ', ' * 3600 + '), 'm ', ' * 60 +...

Viewing 15 posts - 1 through 15 (of 21 total)