I have group of stored procedures with names like 'somename_%'. Are there any way to delete that SP with one query, forexample
DROP PROCEDURE where name like
'somename_%'
.
Hello there
I've a table with about 130 000 records with telephonenumbers. The numbers are all formated like this +4311234567. The numbers always include international country code, local area code and then the phonenumber and sometimes an extension.
There is a webservice which checks for the caller's number in the table. That service works already. But now the client wants that also if someone calls from a company which number is already in the database but not his extension, that the service will return some result.
Example for table.
**id** | **telephonenumber** | **name**
| 1 | +431234567 | company A
| 2 | +431234567890 | employee in company A
| 3 | +4398765432 | company b
now if somebody from company A calls with a different extension for example +43123456777, than it should return id1. But the problem is, that I don't know how many digits the extensions have. It could have 3,4 or more digits.
Are there any patterns for string kind of matchings?
The data is stored in a sql2005 database.
Thanks
I'm looking for a Java ORM that works from database reflection - I need to just point it at a DB, and start being able to walk through the entire set of tables, etc.
Ideas?
I'm using Mysql 5.1, and have this query, is there a way to not use the subqueries and accomplish the same result?
SELECT oref.affiliate_id, ROUND(sum( oph.amount ) * 0.10 ,2) AS tsum
FROM operators_referer AS oref
LEFT JOIN operators_payments_history AS oph
ON oref.operator_id = oph.operator_id
WHERE oref.affiliate_id = 28221
AND
(
oph.date_paid >
(
SELECT MAX(aph.date_paid)
FROM affiliates_payments_history AS aph
WHERE aph.operator_id = oref.affiliate_id
)
OR
(
SELECT MAX(aph.date_paid)
FROM affiliates_payments_history AS aph
WHERE aph.operator_id = oref.affiliate_id
)
is NULL
)
I was trying to run the following query
UPDATE blog_post SET `thumbnail_present`=0, `thumbnail_size`=0, `thumbnail_data`=''
WHERE `blog_post` NOT IN (
SELECT `blog_post`
FROM blog_post
ORDER BY `blog_post` DESC
LIMIT 10)
But Mysql doesn't allow 'LIMIT' in an 'IN' subquery.
I think I can make a select to count the table rows and then make an ordered update limited by 'COUNT - 10', but I was wondering if there is a better way.
Thanks in advance.
I am stuck in converting this snipped to asp.net.
set RSLinksCat = conn.Execute("select linkscat.id, linkscat.category from linkscat, contentlinks, links where contentlinks.linksid = links.id and contentlinks.contentid = " & contentid & " and links.linkscatid = linkscat.id order by linkscat.category")
<%if not RSLinksCat.EOF then%><h1>Links</h1>
<br />
<%do while not RSLinksCat.EOF%>
<%set RSLinks = conn.Execute("select * from links where linkscatid = " & RSLinksCat("id") & "")%>
<strong><%=RSlinkscat("category")%><strong>
<ul>
<%do while not RSlinks.EOF%>
<li>
<a href = "http://<%=RSLinks("url")%>" target="_blank"><%=RSlinks("description")%></a>
</li>
<%RSLinks.MoveNext
loop%>
</ul>
<%RSLinksCat.MoveNext
loop%>
<br />
<%end if%><%conn.close%>
I'm not sure where to start. Can anyone recommend the correct approach i.e sqldatareaders or repeaters or arrays or? VB code samples most welcome.
Thanks
My table looks like this with duplicates in col1
col1, col2, col3, col4
1, 1, 0, a
1, 2, 1, a
1, 3, 1, a
2, 4, 1, b
3, 5, 0, c
I want to select distinct col1 with max (col3) and min(col2);
so result set will be:
col1, col2, col3, col4
1, 2, 1, a
2, 4, 1, b
3, 5, 0, c
I have a solution but looking for best ideas?
Hi friends,
While updating a datatime column in a table from another table, i noticed that mnilliseconds value are not shown.. instead it is rounded and the value is updated to nearest seconds.
Example :
Original Value: 2008-06-26 14:06:36.643
Updated Value : 2008-06-26 14:07:00
Please help me getting the actual value including milliseconds
If you have a table with a clustered index on the Primary Key (int), is it redundant and bad to have one (ore more) non-clustered indexes that include that primary key column as one of the columns in the non-clustered index?
hi!
the query is:
select employee_id, last_name, salary, round((salary+(salary*0.15)), 0) as
NewSalary, (round((salary+(salary*0.15)), 0) - salary) as “IncreaseAmount”
from employees;
can i optimize this round((salary+(salary*0.15)), 0) part in anyway, so that it doesn't appear twice..i tried giving it an alias but didn't work :(
i created a small application using c# winforms that uses mssql as a database.
is there a way to attach the database to the exe file so i won't need to install sqlserver on all the machines that i want to run the program on?
Hi All,
I'd like to move some data from one table to another (with a possibly different schema). Straightforward solution that comes into mind is -
start a transaction with serializable isolation level;
INSERT INTO dest_table SELECT data FROM orig_table,other-tables WHERE <condition>;
DELETE FROM orig_table USING other-tables WHERE <condition>;
COMMIT;
Now what if the amount of data is rather big, and the <condition> is expensive to compute? In PostgreSQL, a RULE or a stored procedure can be used to delete data on the fly, evaluating condition only once. Which solution is better? Are there other options?
I'm trying to make a table visible to Views. One of the columns has type date (as opposed to a Unix timestamp). The example I initially tried to copy from is in modules/comment.views.inc in the Views module:
// timestamp (when comment was posted)
$data['comments']['timestamp'] = array(
'title' => t('Post date'),
'help' => t('Date and time of when the comment was posted.'),
'field' => array(
'handler' => 'views_handler_field_date',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort_date',
),
'filter' => array(
'handler' => 'views_handler_filter_date',
),
);
This makes the dates, which are all in the past year or so, show up as "1 Jan 1970 00:33", so evidently a value of '2010-05-12', for example, is being interpreted as 2010 seconds past 1 Jan 1970 00:00.
Can anyone point me to a correct way of exporting date columns?
EDIT: I'm following up on some clues found at http://drupal.org/node/476774 .
I have a varchar @a='a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p' , wich have | delimitted values. I want to split this variable in a array or a table.
Do anyone have any idea about this.
At my job, we have pseudo-standard of creating one table to hold the "standard" information for an entity, and a second table, named like 'TableNameDetails', which holds optional data elements. On average, for every row in the main table will have about 8-10 detail rows in it.
My question is: What kind of performance impacts does this have over adding these details as additional nullable columns on the main table?
I'm using a database link to execute a DELETE statement on another DB, but the DB link name doesn't conform to global naming, and this requirement cannot change.
Also I have global_names set to false, and cannot be changed either.
When I try to use these links however, I receive:
ORA-02069: - global_names parameter must be set to TRUE for this operation
Cause: A remote mapping of the statement is required but cannot be achieved because
GLOBAL_NAMES should be set to TRUE for it to be achieved. -
Action: Issue `ALTER SESSION SET GLOBAL_NAMES = TRUE` (if possible)
What is the alternative action when setting global_names=true is not possible?
Cheers,
Jean
I wanna update my database from my dataset.
mydataadapter = new MySqlDataAdapter("SELECT * FROM table0; SELECT * FROM table1; SELECT * FROM table2;", con);
myda.Fill(dataset);
//......
// for example I'm doing a change like this
ds.Tables[2].Rows[1][3] = "S";
//Then updating the database
MySqlCommandBuilder com = new MySqlCommandBuilder(mydataadapter);
mydataadapter.Update(dataset, "table2");
then it returns this error
TableMapping['table2'] or DataTable 'table2' didn't find by Update.
Do you have any advice?
I have a column whose value is a json array. For example:
[{"att1": "1", "att2": "2"}, {"att1": "3", "att2": "4"}, {"att1": "5", "att2": "6"}]
What i would like is to provide a view where each element of the json array is transformed into a row and the attributes of each json object into columns. Keep in mind that the json array doesn't have a fixed size.
Any ideas on how i can achieve this ?
Hi,
I have this MySql select query witch seams to have a bug but I am quit "green" so I simple can not see, so maybe you could help?
Here is the query:
SELECT node_id
FROM rate
WHERE node_id='".$cat_node_id_string."'
LIMIT ".$node_count_star.",".$node_count_end."
ORDER BY SUM(amount)
GROUP BY node_id
Thanks for help in advance...
I need a way to store an int for N columns. Basically what I have is this:
Armies:
ArmyID - UINT
UnitCount1 - UINT
UnitCount2 - UINT
UnitCount3 - UINT
UnitCount4 - UINT
...
I can't possible add a column for each and every unit, so I need a fast way to store the number of each units in an army (you might have guesses it's for a game by now). Using XML is not an option as it will be dead slow.
I need to get the most recent record for each device from an upgrade request log table. A device is unique based on a combination of its hardware ID and its MAC address. I have been attempting to do this with GROUP BY but I am not convinced this is safe since it looks like it may be simply returning the "top record" (whatever SQLite or MySQL thinks that is).
I had hoped that this "top record" could be hinted at by way of ORDER BY but that does not seem to be having any impact as both of the following queries returns the same records for each device, just in opposite order:
SELECT extHwId,
mac,
created
FROM upgradeRequest
GROUP BY extHwId, mac
ORDER BY created DESC
SELECT extHwId,
mac,
created
FROM upgradeRequest
GROUP BY extHwId, mac
ORDER BY created ASC
Is there another way to accomplish this? I've seen several somewhat related posts that have all involved sub selects. If possible, I would like to do this without subselects as I would like to learn how to do this without that.
what is the proper way of doing the following:
getting DATE as user input
running a query
generating a report that uses the query
this is the solution i was thinking:
have a form that takes user input
run the query
open the report
what is the correct way of doing this?
I have a table where a record looks like this
varchar(255) Name
varchar(255) Text
varchar(255) Value
Name is the DDL name, Text is what is displayed, and Value is returned upon selection. There are between one and twenty options for each Name. Without iterating though each option like a cursor, is there any way to pull out a list of objects, one for each unique DDL Name, using Linq and C#?
A sample of the data:
Beds '4 (10)' 4
Beds '5 (1)' 5
Beds '7 (1)' 7
Baths 'NA (13)' NULL
Baths '0 (1)' 0
Baths '1 (13)' 1
I was thinking about doing an outer select to get the unique Names, then an inner select to get the list of options for it, then return the set as a List of a set of Lists.
The situation is as follows:
I have a substantial number of tables, with each a substantial number of columns. I need to deal with this old and to-be-deprecated database for a new system, and I'm looking for a way to eliminate all columns that have - apparently - never been in use.
I wanna do this by filtering out all columns that have a value on any given row, leaving me with a set of columns where the value is NULL in all rows. Of course I could manually sort every column descending, but that'd take too long as I'm dealing with loads of tables and columns. I estimate it to be 400 tables with up to 50 (!) columns per table.
Is there any way I can get this information from the information_schema?
EDIT:
Here's an example:
column_a column_b column_c column_d
NULL NULL NULL 1
NULL 1 NULL 1
NULL 1 NULL NULL
NULL NULL NULL NULL
The output should be 'column_a' and 'column_c', for being the only columns without any filled in values.