sql

MSSQL to MYSQL Migration tool

I want to migrate my MSSQL database into MYSQL. Is there any open source or free software for that? ...

Hibernate HQL: Converting a SQL Statement to HQL (with subselects/joins)

Hello Hibernate Experts, i would very much appreciate your help in transforming the following SQL statement to a valid HQL Statement. I tried for hours but was not successfull: SELECT * FROM master as m left outer join (select * from child as c where c.id = (select max(d.id) from child as d where d.MasterFk = c.MasterFk) )as b ON m.id...

MySQL error when trying to get unique values using DISTINCT together with LEFT JOIN

I have two mysql tables, courses and student_courses, I need to get unique course_names from the course table. But I get a erro when trying to execute my query. Heres my query SELECT sc.c_id, DISTINCT c.course_name FROM Courses AS c LEFT JOIN Student_Courses AS sc ON c.c_id = sc.c_id WHERE sc.s_id = 4 This i...

What is the preferred way of executing SQL in a Custom SSIS task?

I'm writing a Custom SSIS task that, as one of it's functions, should execute a stored procedure on a database connection. I can't seem to find any information about how this is done. I'm using an ADO.NET Connection Manager to connect to the database and I wish to write my Task in C#. What is the preferred way of executing SQL in a Cu...

Trace in SQL Server 2005 Mobile Edition

Is there any tool available, from Microsoft or 3rd party, that allows a trace to be performed on Windows Mobile 6 device running Microsoft SQL Server 2005 Mobile Edition? ...

SQL Syntax: Select Results for each date between a range of dates

Hi, I have the following SQL (SQL Server 2005) that I use to calculate the total times for each column: DECLARE @Param1 DATETIME DECLARE @Param2 DATETIME DECLARE @Param3 DATETIME SET @Param1 = '2009-01-01' SET @Param2 = '2009-09-09' SELECT SUM(IdleSec) AS TotalIdleSec, SUM(ProductionSec) AS TotalProductionSec, SUM(Upline...

Update first then Insert if row doesn't exist (SQL) Rather than check if row exists first?

Hiya All, I've always used the method of checking a table to see if a row exists, and then update it with my new data or insert it if it doesn't exist, but it's got me thinking what would be wrong with simply doing an update, if no rows are effected, then do an insert statment, that could potentially speed up my script and put less load...

Hierarchical Query

Hi all, I hope I'm able to explain the problem that is puzzeling me. I have the following hierarchical data set (this is just subset of 34K records) PARENT_ID CHILD_ID EXAM TUDA12802 TUDA12982 N TUDA12982 TUDA12984 J TUDA12984 TUDA999 J TUDA12982 TUDA12983 N TUDA12983 TUDA1532...

In which cases can INNER JOIN (SELECT ... not be rewritten using temp table

I am using GridSQL where I get some performance problems whenever the SQL pattern INNER JOIN (SELECT arises. I am therefore considering rewriting all these queries into two queries, one creating a temporary table using the exact select statement and the other query joining with the temporary table, so the pattern would be INNER JOIN temp...

Don't check field if parameter is an empty string

I want to do this (s.Reference = @Reference or @Reference = '') but I get an sql error saying unable to convert nvarchar to bigint. What's going on there. I just want to skip that query on the Refernce if the input parameter is an empty string. ...

SQL query without UNION

Can any one help me in rewriting the following query without using UNION statement? ( SELECT A.QRYNAME0 "Query Name", A.OPRID, A.DESCR, A.QRYTYPE, TO_CHAR(A.CREATEDTTM,'DD-MON-YYYY HH24:MI:SS') "Created On", TO_CHAR(A.LASTUPDDTTM,'DD-MON-YYYY HH24:MI:SS') "Last Updated On", B.EXECCOUNT "No of Times Executed...

SQL: How To Find The Top String Column Value in a Grouped Query

When grouping is there a simple way to get the first or top value out of a column. In the following example I want the last value in [Text] if sorted by [Date] descending. SELECT [Id], MAX([Date]), TOP 1 [Text], <-- How do I do do this COUNT(*) FROM [ExampleTable] GROUP BY [Id] ORDER BY [Date] DESC Thanks in advance....

Insert 50 thousand record in MySQL

I want to insert 50 000 records into MySQL through a web service written in Java but only 20 000 records are getting inserted. I dont think there is size (number of record ) limition in my sql. is there something where i can Insert/Select 50k records in a single go (bulk) ...

Microsoft PHP SQL Driver 1.1

Hi, Will microsofts SQL for PHP driver version 1.1 work with x64 builds of php 5.3? It's not a general question as much as it sounds, we are currently having trouble with it. I just would like to know if someone can confirm if it works/should work or not. Thanks Jonas ...

SSIS - Date Coloumn to Variable Null and non-Null Values

Within an SSIS package I have a dataflow that extracts two coloumns from an access database a TaskID and a date I store this in a ADO recordset and pass this to a For Each Loop Container I am them attempting to assign each value pair to two variables "taskID" and "taskDate" I then want to use thse two variables within a SQL Insert task...

SQL Server express edition issue

Hello everyone, I want to know SQL Server Express edition, like SQL Server 2008 Express edition, whether totally free or not (e.g. free for a period of time or free for ever)? I heard no management tool like SQL Server Management Studio for Express edition, is that true? If I have some code which works on SQL Server Enterprise edition...

Performance issue with SQL Server stored procedure

I used the ANTS profiler to identify the remaining bottleneck in my C# application: the SQL Server stored procedure. I am using SQL Server 2008. Can anybody here help me increase performance, or give me pointers as to what I can do to make it better or more performant? First, here's the procedure: PROCEDURE [dbo].[readerSimilarity] --...

Iterate over multiple MySQL tables, export 1 table from each

I have around 150 MySQL databases, I need to export 1 table from each of the databases. Is this possible, username and password are identical for each DB. ...

SQL Server 2005 Deadlock Problem

I’m running into a deadlock problem when trying to lock some records so that no process (Windows service) picks the items to service them, then update the status and then return a recordset. Can you please let me know why am I getting the deadlock issue when this proc is invoked? CREATE PROCEDURE [dbo].[sp_LoadEventsTemp] ( @Request...

T-SQL ISNULL() Optimization

I have this clause on a join in a stored procedure I inherited: WHERE a.is_active = 1 AND b.due_date <= ISNULL(@due_date_limit, b.due_date) How would I re-write this to remove the ISNULL as it's causing severe performance problems? ...