Forum Replies Created

Viewing 15 posts - 436 through 450 (of 475 total)

  • RE: SQL Query: Subtract data from consecutive rows uptil non zero value reached.

    This may do what you require?;with origQry as (

    select A.CurrentLine,A.MappingLine,A.SourceLine,

    A.Amount as AmountA,

    B.Amount as AmountB,

    A.RowNumber as RowNbrA, B.RowNumber as RowNbrB,

    (A.Amount-B.Amount) as [Difrence (AmountA - AmountB)]

    from [dbo].[AmountTable] A

    Inner join [dbo].[AmountTable] B

    on B.RowNumber...

  • RE: Importing a Unix file to SQL

    Personally I would use Perl or something like that to pre-format the file before trying to load it.

    eg

    #open files for input and output

    open (IN,"<undelimited.txt") || die ("Failed to open input");

    open...

  • RE: T-SQL Query Help

    Assuming that there are rules for each of the Employee groups

    You create a rule table

    CREATE TABLE [dbo].[EmployeePermsRules] (

    [EmployeeGroup] [varchar](50) NOT NULL,

    [System1] [varchar](1) NULL,

    [System2] [varchar](1) NULL,

    [System3] [varchar](1) NULL

    )

    INSERT [dbo].[EmployeePermsRules] ([EmployeeGroup], [System1],...

  • RE: Creating square box polygon from Geography/Geometry Point

    Hi Darrin

    Try the following

    SELECT geometrycolumn.STBuffer(5000).STEnvelope()

    FROM spatialtable

    This will only work with Geometries not Geographies. I could probably come up with something to do a rough extent on a geography if...

  • RE: Rounding question

    bochambers (11/18/2012)


    I initially thought that this was an issue of the approximate storage of the FLOAT data type such that the 3.65 was actually being stored as 3.649999999... for example...

  • RE: Rounding question

    bitbucket-25253 (11/18/2012)


    Unfortunately the cited reference for the correct answers does NOT or I could not find the "tie breaking rule" in that reference. Any one have better luck ?

    Nope...

  • RE: Avoiding IF/ELSE

    dwain.c (11/15/2012)


    It occurred to me on lookback that this is going to fail if #Companies has more than one column or that column has a data type that is incompatible...

  • RE: Avoiding IF/ELSE

    It's a bit ugly ... but you could do something like

    ;with companyNotNull as (

    SELECT * FROM #Companies WHERE CompanyID = @CompanyID

    ),

    companyNull as (

    Select CompanyID FROM #CompanyGroups WHERE CompanyGroupID = @CompanyGroupID

    )

    SELECT...

  • RE: SQL IO Performance

    This is probably way off base ... but is there something external to the database getting in the way? For example an over enthusiastic virus checker.

  • RE: No record count in PIVOT

    capnhector (11/12/2012)


    nope he handles the leading "," with the initial ISNULL. the OP does not initialize the @columns variable so NULL + ',SOMETHING' is NULL and the ISNULL function...

  • RE: No record count in PIVOT

    michielbijnen (11/12/2012)


    There is a comma! As far as I know the syntax is correct for the columns variable. Or not?

    As an example

    select 'Count IsPrimary', [0], [1]

    from (select isprimary, blockid from...

  • RE: No record count in PIVOT

    Hi

    You may want to check you @columns variable. It could have a comma at the beginning

  • RE: STDistance

    Hi

    The issue here is that you are using Geometry for your points rather than Geography. Geometry treats the uses a flat projection and essentially ignores the SRID information, whereas...

  • RE: how to add a column that contains the max value of the group from another column

    If I've understood your requirements properly the following should do what you require

    create table #test (

    market_name varchar(6),

    market_project varchar(25),

    ovp_amt decimal(10,2),

    dashboard_status_level int,

    project_level int

    )

    insert into #test

    values

    ('AUSTIN', 'AUSTIN-T6-2011-03157', 125.00, 3, null),

    ('AUSTIN', 'AUSTIN-T6-2011-03157', 137.00, 2,...

  • RE: Simple Performance testing questions

    I got similar results to Dwain

    MAXDOP 0 ( 8 cores )

    CrossTab2548

    CrossTab CTE2559

    Pivot7095CrossTabs

    Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob...

Viewing 15 posts - 436 through 450 (of 475 total)