Forum Replies Created

Viewing 15 posts - 5,851 through 5,865 (of 6,036 total)

  • RE: How do I create a custom identity?

    If your client is stupid it does not mean you must follow his stupidity.

    Create standard IDENTITY column and write a function to convert integers into required code. Create computed column...

  • RE: Not round value

    It's recommended to open BOL time to time (press F1)

    C. Use ROUND to truncate

    This example uses two SELECT statements to demonstrate the difference between rounding and truncation. The first statement...

  • RE: there''''s a space on the first letter...

    declare @Andy nvarchar(50)

    select @Andy = 'andy' + char(13) + ' '

    SELECT     charindex(' ', @Andy)

    result: 6

    Gives an idea?

  • RE: ORDER BY Problem

    Add Versions to select:

    INNER JOIN (select StoreId, CompanyId, MAX(Active) as Active, MIN(Version) as Version from Karts group by StoreId, CompanyId) Karts ON Stores.StoreID = Karts.StoreID AND Stores.CompanyID = Karts.CompanyID

    By "wrong table"...

  • RE: ORDER BY Problem

    Seems your status column is placed into wrong table.

    But anyway try to replace

    INNER JOIN Karts ON Stores.StoreID = Karts.StoreID AND Stores.CompanyID = Karts.CompanyID

    with

    INNER JOIN (select distinct StoreId, CompanyId, Active...

  • RE: Update with table from diff database

    Say you have 2 tables in both databases:

    Create table thing (

      Id int IDENTITY(1,1),

      Name nvarchar(50) NOT NULL,

      typeId int NOT NULL)

    Create Table ThingType (

      Id int Identity (1,1),

      Name...

  • RE: ORDER BY Problem

    If Version id itd datatype, use this:

    ORDER BY Karts.Active * Version

    Is version is varchar,

    ORDER BY case when Karts.Active = 1 then Version else '0' end

     

  • RE: SQL Insert

    CREATE VIEW dbo.TransView

    AS

    SELECT T1.Col2 as VC1, T1.Col3 as VC2, T2.Col1 as VC3, T2.Col2 as VC4

    FROM Table1 T1

        INNER JOIN Table2 T2 on T1.Col3 = T2.Col1

    GO

    -- Say Col1 in Table1...

  • RE: SQL Insert

    Create a view on your 2 tables to repeat schema of the table you are going to import data from.

    Create trigger "INSTEAD OF INSERT" on this view.

    Within a trigger you...

  • RE: Function of a Function

    You cannot use function call as a parameter for anither function. It's wrong syntax.

    DECLARE @String varchar(100)

    SELECT @String =dbo.getSOs(121616)

    SELECT * FROM dbo.SplitToInt(@String,';')

  • RE: group by week problem

    (@@Datefirst + DATEPART(WEEKDAY, @AnyDate)  )%7

    is constant for any DATEFIRST set up.

    For Mon it's 2, fot Tue it's 3, etc.

    Use it to get rid of DATEFIRST dependency.

    If you use

    (@@Datefirst...

  • RE: Event within last 2 minutes

    SELECT ...

    FROM MyTable

    WHERE LastUpdated between dateadd(n, -2, GETDATE()) and GETDATE()

     

  • RE: Possible bug in the ORDER BY clause of SQL Server

    Sorry, because you have [Description] in resultset it will always being used for ordering. It was long discussion about year ago about ANSI and implementation of its prescriptions by Microsoft.

    Good...

  • RE: Possible bug in the ORDER BY clause of SQL Server

    Do not specify prefix in ORDER BY clause.

    SELECT          f.[Id],

                    [Description] = CASE

                        WHEN b.[Description] IS NOT NULL THEN b.[Description]

                        ELSE f.[Description]

                    END,

                    [Foo_Description] = f.[Description]

    FROM            [dbo].[Foo] AS f

    LEFT OUTER JOIN...

  • RE: search between tow dates Problem

    midan1, your problem you are playing with varchars where it must be datetime.

    If period from 16:00 to 20:00 is something to be hardcoded?

    I don't think so. So, store it in...

Viewing 15 posts - 5,851 through 5,865 (of 6,036 total)