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 SkipVought 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. hopper44

    SQL Query to split strings into multiple fields and multiple records

    I have a table defined as follows: CREATE TABLE KT ( AccountNo VARCHAR(20), StockNames VARCHAR(4000) ); 100 "International Business Machines | Conoco Philips | Exxon Inc | American Telegraph and Telephone | McDonalds Inc | JC Penny | Hewlett Packard " 200 "Microsoft Inc | Eastman Kodak |...
  2. hopper44

    How to handle INSERT INTO with varchar Primary Key(PK) column

    Your text file '\\pcnamed\TS_Call_Output.txt' probably has duplicate values for the primary key, hence you are getting the error. View the text file and remove any primary key duplicates.
  3. hopper44

    Update Duplicate Records

    Try something along the following lines: DECLARE @tmptable TABLE (CID VARCHAR(30), ROWNO INT, internal_container_num VARCHAR(30)) INSERT INTO @tmptable select s.container_id, ROW_NUMBER() OVER ( partition by s.container_id order by s.container_id) AS ROW_NUMBER, internal_container_num...
  4. hopper44

    Using Where or And in

    Try this: SELECT n.doc, ISNULL(a.pendinfo1,0) AS pendinfo1, ISNULL(pendinfo2,0) AS pendinfo2 FROM natdocfile n LEFT OUTER JOIN (SELECT t.fo, ISNULL(COUNT(t.cossn), 0)AS pendinfo1 FROM t16pendall t WHERE (mft_POSN1_CD in('b','d') or (MFT_POSN1_CD='a' and aged_alien_rsw='y'))...
  5. hopper44

    Help me to understand the case statements in this query

    When area is less than 10 (i.e. 0-9), then output with a preceding 0. For example, if area = 4, then output '04'. Otherwise, output area as two characters (e.g. if area=25, it will output '25'). This assumes that area will be 0 through 99. If it is greater than two digits, results will be...
  6. hopper44

    pull first record for each

    If you are using SQL Server 2005 or 2008, then you can easily do this by using the RANK function as shown below: SELECT tmp.Account, tmp.Branch FROM (SELECT Account, Branch, RANK() OVER (Partition by Account ORDER BY Branch) as Rank FROM AccountBranch ) tmp WHERE tmp.Rank = 1 Explanation...
  7. hopper44

    Need help building Query

    select t.* FROM TeacherClasses t INNER JOIN ClassHeader c ON t.ClassID = c.ClassID WHERE c.Major = 'Major that I choose'
  8. hopper44

    SQL Datetime again

    It looks like there are some rows in your table that do not conform to the 22/11/2008 00:00:00 format. Hence, the error is generated. To verify if that is the problem, try to put a TOP statement to select, say 2 rows, and verify if that works. For example, select TOP 2 CASE [Column 6]...

Part and Inventory Search

Back
Top