Forum Replies Created

Viewing 15 posts - 106 through 120 (of 238 total)

  • RE: Error Message

    All the predefined error messages are stored in master.dbo.sysmessagess. You can get error code from @@ERROR, save it in a local variable, then select from that table where error =...

  • RE: removing control characters from text field

    It seems the best way would be to bring the data to the middle tier application, perform text manipulations there and put data back to SQL Server. While this is...

  • RE: Variable name in FROM clause

    IF you have to fit in one statement, here is how:

    DECLARE @current bit

    SET @current = 1 -- or 0

    SELECT ... FROM current_table

    WHERE @current = 1

    UNION

    SELECT ... FROM history_table

    WHERE...

  • RE: Finding current table size

    IF you mean number of records, use

    EXECCUTE sp_spaceused 'table_name'.

    This is the fastest way but not always be exact (it reads the number from sysindexes). Otherwise use

    SELECT COUNT(*) FROM...

  • RE: how to populate a variable with a query result

    Would this answer your request?

    DELETE tblMachineInfo

    WHERE ID_Machine_Info IN

    ( SELECT TOP 5 ID_Machine_Info FROM tblMachineInfo ORDER BY ID_Machine_Info DESC )

  • RE: Slow query with variable in search criteria

    Showplans for these two queries would be different. Check those out and you will get the clue. I think Optimizer is smart enough to see that the second query could...

  • RE: is there "TRANSLATE" function in SQL Server?

    This operation is called pivoting. It is not supported by the current version of SQL Server but you can do it with one SELECT statement, one table scan. Check this...

  • RE: Dynamic WHERE clause problems

    Try something like this. It seems to be working but you need to test for performance if tables are large. The query is not very optimized (IN clause) but allows...

  • RE: Performance measurement/analysis...

    Carl, I think you may want to start with running Windows Performance Monitor and recording counters related to SQL Server activities. You will find those there.

    With the Profiler, try...

  • RE: exists vs join

    notrib, your second query will always delete all rows from the table1 one if there is at least one record in table2. It is probably not what you need. Just...

  • RE: Transaction Statistics

    Of course, there is a tradeoff once you start using the Profiler: it records everything. However you can limit what you record by setting options of the trace. How to...

  • RE: Problem with multiple records

    select adviserId, MIN( SQRT( SQUARE( northing ) + SQUARE( easting ) ) )

    FROM #adviser

    GROUP BY adviserId

  • RE: Transaction Statistics

    I think you can output the Profiler results to a file. Just look at the options in the dialog box.

  • RE: SELECT query problems.

    Because of the IN clause, optimizer cannot use an index on the ID column. If the table is large, it will take awhile to loop through every number in your...

  • RE: What Permissions are required to run Trace

    No, you have to be an sa to run Trace (or Profiler) in the SQL Server 7 and 2000.

Viewing 15 posts - 106 through 120 (of 238 total)