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 TouchToneTommy 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: *

  • Users: davism
  • Content: Threads
  • Order by date
  1. davism

    SQL to select most recent row from current date.

    Hi, I have a table with something like: MemberID[tab][tab]EffDate[tab][tab]TermDate ----------------------------------------------- 1[tab][tab][tab][tab]12/01/2018[tab][tab]12/31/2018 1[tab][tab][tab][tab]4/01/2019[tab][tab]5/31/2019 1[tab][tab][tab][tab]7/01/2019[tab][tab]12/31/2019 I want...
  2. davism

    1 SP on a different DB to used for multiple databases

    We have some database that like span different states. We have code for a stored procedure and that stored procedure resides in a Stage database on the same server so a linked server is not necessary. CREATE PROCEDURE dbo.TestA (@StateID CHAR(2)) AS BEGIN SET NOCOUNT ON UPDATE...
  3. davism

    Index on Temp Table

    Hi, In SQL Server 2008 R2 and up, is it a performance issue if in a stored procedure a temp table is created, then loaded, then an index created on it? Or should it create that a temp table is created, an index created on that temp table and then loaded? Also, if it not true that IF after...
  4. davism

    DDL to files for DB artifacts (Stored Procedures, Views, Triggers, etc) in a SQL Server DB.

    Hi, Is there a way or command to use to get the DDL's to a file for each DB artifact in a SQL Server database? So, for instance, if there are 3 stored procedures in a database: I want the DLL for each stored procedure to go into it's own unique file: stored procedure 1 name is Test1. All...
  5. davism

    SQL SERVER 200 and GROUP BY and HAVING with COUNT

    Hi all, I'm having a little bit of difficult and hopefully somebody can help me out here. I have a table like: GUID, TESTID, TESTDATE, TESTTYPE, TESTTYPEID Now what I want to do is I know there are multiple rows with the same TESTID for the same TESTTYPEID. So, I am trying to get an...
  6. davism

    Global Temporary Table and SQL Server 2000

    I have a question with regard to temporary tables and a usp_Test1 stored procedure (SP). This is related to a SQL Server 2000. (Yes, I know it's older technology but it is what it is.) I'm looking a situation: • On a website, when a User or whomever requests a “Click Here” • The above SP is...
  7. davism

    Split on Comma to use with an IN statement

    Hi all, How can I split information on a comma and put use for an IN statement? For example, I want to exclude certain states. Now, I want to take the variable that is passed in and put it in a temporary table then use the temporary table in a NOT IN (select * from #States) statement. How...
  8. davism

    Limit output to so many rows by like STATE.

    Hi all, What is the best way to limit like the number of users per U.S. state to 5 or less? Let's say that I have a table where I have like: User State --------------- test1 AL test2 AL test3 CO test4 AL test5 CO test6 CO test7 CO test8 AL test10 CO test11 CO...
  9. davism

    NULL AND NOT NULL in SQL WHERE

    Hi all, Is there a way to do something like: DECLARE @TestID varchar(10), @LastName varchar(70), @FirstName varchar(30), @MiddleName varchar(25), @BirthDate datetime, @SSN varchar(9), @Address varchar(100), @State char(2), @Zip varchar(6) SELECT...
  10. davism

    Addition of a Column in the Middle of a Table

    All, Other than logical grouping - what is the value of inserting a column in the middle of a table? For instance: Col1: FirstName Col2: LastName Col3: DOB Col4: SSN If I wanted to add a column for MiddleName, the logical grouping to have the FirstName, MiddleName and LastName would be...
  11. davism

    XML and DB...

    Hi all, I have a question that you may have some information for... What is the best way to take an existing in-depth XML based application that stored the entire XML in a database but also stores each of one the nodes in the the database tables as well. So basically (a very simplistic and...
  12. davism

    Multiple SELECTS in a SP options on splitting that out?

    Hi all, I have a question that I hope that you may be able to assist with. I have a stored procedure and in it over 52 SELECT statements are executed but each SELECT uses the table value in the WHERE clause. for instance: SELECT a.CheckID, a.test1, a.test2, a.test3 from Test1 a where...
  13. davism

    Temporary table and key...

    Hi all, Hopefully somebody can help me with this but basically I have a stored procedure that I'm trying to speed up a little bit. This with SQL Server 2005. Right now, it's running 45 seconds in situation #1. In situation #2, it's running about 44 seconds. Situation #1: 1) Create temporary...
  14. davism

    Select a subquery with a temp table.

    Hi all, I'm not getting this one entirely. I have a script that creates a temporary table and inserts into it from another select. Then I select everything from the temporary table. I have an aggregate function (SUM) included which is why I am selecting from the temp table at the end. I...
  15. davism

    FORCE INDEX USE in a WHERE statement?

    Hi all, I have a question that may be able to be resolve here and greatly appreciate any information. It involves SQL Server 2005. I have a stored procedure that runs ok considering the volume of data that I am dealing with. However, I did a query plan on it and it showed an area that had a...
  16. davism

    INNER JOIN and LEFT JOIN question...

    Hi, This is a little interesting to try and explain... What I am trying to do is run a query... but what I'm finding is that on under some conditions an INNER join on soem tables are necessary. However, on other conditions WHERE the USE of the tables are NOT applicable it will not return...
  17. davism

    Multiple reference SQL?...Need some help...

    Hi, Any help would be greatly appreciated on this. I'm running out of ideas... I will try my best to explain the situation. I have a user that logs in then is USER E. I have a table that has a reference to LOC A and LOC B but like A and B ID's. These LOC's are stored in another table. The...
  18. davism

    Check for differences in multiple databases...

    All, What is the best or recommended approach for check to see if values are present in one or more different database tables? With one key element, I believe anyway and that is there may be some items based on certain criteria that are in both. For instance, I have database TEST with table...
  19. davism

    Difference and additions between 2 database queries...

    All, I have a question that any assistance with on direction would be greatly appreciated. What I have is in one database table I have a list of patients and in another database table I have a list of patients. What I want to do is create a return of a dataset that includes only the unique...
  20. davism

    SQL Server Cursor and timeout - intermittent.

    Hi all, I have a question that maybe someone can provide some information on. I have a stored procedure that has a cursor (loop #1) and that iteration calls another stored procedure and that stored procedure also has a cursor (loop #2). Now, these cursors are NOT used with a large amount of...

Part and Inventory Search

Back
Top