Forum Replies Created

Viewing 15 posts - 1,471 through 1,485 (of 1,496 total)

  • RE: shrinking the log file

    Try:

    alter database abcd

    set recovery simple

    use abcd

    go

    dbcc shrinkfile(abcd_log, 200)

    -- if originally in full recovery, reset

    alter database abcd

    set recovery full

    You will need to do a full backup afterwards.

     

  • RE: compared two table with

    Be careful with nulls but try something like:

    select *

    from dbo.Employees E

    where not exists (select *

      from dbo.ModuleLog L

      where L.EmployeeName = E.EmployeeName

       and L.DOB = E.DOB)

    or

    select E.*

    from dbo.Employees E

     left join dbo.ModuleLog L on...

  • RE: Param to pass to Oracle sp_ and sp_ to ret 1 or 0.

    I have never called an Oracle SP from T-SQL but you could try passing @status as an output parameter.

    eg exec DEV..SYSADM.update_procedure @Username,@status OUTPUT

     

  • RE: Id of the last inserted

    No problems - I know the feeling.

    At the time I thought Erland Sommarskog's post succinctly summed up the issues. I just re-posted it as I have found it to be...

  • RE: Id of the last inserted

    The original question was about identities so I answered it.

    I agree that you have to think very carefully before using identity as a Primary Key but quite often one has...

  • RE: Left of a comma

    declare @t table(namestr varchar(50) not null)

    insert @t

    select 'Aardvark, Archie (1)' union all

    select 'Baboon, Bob (2)' union all

    select 'Chimp, Charlie (3)'

    select ltrim(rtrim(left(namestr, commaPos - 1))) as LastName

     ,ltrim(rtrim(substring(namestr, commaPos + 1, bracket1Pos...

  • RE: Id of the last inserted

    Use SCOPE_IDENTITY() after each insert. Something like:

    declare @LastID int

    insert table1(...) select ...

    set @LastID = SCOPE_IDENTITY()

    insert table2(Table1ID, ...) select @LastID, ...

    set @LastID = SCOPE_IDENTITY()

    insert table3(Table2ID, ...) select @LastID, ...

     

     

  • RE: function that returns a date from a string

    Ryan Randall's solution:

    select cast('1 ' + 'February, 2004' as datetime)

     

  • RE: Help in Tuning the Query

    On quickly looking at this, there is no join condition between ASP_MASTER and the other tables. This will produce a cartesian product; not at good idea!

    You could probably optimise this...

  • RE: Date format question

    If possible, try and get at least two example dates and values. Maybe 2006-08-09 = 732503 and 2006-08-08 = 732502

    You should then be able to work out if it is a...

  • RE: How to check if stored procedure is already running?

    I have used application locks for this sort of proc. The idea is similar to using a table except everything is in memory. The outline code is:

    -- start of proc

    exec...

  • RE: Convert Month to Text

    select datename(m, getdate())

  • RE: Select for hours worked during a time period

    Opps...

    select ceiling(sum(datediff(minute, tStartTime, tEndTime))/60.0)

    from ( select case when tStartTime < @reportStart

      then @reportStart

      else tStartTime

      end as tStartTime

      ,case when (tEndTime > @reportEnd OR tEndTime IS NULL) --!!!!!

      then @reportEnd

      else tEndTime

      end as tEndTime

     from @t

     where tEndTime >...

  • RE: Select for hours worked during a time period

    or something like:

    declare @t table

    (

     nPK int not null

     ,nJobID int not null

     ,tStartTime datetime not null

     ,tEndTime datetime null

     ,lJobOpen bit not null -- is the needed if tEndTime is null?

    )

    insert @t

    select 1, 1,...

Viewing 15 posts - 1,471 through 1,485 (of 1,496 total)