Forum Replies Created

Viewing 11 posts - 1 through 11 (of 11 total)

  • RE: SQL - Need to add a flag when certain conditions are met

    One more option (may not be the best but it works).

    create table #temp(Person nvarchar(50),TrnDt date, StartDt date, EndDt date,In_Punch time, Out_Punch time,WkHours int, PayCode nvarchar(50),[XFlag] int)

    insert#temp([Person],[TrnDt],[StartDt],[EndDt],[In_Punch],[Out_Punch],[WkHours],[PayCode])

    SELECT...

  • RE: Linked Server

    You can't create a local SQL Server as a linked server and secondly whichever databases are accessed within DB4 (and if they are not on this server) then you need...

  • RE: delete old backups

    Have you tried Maintenance Plans in SSMS.

    In SSMS

    Connect to server

    Go to Management

    Right Click on Maintenance Plans

    Click Maintenance Plan Wizard

    You can create a maintenance plan and assign a schedule to...

  • RE: Can this be done?

    SSIS is another way

  • RE: Matching the existence of data between like columns

    Consider this idea (if not already considered). It is my experience in dealing with such data:

    In these situations, the data quality plays a major role. First objective is to establish...

  • RE: extend script for dependencies: how?

    Try this

    WITH DepTree (referenced_id, referenced_name, referencing_id, referencing_name, NestLevel, obj_type )

    AS

    (

    SELECT

    o.[object_id] AS referenced_id ,

    o.name AS referenced_name,

    o.[object_id] AS referencing_id,

    o.name AS referencing_name,

    0 AS NestLevel,

    (CAST(o.[type] COLLATE Latin1_General_CI_AS_KS_WS...

  • RE: rounding decimal to nearest integer value

    Try this

    declare @a decimal(10,2), @b-2 decimal(10,2), @C decimal(6,0), @d decimal(6,0)

    select @a = 5.49 , @b-2 = 5.58

    select CAST(@a as...

  • RE: Join 2 reference values in one line ...

    Try this SQL. If you are sure that there always be a city info then replace LEFT with INNER.

    selectord.ID,ord.OrderNumber,src.MarketCenterCity as 'SourceMKT', dst.MarketCenterCity as 'DestMkt'

    fromOrders ord

    LEFT JOIN marketCity src on ord.SrceMktId...

  • RE: Date sequence missing values

    Here is one solution. It solves your problem:

    create table #testdata(MyId int, DailyDt date, MyAmount money)

    create table #timeseries(SeriesDate date)

    declare @startDt date, @EndDt date, @workDt date

    select@startDt = '01/05/2014', @EndDt = '01/10/2015'

    select@workDt =...

  • RE: Snapshot of data, compare previous day

    Try this.

    create function dbo.[F_GetPreviousDayAndAmount] (@ID char(5),@InjectedDate datetime)

    RETURNS [float]

    as

    BEGIN

    declare @YesterdayAmount float ,@PrevDate datetime

    select@PrevDate = max(InjectedDate)

    from[dbo].[Transactions]

    where[ID] = @ID and

    [InjectedDate] < @InjectedDate

    if @PrevDate is NULL

    select@YesterdayAmount = NULL

    else

    begin

    select@YesterdayAmount = [Amount]

    from[dbo].[Transactions]

    where[ID] = @ID and

    [InjectedDate]...

  • RE: Converting getdate

    First you don't have to convert the getdate() in any format. See the following example:

    declare @a date

    select @a = '2012-10-22'

    if @a > GETDATE()

    select 111

    else

    select...

Viewing 11 posts - 1 through 11 (of 11 total)