sql

SQL Server 2008 reports

Hi Is SQL Server 2008 reports works in adobe reader 5.1? How can i test that one? What is Microsoft report viewer? ...

Help deciphering Stored Procedure

I can't for the life of me figure out how this stored procedure works or what it is doing exactly, I know it works as is but I'm trying to limit some database calls which requires modifying this stored procedure. CREATE PROCEDURE scriptassist.getQueue @Status smallint = -1, @GroupID uniqueidentifier = null, @MACAddress varch...

ORM: why should i use it?

Possible Duplicates: Are there good reasons not to use an ORM? Why should you use an ORM? Hello, i develop since many years in SQL (many different sql servers like Oracle, MSSql, Mysql) and i always been happy in doing that. I've recently seen a lot of stuff around ORMs and i'm asking why should i move toward this world. Can...

Zend_DB union() : Zend_Db_Table_Abstract vs Zend_Db_Table::getDefaultAdapter()

So i have this raw SQL that i want to call via the zend framework select t.type, t.tid,t.tname,t.cid,t.cname, ls.* from ( select t.type, t.id as tid, t.name as tname, c.id as cid, c.name as cname from team t join company c on t.parent=c.id and t.type='C' and c.sector=20 and t.status='ACTIVE' union select t.ty...

How to use T-SQL MERGE in this case?

I'm new to T-SQL command MERGE so I found a place in my SQL logic where I can use it and want to test it but can't figure out how exatcly should I use it: IF (EXISTS (SELECT 1 FROM commissions_history WHERE request = @requestID)) UPDATE commissions_history SET amount = @amount WHERE request = @requestID ELSE INSERT INTO ...

"Executing an update/delete query" exception for @NamedQuery doing REMOVE

Hi. The following exception thrown for Spring Batch application: 19:12:40,083 ERROR main AbstractStep:213 - Encountered an error executing the step javax.persistence.TransactionRequiredException: Executing an update/delete query Code,where named query used: entityManagerFactory.createEntityManager() .createNamedQu...

best way to read string into a table in ACCESS

i have a string like this some_string= "something, something2, something3, something4, etc.." i would like to read this string into a table like this: field1 = "something" field2 = "something2" etc what is the best way to do this in vba/sql? ...

SQL query for finding rows with special characters only.

Hi Team, I am working with SQL Server 2005. I need to find out only those rows for which there is a special character in “Body” column. In the following scenario, the result should be only the row with TemplateID = 2. How do we write the query for this? CREATE TABLE #Template (TemplateID INT, Body VARCHAR(100)) INSERT INTO #Template ...

reading into table: comma values and quotes SQL

i have a string like this something = "something, something1, "something2, something else", something3" i need it to be read into a table like this: field1 = "something" field2= "something1" field3 = "something2, something else" field4 = "something3" please notice that the double quotes in the something string signified that the s...

insert values with different delimiter

i want to insert values into a table, with an INSERT INTO statement but i would like to use a different delimiter (not a comma) how do i do this? i dont want to use a comma for the following reason: the data is in this format: |something|somethingelse|something3 ,moretextinsamefield| field1 = "something" field2 = "somethingelse" fiel...

How to create select SQL statement that would produce "merged" dataset from two tables(Oracle DBMS)?

Here's my original question: merging two data sets Unfortunately I omitted some intircacies, that I'd like to elaborate here. So I have two tables events_source_1 and events_source_2 tables. I have to produce the data set from those tables into resultant dataset (that I'd be able to insert into third table, but that's irrelevant). ev...

C# Finisar SQLite DateTime Comparison Problem

My "task" database table look like this: [title] [content] [start_date] [end_date] [...] [...] [01.06.2010 20:10:36] [06.06.2010 20:10:36] [...] [...] [05.06.2010 20:10:36] [06.06.2010 20:10:36] And I want to find only those records that meet the condition that a given day is between start_date and end_date. I've tried the following ...

Composite primary keys in N-M relation or not?

Lets say we have 3 tables (actually I have 2 at the moment, but this example might illustrate the thought better): [Person] ID: int, primary key Name: nvarchar(xx) [Group] ID: int, primary key Name: nvarchar(xx) [Role] ID: int, primary key Name: nvarchar(xx) [PersonGroupRole] Person_ID: int, PRIMARY COMPOSITE OR NOT? Group...

What trace flags are needed for detecting deadlocks

I am trying to get better information on deadlocks that are occurring in my DB. After reading this article, it's still unclear to me whether I should be using trace flag 1204, 1222 or both. ...

Can a sql server aggregate udf be passed in multiple parameters?

I am trying to write an aggregate udf for using Sql Server 2008 and C# 3.5 that implodes an aggregation of data. The kind of syntax I am looking for is: SELECT [dbo].[Implode]([Id], ',') FROM [dbo].[Table] GROUP BY [ForeignID] where the second parameter is the delimiter for the aggregate function. And example return value would be s...

SQL: how to predicate over stored procedure's result sets?

Simple question I couldn't figure out (not a SQL expert... sorry): I want to do a select on the result set of sp_who2. How can I? for ex. select SPID from [result set from sp_who2] ...

iBatis how to solve a more complex N+1 problem

I have a database that is similar to the following: create table Store(storeId) create table Staff(storeId_fk, staff_id, staffName) create table Item(storeId_fk, itme_id, itemName) The Store table is large. And I have create the following java bean public class Store { List<Staff> myStaff List<Item> myItem .... } public...

Nesting, grouping Sqlite syntax?

I can't for the life of me figure out this Sqlite syntax. Our database contains records like: TX, Austin OH, Columbus OH, Columbus TX, Austin OH, Cleveland OH, Dayton OH, Columbus TX, Dallas TX, Houston TX, Austin (State-field and a city-field.) I need output like this: OH: Columbus, Cleveland, Dayton TX: Dallas, Houston, Austin ...

While Loop in TSQL with Sum totals

I have the following TSQL Statement, I am trying to figure out how I can keep getting the results (100 rows at a time), store them in a variable (as I will have to add the totals after each select) and continue to select in a while loop until no more records are found and then return the variable totals to the calling function. SELECT [...

Problem wit MDAC when trying to compile in VS2008 using x64 bit target platform

I am trying to compile an 32 bit application. I am aware of problems with it but that is why its being compiled on 64 bit version. I am hanging at this problem. Application uses lots of sql stuff. In sqltypes.h file: (provided by MDAC) #ifdef _WIN64 typedef INT64 SQLLEN; typedef UINT64 SQLULEN; typedef UINT64 SQLSETP...