Forum Replies Created

Viewing 15 posts - 5,371 through 5,385 (of 6,036 total)

  • RE: value of select column as an argument in a function

    You can do it only with scalar functions.

    select dbo.MyFunction(Col1) as Col1Mod, Col2,...

    FROM ...

  • RE: Limiting SQL return

    FORGET ABOUT "TOP"!!!

    Select Identity (int, 1, 1), <key columns>

    INTO #TempTable

    FROM SomeTable

    ORDER BY <desired order>

    SELECT T.*

    FROM SomeTable T

    INNER JOIN TempTable TT ON T.<key columns> = TT.<key columns>

    WHERE TT.ID between @StartRow and...

  • RE: Replacing Cursor with UDF slower...

    Because your "set based approach" is actully a hidden cursor.

  • RE: Help with Update Query

    Yes, of course,

    but idea is you don't need to mention the same table twice:

    UPDATE OrdMain

    SET

    ListTotal = SUM_Each

    FROM (select OrderId , SUM(ListEach) SUM_Each

    from OrdItem

    group by OrderId ) DT

    WHERE DT.Order_ID =...

  • RE: Help with Update Query

    Everythin is much simpler:

    UPDATE OrdMain

    SET

    ListTotal = SUM(ListEach)

    FROM OrdItem

    WHERE OrdItem.Order_ID = OrdMain.Order_ID

    AND (OrdMain.Order_Num = N'11589');

  • RE: Second FROM in T-SQL DELETE

    Try to avoid "optional" things.

    They may not work on every server.

    delete dm

    from table2

    inner join longname defs on defs.defid = table2.defid

    inner join table1 dm on dm.id = defs.id

    WHERE table2.col1 ='whatever'

  • RE: Store Procedure Performance Question

    Seems it's data type mismatch.

    What is the datatype of ColumnB?

    The statement

    Set @var3 = @var1 + 2

    will implicitely convert @var1 from nvarchar to int and than convert int result to...

  • RE: Incremental counts are off -

    I don't know where to start.

    Everything is wrong. Really.

    For the beginning, LogPingResponse must be a view, not a table.

    Select dbo.DateOnly(RingTime) as pingDate,

    -- dbo.DateOnly is a UDF returning only date...

  • RE: Incremental counts are off -

    Everything here is wrong: from initial design to the way SP is written.

    If this the the way your system is developed you better hire SQL developer, otherwise you will never...

  • RE: Don''''t blame SQL please....

    There are many solutions.

    One of them:

    Build a table UDF with parameter @DBName.

    Another one:

    Use dynamic query to BUILD A VIEW addressing your databases.

  • RE: multi table insert statement

    Actually if you look on my trigger you'll realize IT IS "2 INSERT statements in a transaction", exactly as David suggested.

    Don't be afraid of triggers. They are really helpful for...

  • RE: multi table insert statement

    Use lookup for retrieving necessary ID.

    CREATE View ...

    AS

    SELECT Name_A, Name_B

    FROM TableA

    Inner Join TableB on TableA.B_ID = TableB.ID

    GO

    CREATE Trigger .....

    ON <View Name>

    INSTEAD OF INSERT

    AS

  • RE: replacing all code problem

    I'm not sure what's easier: parse such queries or build a new, properly designed, database.

  • RE: Saving Query results as CSV file in SQL Server 2005

    Try to open the file with Notepad.

    Probably you'll see why Excell does not see commas in it.

  • RE: To Stage Or Not To Stage

    Staging is nice and clean while you have SINGLE process to import data.

    But when you have a situation with many processes are importing data simultenuosly and sometimes it's probably repeating...

Viewing 15 posts - 5,371 through 5,385 (of 6,036 total)