Forum Replies Created

Viewing 15 posts - 49,471 through 49,485 (of 49,571 total)

  • RE: Select any 5 rows in random

    What happensd is that SQL creates a temporary work table in TempDB for the columns returned from the query, plus a new column for the NewID, populates the work table...

  • RE: Hi i need to do a trace of a procedure that is called from another that is encrypted

    You could run profiler and capture the sp:StmtStarting event. That will show you every statement executed inside the stored proc, even if it is encrypted.

    That way, you'll be able...

  • RE: @@Servername, Developer Edition, XP Pro

    Hmmm, I'm running Developer (2000) as a named instance on an XP Pro machine (SP 1) and @@Servername returns the name of the instance.

    Have you tried through query analyser, or...

  • RE: HELP with Triggers [AGAIN]

    'Order by 1' says to order the resultset by the first column in it, in this case, the count(*)

  • RE: dynamic sql problem

    Why do you need a dynamic statement? I assume you're doing this in a stored proc, if not, adjust or whatever...

    I'm also assuming that you know the structure of the...

  • RE: dynamic sql problem

    Don't think that's going to work, since @vtbl is a table type variable. If it was a string would be fine.

  • RE: dynamic sql problem

    It's a scope issue. The variable only exists at the outer level (where it was declared) so when the dynamic SQL executes, the table variable is not visible.

    See BoL under...

  • RE: Simple UPDATE Question

    Almost right

    UPDATE BalanceTable

    Set Vendor = VendorCodeTable.Vendor

    FROM VendorCodeTable

    You can optionally add a where clause after to do joins e.g.

    UPDATE BalanceTable

    Set Vendor = VendorCodeTable.Vendor

    FROM VendorCodeTable

    WHERE BalanceTable.Region=VenderCodeTable.Region

    HTH

  • RE: Second Largest Element

    Actually, come to think of it, it can.

    SELECT MAX(Element) FROM Table WHERE Element NOT IN (SELECT TOP 1 Element FROM table ORDER BY Element DESC)

    Replace TOP 1 with whatever you...

  • RE: Second Largest Element

    Select max(element) AS SecondLargest FROM

    Table WHERE Element!=(SELECT max(element) FROM Table)

    Unfortunatly not adaptable to give the third largest, etc. I'm sure someone around here has a more adaptable solution.

  • RE: max date

    Eeep, sorry.

    Remove all references to id and remove the group by in the inner query. I was thinking of somethng else.

    SELECT actionstatus, actiondatetime FROM tbl INNER JOIN

    (SELECT MAX(actiondatetime) AS...

  • RE: max date

    I assume you have some column that is unique. For the purposes of the eg, I will call that column ID. Also calling the table tbl

    SELECT actionstatus, actiondatetime FROM...

  • RE: multiple instance of SQL Server

    SET ANSI_NULLS ON

    GO

    SET ANSI_WARNINGS ON

    GO

    CREATE PROCEDURE [procTest]

    AS

    SELECT Shift_num

    FROM [bell-sql].CabTS.dbo.Shift

    GO

  • RE: How to write a MS-SQL function that makes nvl() look like isnull()

    Ownership confusion, most likely

    First it should be

    CREATE FUNCTION dbo.nvl(....

    then call it

    select dbo.nvl('123', '321') from my_table

  • RE: How to write a MS-SQL function that makes nvl() look like isnull()

    You could try and make the input and output datatypes sql_variant. It's not overly efficient, and may cause problems with implicit conversion, but should work.

Viewing 15 posts - 49,471 through 49,485 (of 49,571 total)