If I have a table with important 2 columns,
CREATE TABLE foo (id INT, a INT, b INT, KEY a, KEY b);
How can I find all the rows that have both a and b being the same in both rows? For example, in this data set
id | a | b
----------
1 | 1 | 2
2 | 5 | 42
3 | 1 | 42
4 | 1 | 2
5 | 1 | 2
6 | 1 | 42
I want to get back all rows exce...
Is there a way of debugging sql in visual studio
...
I want to remove a particular character while retrieving a varchar from a table. The query looks like this:
SELECT ServiceName,
case isNumeric(Ramusage)
when 1 then
cast ( ltrim ( rtrim ( ramusage )) as int )
else
0
end as test,
priority
FROM ProcessInfo
Here the probl...
I have a 3 large tables (10k, 10k, and 100M rows) and am trying to do a simple count on a join of them, where all the joined columns are indexed. Why does the COUNT(*) take so long, and how can I speed it up (without triggers and a running summary)?
mysql> describe SELECT COUNT(*) FROM `metaward_alias` INNER JOIN `metaward_achiever` ON ...
I want to select some values from a table . I want a text output . Now what iam doing is iam writing a procedure to convert the selected values into text . But its really time consuming . Is there anythng , means any system functions or sp's in SQL to implement this....?
...
How do I select data from a MS SQL Server from MySQL? We have a system of linked server in SQL Server. I have also heard that you can do a linked server to Mysql from sql server. But I want to know the reverse.
The mssql server is what we use mainly for production. So one main reason we'd want to do this is simply to get the exact mssql...
I need to replace more than 20 000 names with new names i created given the CodeID.
For example: I must update all rows that contain "dog" (which has a CodeID of 1) with "cat", and update all rows that contain "horse" (which has a CodeID of 2) with "bird", etc.
1st SQL statement: UPDATE animalTable SET cDescription = "cat" WHERE Code...
Hi,
I've got an SQL table that I use to keep product data. Some products have other attached data to them (be it: books have number of pages, cover type; movies have their time-length; etc).
I could use a separate table in SQL to keep those, keeping (name, value) pairs.
I can also just keep an XML-packed data in a single field in a t...
Here is my problem,
i'm trying to do tag cloud in symfony, what i want to perform is such a sql query
select tag, count(tag) from tagi group by tag order by count(tag) desc limit 10
anyone can help?
...
I've got a table defined like this :
create table #tbFoo
(bar float)
And I'm looking for a way to round every value contained in column bar without changing the total sum (which is known to be an integer, or very close to an integer because of float number precision).
Rounding every value to the nearest integer won't work (ex : 1,5;...
How can I test two datetimes (not including their time components) for equality?
...
I try insert byte array in sql table, data type in table is VarBinary(Max), but it finish with this error:
System.Data.SqlClient.SqlException: Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.
Any adice, I am beginner with Sql...
Here is my code:
byte[] key;
...
Database Name = MyDB
Table Name = MyTable
Column Name = ColumnSurname
Using SQL Server 2005
I have multiple entries in ColumnSurname and some of them are spelled exactly the same. How can i return all the distinct values with the same ColumnSurname value. Meaning i want to return "Bond" if "Bond" comes up more than twice.
How would ...
Hi All,
Im Using toad for Oracle to run a query which is taking much too long to run, sometimes over 15 minutes.
The query is pulling memos which are left to be approved by managers. The query is not bringing back alot of rows. Typically when it is run it will return about 30 or 40 rows. The query needs to access a few tables for its...
How do I drop all foreign-key constraints on a table in SQL Server 2000 using T-SQL?
...
I am having db2 9.5 whereas our client is having db2 9.1. So what happenes is, if i create a SP which is using any function present in 9.5 but not in 9.1 then the procedure will fail to compile / create on client side.
Is it possible to compile the SP as it will be in 9.1 ?
...
I read this article, and i have the code in oracle, but I want to convert it to work on MySQL. In Oracle, i use the function rank, with four columns can eligible or not, how i can use this in mysql, or, it is not possible?
This is the code, I want select the most eligible line, every line can have 4 columns completed, I want to rank on...
I've noticed that prepared statements containing ROW_NUMER() code often gets recompiled although their SQL-code hasn't changed.
(example from book Inside Microsoft SQL Server 2008: T-SQL Querying):
WITH SalesRN AS (
SELECT
ROW_NUMBER() OVER (ORDER BY qty, empid) AS rownum,
empid,
mgrid,
qty
FROM
dbo.SalesOrder
)
SELECT
r...
Msg 8966, Level 16, State 1, Line 1
Could not read and latch page (1:1681) with latch type SH. sysindexes failed.
What does this mean ?
is it that DB is currupted?
...
How can I get a default value of 0 if a sum does not return any rows?
Edit: I have edited this post to add a more thorough example (which the previous one didn't encounter)
E.g.
DECLARE @Item TABLE
(
Id int,
Price decimal,
PricePer decimal
)
DECLARE @OrderItem TABLE
(
Id int,
ItemId int,
ChargedPrice nvarchar...