sql

Why the most natural query(i.e. using INNER JOIN (instead of LEFT JOIN)) is very slow.

This query takes too long... explain analyze select c.company_rec_id, c.the_company_code , c.company from tlist t -- it is questionable why this query become fast when using left join, the most natural query is inner join... join mlist m using(mlist_rec_id) join parcel_application ord_app using(parcel_application_rec_id) join par...

Do I gain any performance advantages by using VIEWs rather than JOINs?

In our project, we often end up writing complex joins over like 3 tables. Do we gain any performance advantages by using views or are they only for making the lives of query writers easier? In case it matters, we use MySQL. If any advantages are thus achieved (other than simpler queries of course) please illuminate. ...

How do I avoid redundant data fields in the result set when using JOINs ?

Following join is supposed to retrieve user info along with their messages for users with a certain status: SELECT * FROM user, message WHERE message.user_id=user.id AND user.status=1 The problem is that all rows about a certain user in the result set contain redundant columns that repeat the same data about that user (those fields re...

How to send mail from Stored Procedure ?

Hi All, I need to send a mail from Stored Procedure. I knew it is possible. I studied it from this link . How do i authenticat in SMTP Server. Do you have any idea.? Thanks ...

SQL Sever 2008 Database Project deployment issue

hi I'm having issue with how to to deploy (a SQL2008 project) to multiple dbs. I'm using VS2010 + SQL Server 2008 Database project, it imports the "DevDB", works all fine. Now I want to deploy it to a different DB "TestDB", both DBs are on the same SQL server. It's keep complained about ".mdf and .log" conflicts. In SQL 2005 db proje...

Is it possible to define a serial datatype which autoincrements when updating a row?

when a new row is added to a table containing a serial column, the next highest integer value is assigned to that column when the row is committed. can I define a serial datatype which will autoincrement when updating a row with a previously assigned serial value?...in datablade?.. I'm currently using the following functionality for an i...

problem with SQL query in DB2

How can i write a query in DB2 for following thing: The difference between current timestamp and a timestamp field in dB should be >=4 hours AND <= 24 hours ...

OPENROWSET & SQL Server 2008 Security (SSAS)

Hi! I try to fill a SSAS Mining Model with Data from a (local) SQL Server Table Both SQL Server and SSAS (all 2008) are on the same (devlopment machine) WinXP64. SQL Server Security is 'Windows Authentication' MDX Code: INSERT INTO MINING STRUCTURE [ttseries] ( [col1], [col2], [col3], [col4] ) OPENROWSET( 'SQLOLEDB', 'Server=(local...

Re copy and re-order table

I am using SQLite. I want to create a new table ordered differently than an existing tables's data. I have tried the following but it does not work in either the Mozzilla SQLite admin tools or SQLite Manager. What am I doing wrong? INSERT INTO temp (SnippetID, LibraryID,Name, BeforeSelection, AfterSelection, ReplaceSelection, NewDocu...

Search uniqueidentifier value in SQL Server 2008 table

I have a table in SQL Server 2008 with uniqueidentifier field. In my application (C#, WPF) I have a textbox which intended for search some data by GUID, user can enter guid by typing, ctrl+v, etc, so he/she can make an error. What is the best and fastest approach to make a search by this field using linq2sql ignoring whitespaces, "-".....

Any good method to work with large amount of data?

I have almost 100.000 records in the database and I need to compare them to each-other with the Longest Common Subsequence algorithm, and I need to do that with 1000 new records every day. My application is written in c# .Net, and the problem is that this comparing is working slow on the application level, for comparing of 1000 records a...

display data in sharepoint services 3. 0 dashboard from SQL server 2008

i want to display the SQL server data which is in table form into the SHarepoint. I dont have sharepoint 2007/2010 I just have SHarepoint services 3.0 and sharepoint designer 2007 please help. I think business data catalog cant be used in this version. IS it true ? do i have to go for paid version ? ...

Oracle SQL trace with bind variables

How to aquire the full SQL statement with bind variables substituted from a trace file? When setting ALTER SESSION SET EVENTS '10046 trace name context forever, level 4'; ALTER SESSION SET sql_trace = true; the resulting trace file contains the SQL query with bind variables and the resolution of the bind variables in a separate "BIND...

The table 'dbo.UserProperties' is ambiguous. Why this error is coming ?

Why this update statement is not getting compiled ? According to the msdn it is perfectly right. UPDATE dbo.UserProperties SET Value = MergeFrom.Value FROM dbo.UserProperties MergeFrom , dbo.UserProperties MergeTo WHERE MergeFrom.Field = MergeTo.Field AND MergeTo.[Key] = CAST(@MergeToUserID AS NVARCHAR(50)) ...

finding time differance in DB2

How can i write a query in DB2 for following thing: The difference between current timestamp and a timestamp field in dB should be >=4 hours AND <= 24 hours Some one suggested this but its not working. select * from tableName where date <= DATEADD([hour], -4, CURRENT_TIME) and date date >= DATEADD...

Syntax error in ALTER PROCEDURE in a DB update script

I have a script to update my database for a new release of my web app . In this update i need to alter a strored procedure. I have an ALTER PROCEDURE script that works fine when run on its own, however when I drop it into my update script and run it I get the errors "Incorrect syntax near the keyword 'PROCEDURE'." and "Must declare the s...

How much time will my SQL query take?

I have a database in SQLite Administrator, with 3 tables, say A,B and C. Table A has 3 columns p1,p2 and p3, with about 2 million rows. Table B has 2 columns p1 and p4, with also about 2 million rows. Table C has 1 column p4 with about 800,000 rows. The query that I am trying to run is as following: SELECT A.p1, B.p4, A.p2, A.p3 FRO...

Insert not getting compiled.

Why this insert is not getting compiled :- INSERT INTO dbo.UserGroupsToUsers ( UserID , LastUpdated , ID , UserGroupID ) SELECT @MergeToUserID , GETDATE(...

SQL views. do i need to use it to increase performance?

i mostly need to know - views and their purpose ? - do they increase performance of an application ? - in what kind of cicumstance will I need to use views? ...

xp_md5.dll for 64-bit

I am right now using this extended stored procedure in one of the test database on sql server 2008 and it works fine. I tried to do the same on a different sql server and it did not work on that. Then I got an explaination that the former was a 32 bit processor and latter was a 64 bit processor. Is there anyway to make use of this extend...