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 Mike Lewis 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. JohnDuncanTB

    Need help with SQL select within Select Find manager name using a person manager ID number

    If either txtGivenname or txtSurname are NULL, then the result is NULL. Try something like ... Select txtEnterpriseID,txtGivenname, txtSurname, txtCity ,txtManagerEnterpriseID , (Select (IsNull(txtGivenname + ' ','') + IsNull(txtSurname,'')) from VLDAP Where txtEnterpriseID...
  2. JohnDuncanTB

    Importing from Oracle to SQL Server 2012

    As long as there are no IDENTITY columns in the NEW_ tables and the columns are of the same datatype as the Oracle tables, then tt may be as easy as ... INSERT INTO NEW_Table1 SELECT * FROM OracleServer.OracleDatabase.dbo.Table1 You will have to substitute your values for OracleServer and...
  3. JohnDuncanTB

    Design question - adding soft links to tables

    No need for the additional primaryaddkey column. That would mean an update to the acctaddress table isprimary column requires an additional update to the account table. You can accomplish the same thing with a view. CREATE VIEW dbo.acctprimaryaddress AS SELECT a.acctkey, a.acctname...
  4. JohnDuncanTB

    Why is My Query Failing Logically?

    Assuming the date fields are actual datetimes not strings, I suspect the answer lies with BENEF_SEQ_NBR. You are only selecting RECIP_SSN_NBR for the result set but the NOT EXISTS includes BENEF_SEQ_NBR equality criteria. --JD "Behold! As a wild ass in the desert go forth I to my work."
  5. JohnDuncanTB

    isnull not working

    Your IsNull only kicks in when adj.trantype = 3 and adj.adjcat = 'WRITE_OFF'. I suspect the NULL values you are seeing are for rows that do not meet that criteria. You could wrap the whole CASE statement in IsNull. ,IsNull(CASE when adj.trantype = 3 and adj.adjcat = 'WRITE_OFF' then adj.adjamt...
  6. JohnDuncanTB

    Running total by ID#

    This is old school but should still work. SELECT t1.[Date] ,t1.[ID] ,t1.[Billed] ,t1.[Paid] ,(SELECT SUM(t2.[New_Mbr_Med_CS]) FROM #localtemp as t2 WHERE t2.[ID] = t1.[ID] AND t2.[Date] <= t1.[Date]) as 'Ttl_Med_CS' FROM #localtemp As t1 ORDER BY t1.[ID]...
  7. JohnDuncanTB

    Using USE in a Stored Proc

    You can try creating the procedure in the master database and marking it as system object, then you should be able to run it from any user database in the context of that database. Articles: SQL Server Central SQL Team --JD "Behold! As a wild ass in the desert go forth I to my work."
  8. JohnDuncanTB

    Default to Replicate timestamp as binary

    Is there a way to set Replicate timestamp as binary as the default for replication? I am building a data mart/warehouse. I have several source databases that are replicated to my server. I want to use timestamp (now rowversion) columns to determine which rows need updating for a differential...
  9. JohnDuncanTB

    Average Call Times per day

    How does this work for you? SELECT x.StartDate ,cast(s.AvgSecondsPerCall / 3600 as varchar) + ':' + cast((s.AvgSecondsPerCall / 60 - (AvgSecondsPerCall / 3600 ) * 60) as varchar) + ':' + cast((s.AvgSecondsPerCall - (s.AvgSecondsPerCall / 60) * 60) as varchar) ElapsedTime FROM (SELECT...
  10. JohnDuncanTB

    COUNT with Group By producing two similar groups

    I think changing the GROUP BY should do the trick. SELECT CASE LTRIM(RTRIM(CaseType)) WHEN 'Surgical' THEN 'S' WHEN 'Dermatology' THEN 'D' WHEN 'Fluorescence' THEN 'D' WHEN 'Non-GYN Cytology' THEN 'N' END AS Code, COUNT(Accession), ReceivedDate AS DateToProcess FROM...

Part and Inventory Search

Back
Top