Forum Replies Created

Viewing 15 posts - 2,821 through 2,835 (of 2,893 total)

  • RE: Using while loop in select * into a table

    If you can, give this task to DBA.

    DBA can switch server into Bulk-logged or Simple Recovery model (if it's currently set to a Full Recovery ) and then use SELECT...

  • RE: Retrieve Previous Available Date Records

    Thank You for the table & data setup. For the future please use ISO date format as we are not all Americans here 😉

    Now the query for you:

    ;with LastInFlows

    as

    (

    select nf.ClientCode,...

  • RE: Recursion - BOM Report

    Try this:

    DECLARE @ProductId NVARCHAR(30)

    SET @ProductId = 'AZXXX423AA';

    WITH ProductComponents AS

    (

    SELECT

    s.Product,

    s.Component,

    s.Quantity

    FROM Structures AS s

    INNER JOIN Products AS p...

  • RE: Recursion - BOM Report

    It is very easy to write query which returns requied number of records, just add TOP #OfRequiredRecords straight after SELECT keyword 😀

    Seriously, it's not clear from your table structure what...

  • RE: Alter Table

    Let say you have table like:

    CREATE TABLE [dbo].[MyTestTable]

    (

    [RecId] [int] NOT NULL,

    [Val] [nchar](10) NULL,

    CONSTRAINT [PK_MyTestTable] PRIMARY KEY CLUSTERED

    (

    [RecId]...

  • RE: Recursion - BOM Report

    This version of recursive CTE is based on assumption that the Structures.Component is a parent of other parts (products).

    WITH ProductComponents AS

    (

    SELECT

    p.Product,

    p.ProductId AS ParentProductId,

    ...

  • RE: Recursion - BOM Report

    Your script is one huge single line of text!,

    Could you please try to make it a bit more usable.

    Thanks.

  • RE: Ordering Results

    Another version (without sub-select & join):

    select id, location

    from tblTest

    order by

    (case location when 'LIVERPOOL' then 1

    ...

  • RE: Ordering Results

    Try this:

    select id, location

    from tblTest t

    left join (select 1 oid,'LIVERPOOL' o union all select 2, 'SEFTON' union all select 3, 'KNOWLSEY') ot

    on ot.o = t.Location

    order by ISNULL(ot.oid,10),...

  • RE: Selecting data relative to two Date columns

    Using INTs (with same index structure) would reduce number of reads anyway.

    However I agree, the changing legacy system is not a viable option in your case.

  • RE: Quotation

    In SQL2008 you can do this:

    ',ORGANISATION = ' + convert(varchar, cast(@FIELD18 as varbinary ),1)

    In SQL2005 you need to use system function:

    ',ORGANISATION = ' + master.dbo.fn_varbintohexstr(cast(@FIELD18 as varbinary ))

    See, you will...

  • RE: TSQL Programming Book

    I prefer "Three Men in a Boat (To Say Nothing of the Dog)" by Jerome K. Jerome.

    Oops, it is nothign to do with T-SQL, sorry.

    😀

  • RE: Selecting data relative to two Date columns

    john.delahunt (5/26/2010)


    ...I can see how the change of data types would make the comparisons quicker, but I think the real problem is the number of reads being done by the...

  • RE: Index on IDENTITY column

    karthikeyan-444867 (5/26/2010)


    First, what actually makes you say that and why are you "sure"?

    I read like 'Don't create clustered index on monotonically increasing column' some years back.

    ...

    It would be long time...

  • RE: Selecting data relative to two Date columns

    Just to make sure...

    I am not advising to store date in YYYYMMDD format (or other date format) as INT (that would be stupid).

    Try SELECT CAST(GetDate() AS INT)

    You will see...

Viewing 15 posts - 2,821 through 2,835 (of 2,893 total)