Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. SamGarland

    Query "["

    No, the table name is just showed differently in those two places. In SQL Server 2000, properties shows the literal value of the column name, whereas design table shows an escaped version of it.
  2. SamGarland

    Query "["

    You can use one enclosing set of square brackets and each ] that is not part of the enclosing set of square brackets needs to be escaped with a second ]. i.e. SELECT [[Items]].[ItemID]]] FROM MyTable
  3. SamGarland

    Insert and Delete Triggers from only one transaction

    Once an identity value has been used it will not be reused again, so deletions can mean that the numbers in identity columns are not contiguous. If there was an insertion and then the transaction was rolled back the side effects of the insert trigger which are not logged database actions (such...
  4. SamGarland

    ERROR:OBJECT ALREADY IN DATABASE

    Try using this before the SELECT ... INTO statement: if OBJECT_ID('tempdb..#temp1') IS NOT NULL DROP TABLE #temp1
  5. SamGarland

    Audit Query

    Here is an example solution to this type of problem I have made using the Northwind database, you can add additional selection criteria to the subquery as needed: use Northwind select a.* FROM (select TOP 10 PERCENT * from orders) as a JOIN orders b ON b.CustomerID = a.CustomerID ORDER BY...
  6. SamGarland

    Trigger problem

    Try using this code. It will work on a table called MyTable with an identity field called id. It should log the id value along with new values for the columns that have been affected by the update statement that fired the trigger. I had to create a temporary table to duplicate the inserted table...
  7. SamGarland

    sp_linkedservers

    You can make multiple linked server definitions for the same db instance, with different connection information. Then you can just use different linked server names to connect with different logins.
  8. SamGarland

    Triggers & Multiple Inserts

    Just a bit of a clarification (I've been away from a computer for a few days and this has been bugging me). In the case above the IF EXISTS check is probably not neccesary, however the insert trigger fires once for every insert statement that is executed and it is possible that the inserted...
  9. SamGarland

    Triggers & Multiple Inserts

    Right you are. I just thought of that myself.
  10. SamGarland

    Checking what recovery model a DB has

    To find all databases in an instance of SQL Server that have the simple recovery model use: SELECT name FROM sysdatabases WHERE DATABASEPROPERTYEX(name, 'RECOVERY') = 'SIMPLE'
  11. SamGarland

    Triggers & Multiple Inserts

    The problem is that you are using a variable that can only hold a single value. SET @Value = (SELECT REC_PartNo from inserted) will set @Value to the last REC_PartNo retrieved by the SELECT statement. Try something like this: CREATE TRIGGER tr_recipe_insert ON RecipeTable FOR INSERT AS IF...
  12. SamGarland

    (T-SQL)-VIEW Combined tables into one but wrong positions

    OK, I think I understand what you are trying to do now. I think you want to include the contents of the view and the table in one resultset and the QtyAlloc and Total_Pcs_Needed totals are used in the same way. If this is true, rather than doing a FULL OUTER JOIN and adding a whole lot of...
  13. SamGarland

    Insert and Delete Triggers from only one transaction

    The deleted table stores copies of the affected rows during DELETE and UPDATE statements. The inserted table stores copies of the affected rows during INSERT and UPDATE statements. The deleted table is not used during inserts. Try checking the deleted table in your delete and update triggers...
  14. SamGarland

    (T-SQL)-VIEW Combined tables into one but wrong positions

    Aside from the REFNM field the two sets of results differ when Grand_Tot_Pcs is NULL. When you add a non-null integral value to NULL, you will get NULL, so maybe ISNULL should be applied to the result of the addition instead of SUM(CAWB.Total_Pcs_Needed): ISNULL(SUM(CAWB.Total_Pcs_Needed) +...
  15. SamGarland

    Concatenate string in INSERT. Don't know # of records.

    Have a look at http://www.sqlteam.com/item.asp?ItemID=3856 It shows 3 different approaches to this class of problem and the performance of each approach with test data. Try these styles with your own db and see which works best for you. In their case they found that cursor solution was the...
  16. SamGarland

    Simple Select Statement to return data containing Single Quote

    Use two consecutive ' (single quote) characters inside a string (which is itself delimited with single quotes) to denote a literal ' character. For example: use pubs select au_lname from authors where au_lname like '%''%' au_lname...
  17. SamGarland

    Concatenate string in INSERT. Don't know # of records.

    AFAIK you can't mix assignment with data retrieval in the one select statement. How about iterating over the result set of the select with a cursor, and performing a string concatenation and a row insertion each time around the loop? Sam
  18. SamGarland

    Checking object references and permissions in stored procedure

    Hi all. Does anyone know an <<easy>> way to check that at a given point in time, object references in a stored procedure can be resolved and are accessible without actually executing the stored procedure? Sam

Part and Inventory Search

Back
Top