sql

SQL Server: Return uniqueidentifier from stored procedure

Can I return UNIQUEIDENTIFIER from a stored procedure using the RETURN statement or is it only by using the OUTPUT statement? i.e to return the PersonID UNIQUEIDENTIFIER: CREATE PROCEDURE CreatePerson @Name NVARCHAR(255), @Desc TEXT AS DECLARE @Count INT DECLARE @JobFileGUID UNIQUEIDENTIFIER -- Check if job exists? SET @Coun...

proper sql structure

Hi, I have a table results, which has he following columns: ID TestCase Platform 1 P1.1.1 Win1 2 P2 Win1 3 P3 Win3 4 P1.1.1 Win3 I have specific category of Platform's Only 4 Win1,Win2,Win3,Win4 Testcases will repeat for each and every Platform. Now, what I am confused is : I need to List all the distinct TestC...

Sorting Float Column vs Int Column in SQL Server

I wonder if type of a column matters in terms of sorting performance. I have heard that int columns are sorted faster than float columns. Do you think it is correct? ...

adding primary key to sql view

Reading that http://stackoverflow.com/questions/894610/how-to-do-hibernate-mapping-for-table-or-view-without-a-primary-key I am wondering how to add a primary key to my view as it is basically just a stored query...? PS: oracle 10g thx ...

update with the value returned from aggregate function

How to update a column of a table using an aggregate function in the sql update statement ? ...

How to find if a value is NULL in SQL Server using c#

I would like to know which values are null in datatable in c# that is returned from ExecuteDataTable of SqlHelper class. string select = "select * from testTable"; string val=""; DataTable dt=dbcon.ExecuteDataTable(select); foreach (DataRow dr in dt.Rows) { foreach (DataColumn dc in dt.Columns ) { if(dr[dc].Equals (null)...

Some Q regarding SOLR and how it actually works!

I have a classifieds website, and I have currently around 100thousand ads in a mysql table. I am using php to fetch results and to display them on a page. However, I am noticing the searches getting slower and slower. That is why I am planning on installing and using SOLR, as I have heard good things about it. But to my suprise, I have...

A good reference for Oracle PL/SQL

What are the best references for Oracle PL/SQL? I have an excellent knowlege of SQL-92 and of MS-SQL extensions, but now I'm working with Oracle and I'm struggling to find good references for the PL/SQL language. I am looking for references for the following: Variable Loops Cursor Packages Trigger Stored Procedures Temporary Table...

Querying a MySQL database step by step - Best method?

Hi, I am building a web application that uses PHP 5, MySQL 5 and Javascript with jQuery and AJAX. The application is a quite complicated selection process with several pulldown menus that the user can select from in any order. Each select in a pulldown will give some more selection critera, that will limit the choices in the other pull...

How to recover the old data from table.

Hi, I have made an update statement in a table in SQL 2008 which updated the table with some wrong data. I didn't have a backup for the DB. It's some important dates which got updated. Is there anyway where i can recover the old data from the table. Thanks SNA ...

How to add together the results of several subqueries?

I am running a MySQL query to rank my site's users according to the number of book reviews and recipe reviews they have contributed. After initial issues with a multiple JOIN query, I've switched to a series of subqueries, which is much, much faster. However, although I can extract the numbers of reviews from each member, I can't figure ...

SQL MS Access - Invalid Use of Null

I have now got rid of the overflow on this query by forcing to a long but now I get Error 94: Invalid Use of NULL Can anyone tell me what the problem could be? SQL Query: Sum(CLng( [TotaalPrijs]/([tbl_ArtikelsPerOrder]![Aantal]*[Totaal])* [tbl_ArtikelVerwijderdUitZaaglijst]![Aantal] )) AS GezaagdeOmzet ...

Violation of PRIMARY KEY on select statement

I have a table that looks like this: CREATE TABLE [dbo].[SomeTable]( [Guid] [uniqueidentifier] NOT NULL, [Column1] [int] NOT NULL, [Column2] [datetime] NOT NULL, [Column3] [bit] NOT NULL, [Column4] [smallint] NOT NULL, [Column5] [uniqueidentifier] NULL, [Column6] [varchar](100) NULL, [Column7] [datetime] ...

Need help with SQL to calculate if store is open or not

I have a list of storecodes in table "Stores" and another table "StoreClosedDates" which tells me if the store is closed on a Saturday or Sunday. My StoreOpenDates table looks like this: CREATE TABLE [dbo].[StoreClosedDates]( [StoreCode] [varchar](50) NOT NULL, [ClosedOnSunday] [bit] NOT NULL, [ClosedOnSaturday] [bit] NOT NU...

Make an SQL request more efficient and tidy?

I have the following SQL query: SELECT Phrases.* FROM Phrases WHERE (((Phrases.phrase) Like "*ing aids*") AND ((Phrases.phrase) Not Like "*getting*") AND ((Phrases.phrase) Not Like "*contracting*")) AND ((Phrases.phrase) Not Like "*preventing*"); //(etc.) Now, if I were using RegEx, I might bunch all the Nots into one big (ge...

Add comma-separated value of grouped rows to existing query

I've got a view for reports, that looks something like this: SELECT a.id, a.value1, a.value2, b.value1, /* (+50 more such columns)*/ FROM a JOIN b ON (b.id = a.b_id) JOIN c ON (c.id = b.c_id) LEFT JOIN d ON (d.id = b.d_id) LEFT JOIN e ON (e.id = d.e_id) /* (+10 more inner/left joins) */ It joins quite a few tables and return...

SQL Server: How to Join to first row

i'll use a concrete, but hypothetical, example. Each Order normally has only one line item: Orders: OrderGUID OrderNumber ========= ============ {FFB2...} STL-7442-1 {3EC6...} MPT-9931-8A LineItems: LineItemGUID Order ID Quantity Description ============ ======== ======== ================================= {098...

Datediff between non-consecutive rows in a table

I would like to take the average of the time difference from Table1 below. The values are not consecutive and occasionally the time value is repeated, so I need to 1) sort by time, 2) discard non-unique values, 3) perform the time difference (in milliseconds), then 4) average the resulting time difference values. Further I'd like to 5)...

Does SOLR use up alot of memory on a server?

I have NO EXPERIENCE with SOLR. Does SOLR use more memory than say MySql on a server? I am about to purchase a VPS-package, but they come in different sizes as you can imagine... I contacted the providers today by email, and told them that I was planning on using SOLR which requires java installed. Their response was that it would w...

SQL view outputs duplicate rows

I am creating a new query from an old query and I'm getting duplicate rows in my result. I have absolutely no idea why this is happening? Here is the old SQL codes which does not produce duplicates: XtraViwStock SELECT TOP 100 PERCENT dbo.qexp_detail.in_date AS inDate, RTRIM(dbo.qexp_detail.stock_locn) AS stockLocn, { fn LCASE(RTR...