sql

SQL transform table query

Hi, I got a problem transforming a table that looks like this PropertyName | PropertyValue --------------------------------- color red color blue size big size small into this: Color | Size --------------------------------- red big red small blue big blue small How can I achieve this? Thanks in advance for any ...

System.Data.SqlClient.SqlException: Invalid object name 'MESSAGE'.

hello all, i have encounter a error that's what can i do? System.Data.SqlClient.SqlException: Invalid object name 'MESSAGE'. ...

JET SQL Performance/ SQL Understanding

This is not a problem that needs answering, more of a query on why this is happening. I have a field in one table that is populated with 'Y' Or 'N', and i have a query that simply takes the value of that field and pops into another table The table has approximately 25,000 records in it The query below takes about 25 seconds to run UP...

Why can't SQL Server alter a view in a stored procedure?

I'm using MS SQL Server, and I'd like to alter a view from within a stored procedure, by executing something like "alter view VIEWNAME as ([some sql])". A few pages thrown up by google assert that this is not supported directly (and neither are related alter-table statements), but there are also examples of how to work around it using c...

how to delete duplicate entry by one SQL ?

i has a table deal: CREATE TABLE `deal` ( `id` int(11) NOT NULL auto_increment, `site` int(11) NOT NULL default '0', `area` int(11) NOT NULL default '0', `name` varchar(255) default NULL, PRIMARY KEY (`id`) ); i want to create : UNIQUE KEY `site` (`site`,`area`,`name`); but now, name filed is not UNIQUE,when i create thi...

Query optimization

I have an stored procedure of this format if(condition 1) begin ( ----- ----- select into #temp1 ---- drop #temp1 ) end if(condition 2) begin ( ----- ----- select into #temp1 ---- drop #temp1 ) end now when the above stored procedure is execute it shows me an error that: "There is already an object named '#temp1' ...

SQL show record when join has no records

SELECT tblProducts.productName, tblProducts.basePrice, tblProductOptions.optionDescription FROM tblProducts CROSS JOIN tblProductOptions WHERE (tblProducts.ID = 3) AND (tblProductOptions.ID = 5) If (tblProductOptions.ID = 5) then it works, there is an option with ID = 5. If it's (tblProductOption...

Multiple contact XML field updates SQL 2008 R2

Hi, I'm not sure of the soundness of the following architecture, but right now, the following information is for a prototype at this time. I have a stored procedure that currently lets me: Pass an owner memberID and say an ID for a new event record In the member table, I have an XML field say called events, and the new event ID gets a...

What is pctincrease in oracle?how the memory is allocated,resized,and autoextended while creating a table space

How the memory is allocated,reallocated and autoextended while creating tablespaces?what is meant by initial and default in tablespaces and how the next is a multiple of five times DB_BLOCK_SIZE? ...

Optimize JOIN SQL query with additional SELECT

Hello, I need a query which will select just one (GROUP BY phi.id_product) image for each product and this image have to be the one with the highest priority (inner SELECT with ORDER BY statement). The priority is stored in N:M relation table called product_has_image I've created a query, but it tooks about 3 seconds to execute and I ...

SQL SERVER, Composite Primary Key Handling

I have a table with 2 primary keys (int, int) and was wondering if it was possible to have one of the primary keys set to auto increment and the other not? The following is the basics of the table structure: Table { Id - Int, VersionId - Int } Basically I have an Id with a Version so that there is a complete history of that reco...

Pagination of oracle result set, returned by stored procedures

Hi all! In our project, we have all DB manipulations concentrated in Oracle stored procedures. Result sets is returned by OUT parameter of SYS_REFCURSOR type. Now we have a task to make pagination, and we don't want to rewrite all of our procedures, adding 2 parameters (pageNumber and pageSize) to them and editing WHERE clauses. We have...

What are the consequences of the sys.sql_dependencies Catalog View Not Being Updated

If I have two trivial stored procedures, created like so: create procedure root as select 1 go create procedure dependant as exec root go (Where dependant depends on root). When I check the sys.sql_dependencies table for the second procedure, I see an entry (as i would expect). If, however, I add the dependant procedure first, I ...

Using single query to retrieve multivalued attribute by joining two tables without causing duplication of fields in mysql

Table 1 : QUERY: Create table client ( applicationNo int primary key, name varchar(20) ); Insert statement: Insert into client values (1,'XYZ'),(1,'ABC'),(1,'DEF'); applicationNo | name 1 | XYZ 2 | ABC 3 | DEF Table 2: Query : Create table client ( applicationNo int, ...

Complicated query with hibernate criteria.

Hello, I want to get QuestionVersion with max versionNumber for each Question. Next I need to check status of those versions and get QuestionVersionContents associated with versions with correct status value. Following statement seems to work but I need It as criteria or at least HQL: select c.content, c.language_id, qv.status, qv.ver...

Duplicating records efficiently in tsql

Hey guys, I've a scenario where I have a parent table which has '1 to many' relationships with two or three tables. These child tables again have '1 to many' relationships with more tables and so on. This goes up to 5 to 6 levels of hierarchy. Now, based on single primary key value of the parent table, I want to duplicate all informati...

Multi-part Identifier could not be bound - Update Query SQL Server 2005

Hi, SQL Server novice here. UPDATE dbo.ObjectivesApproved SET dbo.ObjectivesApproved.VAP = 'Y' WHERE ((dbo.Approved.Cri_Group In ('X01' ,'X02' ,'X03' ,'X04' ,'X05' ,'X07' ,'X08' ,'X09' ,'X10' ,'X11' ,'X12' ,'X13' ,'X14'))) gives the following error The multi-part identifier "dbo.Approved.Cri_Group" could not be bound. What's caus...

Server hardware requirements for SSRS

As the title says, i'm trying to figure out how much RAM is needed to generate and export to excel a large report using SQL Server Reporting Services on Windows Server 2003. It is not an option to upgrade it to SS2008 and also not an option to export to CSV. Strictly from a hardware point of view what is a good configuration for a high...

Select TOP 1 in SQL Server 6.5

I beg you don't ask me why am I using SQL Server 6.5 There is no SELECT TOP command in SQL Server 6.5, and guess what, I need it :) I need to perform something like Select top 1 * from persons where name ='Mike' order by id desc I've tried something with SET ROWCOUNT 1, but in that case you cannot use order by. I end up with Sele...

ADO.Net entity framework SQL loginPermissions

I am fairly new to entity framework, and i am planning to use it in my next project. what permissions should web give to the sql server user login which entity framework uses? since i read entity framework does DML operations do i need to provide datawriter role to login? ...