I have to write a statement that answers the question:
"Which pilot is authorized to fly all the aircraft in the fleet?" implying that the individual aircraft could be of any of the three aircraft types.
Below are the tables with notation Tbl_name (important keys [clarification of keys]):
In words my question should be something like:
"For all those who are authorized to fly aircraft (the only pers_id:s listed in the authorization table), show the names of those that have their pers_id:s next to all aircraft_type:s."
I've gotten this far:
Code:
SELECT DISTINCT p.name
FROM personnel AS p, authorization AS b, aircraft_type AS f
WHERE p.pers_id = b.pers_id
AND b.type_designation = ... ;
Now what I want to accomplish is to select the pilot which has a record for ALL type_designation entries in the aircraft_type table.
Is there a magic keyword that I don't know of? Is that magic keyword called "EXIST" and how do I use it?
Hi there;I was trying to apply SQL SP3a on my windows 2000 server (SP4), butthe installation failed and when I rebooted my server the SQL agentfailed to start and I get the following error:SQLAGENT.exe - Entry Point Not Foundthe procedure entry point SFMapi0GetProfiles could not be located inthe dynamic link library SEMMAP.dllNow, I tried replying SQLSP3a, but that keeps on failing and I keepgetting this error message.Any Idea .. Please help me.Thank you.
Hi All!Has anyone has seen this error before?Event Type:InformationEvent Source:Application PopupEvent Category:NoneEvent ID:26Date:5/14/2004Time:10:06:45 AMUser:N/ADescription:Application popup: sqlmangr.exe - Entry Point Not Found : Theprocedure entry point TraceMessage could not be located in the dynamiclink library ADVAPI32.dll.This computer is running MS SQL Server STD Edition 2000 W/ ServicePack 1.Thanks!
I am wanting to create a query so that I can combine each of the found duplicates into one entry.
An example of this is:
Name |ID |Tag |Address |carNum ------------------------------------------------------- Bob Barker |2054| 52377 |235 Some road |9874 Bill Gates |5630| 69471 |014 Washington Rd. |3700 Bob Barker |2054| 97011 |235 Some road |9874 Bob Barker |2054| 40019 |235 Some road |9874 Steve Jobs |8501| 73051 |100 Infinity St. |4901 John Doe |7149| 86740 |7105 Bull Rd. |9282 Bill Gates |5630| 55970 |014 Washington Rd. |3700 Tim Boons |6370| 60701 |852 Mnt. Creek Rd. |7059
In the example above, Bob Barker and Bill gates are both in the database more than once so I would like the output to be the following:
Bob Barker |2054|52377/97011/40019|235 Some road |9874 Bill Gates |5630|69471/55970 |014 Washington Rd.|3700 Steve Jobs |8501|73051 |100 Infinity St. |4901 John Doe |7149|86740 |7105 Bull Rd. |9282 Tim Boons |6370|60701 |852 Mnt. Creek Rd. |7059
Notice how Bob Barker & Bill Gates appends the tag row (the duplicated data) into one row instead of having multiple rows. This is because I do not want to have to check the previous ID and see if it matches the current id and append to the data.
After performing a side-by-side instalation of SQL2005, I am not able to open Enterprise manager (for managing SQL2000 instance). It aborts with some errors related to mmc.exe not being able to use a couple of dlls: semsfc.dll and lmmc.dll. I've tried to unresgister/register them but I get the following error message:
semsfc.dll is loaded, but the dllRegisterServer entry point was not found... This file can not be registered .
I found a similar complaint in the VB forum, which recomended to use Reagasm but I couldn't understand it really, and I'm not sure if it applies to this SQL server issue.
Below. I have also pasted the current result of this query and the desired result.
Query can be updated to get the desired result as given below?
Query: Select c.OTH_PAYER_ID, c.PAID_DATE, f.GROUP_CODE, f.REASON_CODE, f.ADJUSTMENT_AMOUNT From MMIT_CLAIM_ITEM b, mmit_tpl c , mmit_attachment_link d, MMIT_TPL_GROUP_RSN_ADJ f where b.CLAIM_ICN_NU = d.CLAIM_ICN and b.CLAIM_ITEM_LINE_NU = d.CLAIM_LINE_NUM and c.TPL_TS = d.TPL_TS and f.TPL_TS = c.TPL_TS and b.CLAIM_ICN_NU = '123456788444'
Current Result which I am getting with this query
OTH_PAYER_ID PAID_DATE GROUP_CODE REASON_CODE ADJUSTMENT_AMOUNT 5501 07/13/2015 CO 11 23.87 5501 07/13/2015 PR 12 3.76 5501 07/13/2015 OT 32 33.45 2032 07/14/2015 CO 12 23.87 2032 07/14/2015 OT 14 43.01
Desired/Expected Result for which I need updated query
I have created a trigger that is set off every time a new item has been added to TableA.The trigger then inserts 4 rows into TableB that contains two columns (item, task type).
Each row will have the same item, but with a different task type.ie.
I'm running a merge replication on a sql2k machine to 6 sql2k subscribers. Since a few day's only one of the merge agents fail's with the following error:
The merge process could not retrieve generation information at the 'Subscriber'. The index entry for row ID was not found in index ID 3, of table 357576312, in database 'PBB006'.
All DBCC CHECKDB command's return 0 errors :confused: I'm not sure if the table that's referred to in the message is on the distribution side or the subscribers side? A select * from sysobjects where id=357576312 gives different results on both sides . .
We are trying to do some utilization calculations that need to factor in a given number of holiday hours per month.
I have a date dimension table (dimdate). Has a row for every day of every year (2006-2015)
I have a work entry fact table (timedetail). Has a row for every work entry. Each row has a worked date, and this column has a relationship to dimdate.
Our holidays fluctuate, and we offer floating holidays that our staff get to pick. So we cannot hard code which individual dates in dimdate as holidays. So what we have done is added a column to our dimdate table called HolidayHoursPerMonth.
This column will list the number of holiday hours available in the given month that the individual date happens to fall within, thus there are a lot of duplicates. Below is a brief example of dimdate. In the example below, there are 0 holiday hours for the month of June, and their are 8 holiday hours for the month of July.
I have a pivot table create based of the fact table. I then have various date slicers from the dimension table (i.e. year, month). If I simply drag this column into the pivot table and summarize by MAX it works when you are sliced on a single month, but breaks if anything but a single month is sliced on.
I am trying to create a measure that calculates the amount of holiday hours based on the what's sliced, but only using a single value for each month. For example July should just be 8, not 8 x #of days in the month.
Listed below is how many hours per month. So if you were to slice on an entire year, the measure should equal 64. If you sliced on Jan, Feb and March, the measure should equal 12. If you were to slice nothing, thus including all 15 years in our dimdate table, the measure should equal 640 (10 years x 64 hours per year).
I have tested the code below to remove duplicate table entries based on the field IntOOS. This code works; however, I want to ensure I am removing the oldest entries and keeping the most recent entry. The field to key on this would be something like Max(ID). What would be the best way to ensure I keep the most recent table entry?
/*** Removes duplicate rows from ampfm.rpt_AdtVisitDiag table
by Chuck King 20070928
***/
;WITH CTE
as
(
SELECT
ROW_NUMBER() OVER (Partition By IntOOS Order BY IntOOS) AS ROWID
A table gets data every 4 minutes, I only need spread of every 15 minutes. Can I select only records spread every 15 minutes apart from this table without having to run a scheduled job every 15 minutes and loading one record closest to getdate() at that point into another table(this is how I am doing it now) Is there a better way. Please help Thanks
I have a report that needs to return a count of zero for the rows that have no data, I have tried to use the Left Outer Join but my where clause is excluding the rows with no data and I need to filter the report with the Year, day and Month.
The date filters are from different table(dimDate), not sure how to include them in the #tmpOperationalTypes join as filters
I have been looking for the answer to this for a while, but probably haven't found the right place or query. I want to achieve the following:Table 1Table 2 DateShiftDateShiftData --------------------------------------------------------------------------------- 1/1/200711/1/20072Some data 1/1/200721/2/20073Some more data 1/1/20073 1/2/20071 1/1/20072 1/1/20073
and generate: Table 3 DateShiftData -------------------------------------------------------- 1/1/20071NULL 1/1/20072Some data 1/1/20073NULL 1/2/20071NULL 1/1/20072NULL 1/1/20073Some more data
This way, the information can be displayed and show that some of the entries were not entered for the dates with NULL. Thanks for the help, -Syn
I current have a SqlDataSource with a querystring that uses the following code:<asp:SqlDataSource ID="SearchQuery" runat="server" ConnectionString="<%$ ConnectionStrings:Connect %>" SelectCommand="SELECT Title, ArticleID, REPLACE(SUBSTRING(Article,0,250), '<br />', ' ')AS Article FROM [Articles] WHERE FREETEXT([Article], @q)"> <SelectParameters> <asp:QueryStringParameter Name="q" QueryStringField="q" DefaultValue="*" Type="String" /> </SelectParameters> </asp:SqlDataSource>The string works fine, however is there a way to show how many results where found? Also is there are no results found, can I have it report that as well? Thanks!
This is a followup to a previous question to a previous but in reverse of Find rows where value in column not found in another row
Given one table, Table1, with columns Key1 (int), Key2 (int), and Type (varchar)...
I would like to exclude any two rows where Type is equal to 'TypeA' and Key2 is Null that have a corresponding row in the table where Type is equal to 'TypeB' and Key2 is equal to Key1 from another row.
I would like to return all the rows except where Key=1 and Key=3 because those rows together meet the criteria of Type='TypeA'/Key2=NULL and does have a corresponding row with Type='TypeB'/Key1=Key2.
I recently started with a company that uses access for a front end and sql2000 for the back. They have set up an ODBC connection though access2k to reach sql2k. This works fine but fouls up in regards to the record locking. You can set record locking in access but it has no effect. In the office help it says 'data in a form, report, or query from an Open Database Connectivity (ODBC) database is treated as if the No Locks setting were chosen, regardless of the RecordLocks property setting.'
Also, the access lock option info says it 'could' lock the few records around the record you wish to lock.
So my question is this: How can i (without destroying this ODBC link from access2k to sql2k) get locks for individual records to work successfully?
I have created an Access2K front end application that connects to aSQLServer2K backend. I use this vba code to create the connection fromthe Access app:Dim strConnect As String'make sure all previous connections are closed:CurrentProject.OpenConnection "Provider="'create new connection string to server:strConnect = "PROVIDER=SQLOLEDB.1;INTEGRATED SECURITY=SSPI;PERSISTSECURITY INFO=FALSE;INITIAL CATALOG=NewsBaseDataSQL;DATASOURCE=nycvnewsbas01"CurrentProject.OpenConnection strConnectEverything functions.The problem is the users cannot make the connection if they are notpart of the local admins group on the server. As soon as they areremoved from the local admins group their conenctions fail.How do I remedy this?
Given one table, Table1, with columns Key1 (int), Key2 (int), and Type (varchar)...
I would like to get the rows where Type is equal to 'TypeA' and Key2 is Null that do NOT have a corresponding row in the table where Type is equal to 'TypeB' and Key2 is equal to Key1 from another row
I would like to return only the row where Key1 = 4 because that row meets the criteria of Type='TypeA'/Key2=NULL and does not have a corresponding row with Type='TypeB'/Key1=Key2 from another row.
I have tried this and it doesn't work...
SELECT t1.Key1, t1.Key2, t1.Type FROM Table1 t1 WHERE t1.Key2 IS NULL AND t1.Type LIKE 'TypeA' AND t1.Key1 NOT IN (SELECT Key1 FROM Table1 t2 WHERE t1.Key1 = t2.Key2 AND t1.Key1 <> t2.Key1 AND t2.Type LIKE 'TypeB')
Hi,I'm converting an Access 2000 database to Sql Server and must bemissing something obvious.Using the Import utility in Sql Server, the Access queries seem to getexecuted and the resultant data imported as tables. Oops!Using the Upsize lizard in Access 2003, the queries aren't even in theselection list of "tables" to upsize. It looks like the Upsize wizardisn't supposed to do queries.How does one automate the migration of standard conforming queries toSql Server?Of course, I expect to spend some time addressing the stickiernon-compliant queries, but there must be a way to do the easy ones.What am I missing?-Dave
In an Insert Into statement I have used the Host_Name() function toidentify which user has suppied a record to a table that holdstemporary data.I'm using an Access2K front end.Code:Alter procedure SPName@parameter1 intASSet nocount OnSet xact_abort offDeclare @myHost nvarchar(50)Set @myHost = Host_Name()Insert Into tblMyNameTEMP(UniqueID, AnyField1, AnyField2,myMachineName)SELECT tblMyName.UniqueID, AnyField1, AnyField2, @myHostFROM tblMyNameWHERE tblMyName.UniqueID = @parameter1I have two problems.In some cases (and only on one or two of maybe about 250 clientworkstations) Host_Name() returns the name of MY machine. I'm thinkingthis is because I developed the app and distributed it and for somereason it's retaining the info contained in my original connectionsetup set in the MS-Access Connection window???Also, on some occasions, I get blocking messages in my trace logfollowing this operation.Any help on these two issues is appreciated.lq
Hi.I have the problem that some records in a ms sqlserver table is unableto update from Access.I get the error message odbc-time out error in linked table......I tried to copy this table to another database, where none but me wasaktive.And then it worked quit ok when I try to save the record.I am thinking about if there is some trigger och restraint that Idon't know about, but I don't know how to se all of this in thedatabase.I have changed the odbc-timeout settings in Access but that doesn'tseed to make any differenceSo what's the problem?Does anyone have an idea?/regards BigOlle
I'm using a shipping program called endicia professional that allows for database manipulation to make my processing easier. I've managed to fix the database here and there but have had an issue combining orders from a single customer when theybuy more than one item. Ideally I would like to have it combine rows when a customer purchases items going to the same address. To avoid having an issue where the address line is the same ie two people live in the same appt complex and it combines these I thought we could use qualifiers as the purchase will have name, order Id that should be unique enough
Order-id name address sku 1234 John 46 easy ln. A27 1234 John 46 easy ln. B32
Results: Order-id name address sku 1234 John 46 easy ln. A27,b32
i have a query in which i need to show all rows of same id in singel row and last column should be comma seperated .my query is :
BEGIN TRY SET NOCOUNT ON DECLARE @l_numberOfRecordsInserted INT -- Check if valid Application User ID is passed IF ( @i_AppUserId IS NULL ) OR ( @i_AppUserId <= 0 )
[code]....
so last column section name should come as comma seperated .
There will be one UniqueID for each row. We'll get the uniqueID and PK1 and PK2 in a file. Imp: We need to generate the Sequence_Id depending on number of Issue_dates or Issue_amounts or Issue_Categories or Issue_Rejects as in the above table.
Can we do this without using cursors? This is going to be one time process.
I've a temp variable where I'm moving some columns like below:
id value type1 type2
0 ab type1val1 type2val1
0 cd type1val1 type2val1
0 ef type1val1 type2val1
1 ab type1val2 type2val2
1 cd type1val2 type2val2
1 ef type1val2 type2val2 What I want to do is group these by their id and get the following o/p ab,cd,ef type1val1 type2val1 ab,cd,ef type1val2 type2val2
The grouped values need to be separated by commas.
What I'm doing currently: I'm using a temp variable to put all these values but am unable to coalesce and get the desired o/p.
I have a table that contains many columns in a single row and I'd like to split the table so that it has fewer column values and more rows. My table structure is: create table #scoresheet (Decisions varchar(10), DNumericalValue int, DVI varchar(10), DComments nvarchar(255), Competence varchar(10), CNumericalValue int, CVI varchar(10), CComments nvarchar(255), Equipment varchar(10), ENumericalValue int, EVI varchar(10), EComments nvarchar(255)); I would like to have three rows with four columns. What I've done so far is create a stored procedure that uses a table variable: create procedure sp_splitsinglerow as
declare @Scoresheet_rows_table_var table ( ReviewArea varchar(25), NumericalValue int, VI varchar(10), Comments nvarchar(255)); insert into @Scoresheet_rows_table_var (ReviewArea, NumericalValue, VI, Comments) select Decisions, DNumericalValue, DVI, DComments from #scoresheet
The trouble with this approach is that I have to explicitly name the columns that I insert into the table variable. What I'd really like to be able to is have a loop construct and select the first 4 columns the first time, the second 4 the next time and the last 4 the third time.
Any ideas on how to achieve that?
BTW, I have resolved this issue by suggesting to the Developers that they change the structure of the original table, but I'd still like to know if there is another solution. :)
I am working with some old code that we are trying to clean up and perform some performance enhancements. The performance is now, so Very much better. From over 3 minutes to under 2 seconds.
But I am still trying to get the multiple rows into a single row. I would like to place this into a CTE to get the multiples into a single row. I just cannot get my head around how is the best, most efficient way to write the query.
This is a small example of what the rows look like in the resultset, and what I want to single to be.
DECLARE @BillingCorrect TABLE ( ContractNumber char(10) , pc1 int , pb int , om int , vp int
[Code] ....
I am not sure how to write the query to have all the data in a single row.