sql

How to deny delete on a table for all users

Within SQL Server 2005, is there a way, with a single statement, to deny delete on rows in a particular table for all users of the database? ...

MySQL/PHP update query error

I'm running a query to update a small group of 'items' in a table, from PHP. Running the code with "Sequel Pro" executes it perfectly, while running it on PHP using mysql("query here"); fails miserably. Is there anything wrong with my query? UPDATE `service_joblocation` SET `in_use` = '1', `in_use_since` = '1283488686',...

Rows without repeating records

id | name -------+------------------------------------- 209096 | Pharmacy 204200 | Eyecare Center 185718 | Duffy PC 214519 | Shopko 162225 | Edward Jones 7609 | Back In Action Chiropractic Center I use select id, name from customer order by random() There are 6 records i just want that when ever i query, i will get a uniq...

VBScript not executing sql statment properly

Hi Gurus, good nite! I write you this time because a VBScript that one of the application my company uses to retrieve information from an Oracle database does not seem to be working properly. Here are the facts: There's part of the code that does the following: sSql = "SELECT REQ_PAYMODE" & _ " FROM SYSADM.GBPRESTATIEGROEP" & _ ...

SQL Statement Same Column Different Data

Hello, I have a table with students from 4 courses and two different departments (Math 101, Math 102, English 201, English 202). I want to select students from Math 101, and English 201 if they've had it and English 202 if they've had it or both if they've had them both. Edit: StudentID | Dept | CrsNum 12345 MS 101 99999 ...

Alternative to ORDER BY RAND() on joined tables?

I have a table of approx 3500 Items. In another table I'm storing user votes - the Item id, the user id and the score. When a user hits this script, it must randomly select an Item they haven't already voted on. At the moment I'm using LEFT JOIN then testing for null to find the set of Items they haven't voted on. Trouble is, using ORDE...

Can you make this query faster?

Hello! I'm currently doing a summer job and I have to extend an existing program. My boss asked me to make a tool for our clients so they can see how much their employees cost, per month. But that's not all. The thing is that a company can have one or more 'societies', or subcompanies. We want know how much an employee costs per society...

mysql join two tables

Hi I have a problem joining two tables: table1 id name 1 aaa 2 bbb 3 ccc table2 id table1_id name 1 1 x1 2 1 x2 3 2 s1 table1 is the main table, table2 contains attributes. I need to join and search both tables, but display distinct results from first table. When using JOIN I...

Inserting records to database from multiple checkboxes in vb.net

I have a table like these: Club Table contains: ClubID(IDENTITY), Name, Address Genre table contains: GenreID and Genre ClubGenre table contains Club ID, GenreID Club has a one to many relationship with Genre I created an application that functions like a database editor. I have a group of checkbox contained in a group box labeled G...

How can I rearrange string with SQL?

Declare @CustTotalCount as int Declare @CustMatchCount as int select @CustTotalCount = count(*) from ENG_CUSTOMERTALLY select @CustMatchCount = count(*) from Task where MPDReference in( select ENG_CUSTOMERTALLY_CUSTOMERTASKNUMBER from dbo.ENG_CUSTOMERTALLY) if(@CustTotalCount>@CustMatchCount) select distinct substring(ENG_CUST...

How can i use substring in SQL?

Possible Duplicate: How can I rearrange string with SQL? Declare @CustTotalCount as int Declare @CustMatchCount as int select @CustTotalCount = count(*) from ENG_CUSTOMERTALLY select @CustMatchCount = count(*) from Task where MPDReference in( select ENG_CUSTOMERTALLY_CUSTOMERTASKNUMBER from dbo.ENG_CUSTOMERTALLY) if...

ASP.NET & Entity Framework 4.0 data not refreshing on screen

I've written a 2-tier C# asp.net application. Everything works OK, but if I modify the SQL Server data using the management console, the changes are not displayed on screen. It seems the application reads the data from a cached instance. I have tried everything to make sure it's not a browser cache issue... the data remains static until ...

Select according to string ending

Hi, In my DB, I store various version numbers, like the following : OBJNAME Fix_6.0.0a.1 Fix_6.0.0a.2 I would like to sort them not according to last version element (the number behind the last .character. How do I write such SQL statement ? I guess it's something like SELECT SUBSTR(INSTR(OBJNAME, ".", -1)) as LAST_VERSION, OBJNAME ...

SQL Query value divided by the max(value)

Hi, I'm ashamed of myself 'cause i can't do this query properly... I have a table like this nom | code_geo | valeur | indice -------+----------+--------+-------------------- AISNE | 02 | 81573 | 0.05 SOMME | 80 | 79520 | 0.03 OISE | 60 | 70004 | 0.09 what i need to do is divide each "indice" by the m...

Bulk Delete ManyToMany collections on Derby

I'm using Hibernate and Derby. I've this class: public class Sensorboard { //... @ManyToMany(fetch=FetchType.LAZY) @JoinTable(name="SENSORBOARD_SENSORBOARD_JOIN", joinColumns= @JoinColumn(name="SENSORBOARD_ID", referencedColumnName="ID"), inverseJoinColumns= @JoinColumn(name="NEXTSENSO...

Count number of trails and live based on a month in SQL

Please HELP!!! I have the following table in my database where [start date] and [End date] data type is in datetime CompanyID ServiceStartDat BillingStartDate         1               03/01/2010              03/02/2010        2               12/01/2010       ...

How to separate diffrent database values when they have the same name?

I Have a problem to get the right "Name" from the database, The result is the same on all the "Name". I get the information from the same stored procedure. Are there a way to specify witch name I look for? ex. Text='<%#Eval("tblBrand.Name") %>' Gets the name in tblBrand. But that dosent work. <asp:Label ID="lblProductName" runat="server...

SQL Querying for two Consecutive Rows

I have the following query: SELECT year_week FROM web_details where location = ''JF'' AND property_id = ''FARM'' which produces the following results. YEAR_WEEK 201035 201036 201037 201039 201041 201044 201045 201048 What I actually want is to produce a set of results which only displays values if the consecutive value is available...

How to select the name of the table in an SQL query?

I'm using a UNION and a LIMIT to select the earliest occurence of a type of table row from multiple tables. I need a record of which table satisfied the query in the result set. Is there a way of doing something like: SELECT id, someField, tableName FROM someUnknownTable WHERE someConditions = true ...

Temporary tables how to create before transaction and then use inside transaction

I write code in c#. I want to create temporary table before transaction begins and then use it within transaction, however when I try to do it I get error within transaction it estates that "Table does not exist". What is the proper way of doing it ? SqlConnection sqlConnection = new SqlConnection( "connstring" ); sqlConnection.Open()...