sql

How to wait for execution control to return from dropping a table?

I have the following code: CurrentDb.Execute "DROP TABLE [" & DatabaseName & "].[" & TableName & "];" Which will drop a table from an MS Access database. Typically this is being done using a database on a shared network. How can I ensure the DROP method completes before allowing the control to move on to the next line in my code? T...

What is a level pseudo column in Oracle, Can anyone explain me in this?

What is a level pseudo column in Oracle, Can anyone explain me in this? ...

Getting the hour from a datetime?

How can I select the hour from a datetime? I'm looking for the equivalent of Oracle's TO_CHAR( d, 'HH24' ), which would return 17 for 2010-06-23 17:22:31. I tried to find out about the best time (best answer/questin-ration) to ask an SQL-related question on StackOverflow, using Data Explorer. I got it to work, but I'm sure there is a...

Mysql Many to Many Query

I have a many to many table setup in my mysql database. Teams can be in many games and each game has 2 teams. There is a table in between them called teams_games. SHOW CREATE TABLE information follows. I have been messing with this query for a while. At this point I don't care if it requires sub-queries, joins, or unions. I have tried a...

Top N in View or Crystal Reports?

I am wondering if it's possible to use a view to get the top 5 lines from a table. I am finding that Crystal reports doesn't seem to have anything built in to do this, or I'd do it there. When I query the view Select * from qryTranHistory, it returns the first 5 items, but if I try to select a specific type Select * from qryTranHistory ...

printing restaurant opening hours from a database table in human readable format using php

i have a table that lists the opening hours of restaurants. the columns are id, eateries_id, day_of_week, start_time, and end_time. each eatery is represented in the table multiple times because there is a separate entry for each day. see this previous question for more details: http://stackoverflow.com/questions/3070295/determine-if-a-r...

select restaurant table entries within a certain distance from current location using php

i have a database table with a list of restaurants including their names, latitudes, and longitudes. i would like to select all the restaurants that are within a certain distance from my current location. the current location is determined in the php file (right now i'm just using a static lat & lng). i found code for calculating the dis...

Literal does not match format string for Oracle SQL to_date on a string column

Dear SQL Gurus from Stack Overflow: Environment: Oracle I'm trying to understand why I can't do a to_date selection on a table column that contains strings. Note tableZ with a column of name Value in the example below contains a bunch of strings, some of which are the correct format, for example 6/20/2010 00:00:00. tableZ | Value ...

How do I pass a column as a parameter in Stored Procedure?

How do I pass and use the column name to retrieve a bigint variable in the actual column? DECLARE @personID BIGINT, DECLARE @queryString varchar(500) Set @queryString = 'Select @personID = ' + @PersonColumnID + ' from dbo.Loss_Witness where WitnessID = @witnessID' exec(@queryString) Error message states "Must declare variable '@perso...

How do you merge rows from 2 SQL tables without duplicating rows?

Hi, I guess this query is a little basic and I should know more about SQL but haven't done much with joins yet which I guess is the solution here. What I have is a table of people and a table of job roles they hold. A person can have multiple jobs and I wish to have one set of results with a row per person containing their details and...

Count query results on multi-join statements

select cnt.loginid, grp.last_name as 'Group Name' from contact cnt right join grpmem list on cnt.contact_uuid = list.member left join contact grp on grp.contact_uuid = list.group_id join contact_acctyp cntacc on cnt.contact_uuid = cntacc.contact_uuid where cntacc.c_acctyp_id in (select id from acctyp_v2 where sym like 'CD...

Sql Server Query Optimization

I want to write a query in a stored proc with many filters but I want to avoid dynamic SQL. Say my parameters are nullable (@filter1, @filter2, @filter3...). One way I might solve this is: SELECT col1, col2, col3 FROM table WHERE col1 = ISNULL(@filter1, col1) AND col2 = ISNULL(@filter2, col2) AND col3 = ISNULL(@filter3, col3) The re...

Subsonic Command Timeout

Hello, Is there a way to set the command timeout for everything generated by subsonic? -Edward ...

MySQL query question, I can't get it.

I hope someone can help me out. I have a table that logs our import jobs. I need a query that will produce a matrix with the names of tables on the vertical axis, the import dates on the horizontal axis, and the total number of records imported for that table on that date in the matrix cell. I don't care if we have to create a temporary ...

How to delete duplicate values for a field in a table with a single query?

I want to delete from a table the entries where it has multiple values for Date field. So say I have Employee table - Id,Name,Date,Points i want to delete the entries with same Date field which should be unique...just to cleanup i need to just keep a single entry for date and delete the rest...maybe keep the recent one if possible....c...

How can I break referential integrity briefly, within a transaction, without disabling the foreign key constraint?

I have a table with 3 columns: ID, PARENT_ID, NAME PARENT_ID has a foreign key relationship with ID in the same table. This table is modeling a hierarchy. Sometimes the ID of a record will change. I want to be able to update a record's ID, then update the dependent records' PARENT_ID to point to the new ID. The problem is, when I ...

Is it possible to set ExecuteUpdate to respect session filters?

The query below makes use of ExecuteUpdate. I want said method to respect session filters. Is this possible? //This line seems to make no effect. _session.EnableFilter(FilterName).SetParameter(FilterParam, Value); _session.CreateQuery(String.Format("DELETE FROM {0} WHERE Id IN (:idList)", object.Name)) .SetPar...

Anyone have success setting up SharePoint 2010 with Sql Server 2008 on separate boxes?

I am setting up SharePoint 2010 on one machine with SQL Server on a separate box to server as both the data store and serve reporting services (through SSRS/SP Integration). In the past, I would install the WSS 3.0 for SharePoint 2007 on the SQL Server Box. It appears that there is no existing option for SP 2010. Am I missing somethin...

How do you use autocomplete for thousands of entries?

Is there a way to setup autocomplete in PHP/jQuery that can quickly run through thousands of rows in a database? I have a job board where the user enters his/her college - and I want to offer autocomplete. Problem is, there are 4,500 colleges in the united states and a seems like an awful solution. Is there a good way to both make th...

Can a Microsoft SQL table have more than one Primary Key?

I was always curious but can't find a concise answer. Any help? ...