A cross join performs a cartesian product on the tuples of the two sets.
SELECT *
FROM Table1
CROSS JOIN Table2
Which circumstances render such an SQL operation particularly useful?
In SQL Server, there is the option to use query hints.
eg
SELECT c.ContactID
FROM Person.Contact c
WITH (INDEX(AK_Contact_rowguid))
I am in the process of getting rid of unused indexes and was wondering how I could go about determining if an index was used as a query hint. Does anyone have suggestions on how I could do this?
Cheers,
Joe
i don't know whats wrong with this sql query.
SELECT *
FROM main
WHERE key LIKE '%$word%'
its giving results in phpMyAdmin but giving warning while executing it in a php page.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
I want to create a view for each tree for each customer of this 3 table structured in this way:
Fields: db_attrib.name, db_attrib.name, db_attrib.name until the last db_tree.id_child = 0
Values: db_attrib_values.value where db_attrib.id = db_attrib_value.id_attrib and so on for each child
And so on for each db_tree.id
This is the link to sql fiddle with the prepared structure:
http://sqlfiddle.com/#!9/21516
I was browsing around and found this blog post:
http://erikej.blogspot.com/2010/04/version-3-of-exportsqlce-now-available.html
(It is for a great add in if you user SQL Server CE.)
On that post I saw an screen shot of SSMS with images in the results.
How is this done? I have images in my database (PNG files that are serialized via memory stream), but I just see numbers when I select the image column.
I need to convert int data table field to nchar or nvarchar leading zeros
example:
1 convert to '001'
867 convert to '000867'
thx.
I tested this T-SQL Script and work fine for me !
DECLARE @number1 INT, @number2 INT
SET @number1 = 1
SET @number2 = 867
SELECT RIGHT('000' + CAST(@number1 AS NVARCHAR(3)), 3 ) AS NUMBER_CONVERTED
SELECT RIGHT('000000' + CAST(@number2 AS NVARCHAR(6)), 6 ) AS NUMBER_CONVERTED
I want to start working on a big project. I research about performance issues about LINQ to EF and NHibernate. I want to use one of them as ORM in my project. now my question is that which one of these two ORM can get me better performance in my project? I will use SQL Server 2008 as database and C# as programming language.
Hi,
I am using Oracle Sql Developer to browse a MySQL database. When I browse table with Columns tab(shows table definitions), some of tables will display an Error Encountered dialog that says: Vendor code 1317. Does anyone know how I can resolve this?
Thanks,
/Z
Is there a way in fluent nhibernate (or possibly NHibernate in general) to tell it to generate the primary keys differently? It creates the column name for the key fine, but the index/constraint gets weird generated names like:
PK_Address_3214EC2725332734
PK_CreditCa_3214EC2756CA82C8
etc...
I can use straight sql to rename them but i'd rather not.
thanks,
all
Hello ,
I would like to query from SQL Server 2000 Database.I have got two tables. They are Purchase and PurchaseDetails. I would like to get product records with Last Purchase ID but I can't query with the following statements.So please help me.
SELECT TOP 100 PERCENT dbo.Purchase.PurchaseID AS LastOfPurchaseID, dbo.PurchaseDetails.ProductID,
MAX(dbo.Purchase.PurchaseDate) AS LastOfPurchaseDate
FROM dbo.Purchase INNER JOIN
dbo.PurchaseDetails ON dbo.Purchase.PurchaseID = dbo.PurchaseDetails.PurchaseID
GROUP BY dbo.PurchaseDetails.ProductID, dbo.Purchase.PurchaseDate,dbo.Purchase.PurchaseID
ORDER BY MAX(dbo.Purchase.PurchaseDate) DESC
I'm running SQL Server 2005 Express. And I'm trying to do a bulk insert/import of a data file with a field/row terminator that uses a hexadecimal value 0x001. How should I represent it in a bulk insert command?
I have something like:
bulk insert xxx.dbo.[yyy]
from 'D:\zzz\zzz.dat'
with (
CODEPAGE='RAW',
FIELDTERMINATOR = '=|=',
ROWTERMINATOR = '=|=\001\n',
KEEPNULLS
);
which results in
Msg 4863, Level 16, State 1, Line 7
Bulk load data conversion error (truncation) for row 1, column 3 (code).
The query is a single select containing a lot of grouping levels and aggragate operations.
With SET ARITHABORT ON is takes less than a second, otherwise it takes several minutes. We have seen this behavior on SQL Server 2000 and 2008.
update answers a1
set a1.FilingDate=(
select date_sub( a2.FilingDate
,Interval 1000 Year) as FilingDate
from answers a2
where Year(a2.FilingDate)>=3000
)
where Year(a1.FilingDate)>=3000
but it gives me the following error:
You have an error in your SQL syntax;
check the manual that corresponds to
your MySQL server version for the
right syntax to use near 'update
answers a1 set a1.FilingDate=( select
date_sub(a2.FilingDate,Interval 10' at
line 1
Can anyone tell me about the issue and its solution?
Hibernate criteria, using DB2 dialect, generates the following sql with
composite keys in the IN clause, but DB2 answers that the query is incorrect:
select * from tableA where (x, y) IN ( ( 'x1', y1) )
but, DB2 throws this:
SQL0104N An unexpected token "," was found following ", y) in
( ('x1'".
Expected tokens may include: "+". SQLSTATE=42601
Howdy Folks,
what is the best solution to import large amounts of records into an MySQL or Oracle Database. I Think there are two ways :
Insert every record with an persistent connection
Create on BIG SQL-Statement and query the Database
Iam not sure wich is performing better ? Is there any Best Practice Solutions for this kind of operation ??
In SQL Server 2008, is it possible to create a column that can have a value inserted into it, but can never be updated? In other words, the column can have an initial value inserted into it, but once it contains a non-null value, it can never be changed. If possible, I would prefer to do it without using a trigger.
Thanks - Randy
Given the following models:
class Recipe < ActiveRecord::Base
has_many :recipe_ingredients
has_many :ingredients, :through => :recipe_ingredients
end
class RecipeIngredient < ActiveRecord::Base
belongs_to :recipe
belongs_to :ingredient
end
class Ingredient < ActiveRecord::Base
end
How can I perform the following SQL query using Arel in Rails 3?
SELECT * FROM recipes WHERE NOT EXISTS (
SELECT * FROM ingredients WHERE
name IN ('chocolate', 'cream') AND
NOT EXISTS (
SELECT * FROM recipe_ingredients WHERE
recipe_ingredients.recipe_id = recipes.id AND
recipe_ingredients.ingredient_id = ingredients.id))
I am trying to get my linq query to replicate my t-sql but I am lost.
SELECT *
FROM BaiDetail INNER JOIN
BaiDetailMap ON BaiDetail.DetailText
LIKE '%' + BaiDetailMap.BaiDetailMapSearchText +'%'
This is what I have so far... but no go
from det in Source
from map in Map
where det.DetailText.Contains(map.SearchText)
select new {det, map}
Error Message:
Only arguments that can be evaluated on the client are supported for the String.Contains method.
There are two models Post and Comment. I should get all posts, which have no comments with specific tag. How can I do this using new Rails 3 features such relational algebra (arel).
SQL-solution should be something like this:
SELECT `posts`.* FROM `posts` LEFT OUTER JOIN `comments` ON `posts`.`id` = `comments`.`post_id`
WHERE NOT (`comments`.`tag` = 'my_tag')
Hi,
We are working on a Windows Mobile 6.5 application.
The application is already installed in some devices, and we need to distribute a new version with changes in the database schema (we added a few tables).
Is there a way to make a "patch" windows mobile installer that will replace the application and update the embedded SQL database with some scripts?
In a normal windows installer we would create a custom action in the installation process to apply the changes in the database, but I'm not sure how to do that for Windows Mobile
Thanks.
Let's say I have the following code in a form that is triggered on some click event.
DoCmd.SetWarnings False
DoCmd.OpenQuery "AddSomeStuff"
DoCmd.OpenQuery "UpdateSomeOtherStuff"
DoCmd.OpenQuery "DeleteABunchOfCrap"
DoCmd.SetWarnings True
Can I assume that the three update queries I executed (in SQL Server) are not transactional in that they are run is separate transactions?
The SQL query without where statement runs great and outputs good results, but when I include WHERE condition it shows Unknown column 'date1' in 'where clause'. What's the problem?
SELECT IF(e.weekly, DATE_ADD(DATE(e.time), INTERVAL CEIL(DATEDIFF('2010-04-08', e.time)/7) WEEK), DATE(e.time)) AS `e.date1`, `v`.`lat`, `v`.`lng`
FROM `events` AS `e`
INNER JOIN `venues` AS `v` ON e.venue_id = v.id WHERE e.date1 > '2010-09-01'
I tried to create exactly the same but new table from old table in another database using dblink. This procedure used to worked last two times, but this time I got message:
"SQL state: 42703
Context: Error occurred on dblink connection named "unnamed": could not execute query."
Anyone knows where is the problem or how to solve it?
Please!