sql

Oracle Date subtraction with SQLLDR

Hi, I am trying to import NetBackup statistics into Oracle. One field I really want is ACTIVE START, but it isn't available from bpdbjobs -report. What is available is ACTIVEELAPSED, so I want to subtract that from the END TIME on import as follows: END TIME Format: 26/09/2009 10:46:20 PM ELAPSED TIME Format: 028:32:35 (which is hours...

mysql subselect alternative

Hi, Lets say I am analyzing how high school sports records affect school attendance. So I have a table in which each row corresponds to a high school basketball game. Each game has an away team id and a home team id (FK to another "team table") and a home score and an away score and a date. I am writing a query that matches attendan...

Char count in sql server

Input: AA1 The output will be: Char Count A 2 1 1 ...

Grouping records with or without a foreign key constraint

I have a table containing objects, something like this: PK ObjectId FK ObjectTypeId Description etc The objects need to be grouped. I have been given a number of suggestions, all of which 'work' and some I like more than others. None of them are perfect so I'm struggling to settle on any particular model. 1/ Add a self-referential ...

SQL Command not properly ended

I am getting the sql command not properly ended when hiting this line below. I want to insert into table A with data from table B. Both of them have the same columns but the sequence might be different. TIA! Insert into a (select column_name from user_tab_columns where table_name = 'B') select * from b I am using pl/sql developer. ...

select top 1 * returns diffrent recordset each time

Hi all, In my application I use SELECT TOP 12 * clause to select top 12 records from database and show it to user. In another case I have to show the same result one by one. So I use SELECT TOP 1 * clause,rest of the query is same. I used Sql row_number() function to select items one by on serially. The problem is SELECT TOP 1 * does...

Post-processing in SQL vs. in code

Hi everbody, I have a general inquiry related to processing rows from a query. In general, I always try to format/process my rows in SQL itself, using numerous CASE WHEN statements to pre-format my db result, limiting rows and filling columns based on other columns. However, you can also opt to just select all your rows and do the post...

Sequence / Identity support in python webframeworks

Currently I'm evaluating web frameworks with an ORM layer and I've stumbled upon an interesting issue. I used tables with an ID column in a JEE (EJB3/JPA) application with different databases. In SAPDB I could define a sequence and use the jpa sequence generator annotation to deal with it, the same way I did on an oracle database previou...

What will be faster among SQL Query many times or getting all once in List and process in loop

I have to process almost 300 records of data with records at a time. I want to know which option would be better. Get all 300 records at a time in a custom object, for example, in C# and process them by in a set of three records based on some key. OR Get 3 records every time from database and do some processing, then fetch next 3 recor...

Program to test a SQL connection string?

I need a free and quick to download program that can test a connection string. Thanks ...

Delete duplicated rows and Update references

How do I Delete duplicated rows in one Table and update References in another table to the remaining row? The duplication only occurs in the name. The Id Columns are Identity columns. Example: Assume we have two tables Doubles and Data. Doubles table ( Id int, Name varchar(50) ) Data Table ( Id int, DoublesId int ) No...

linq to entities - try this one!

Hi Im converting to linq to entities and I am finding problems attempting to convert the stored procs I have created as an overview of data. How do I convert this sql statement to linq to entities: I have a venue table with a child venuerooms table. With the last part I want to get the largest capacity for that venue across all rooms ...

While Using Distinct still getting duplicate values?

Using SQL Server 2000 How to avoid the duplicate values? Query SELECT DISTINCT Modification.dbo.Reference.Dates AS DailyDate, tmp_Cardevent2.PERSONID, tmp_Cardevent2.empname, tmp_cardevent2.cardno, tmp_Cardevent2.titlecode, tmp_Cardevent2.titlename, tmp_Cardevent2.departname, CASE WHEN tm...

How to pass a nullable string to an SP from C#

I have a string property that may or may not be null. I am passing it to the SP using this call: db.AddInParameter(InsertMessageDetailCommand, "MyParam", System.Data.DbType.String, this.myParam); the field is defined in the SP like this: @MyParam nvarchar(50) How can I change the SP to allow for null values, and if param value is...

Access. Alternative for left function

Hi, i am trying to write a query using left function in access to take only the first 3 characters of a field. Is there any alternative method for performing the same process without using left Usage of left function shows a compile. error all of a sudden without any reason. If i copy the table and query to a new database it works fi...

Finding Total Log Size of each DataBase in the SQL Server 2005?

Possible Duplicate: How to find out size of the individual databases in the sql server 2005? How can I get the log size of a database in SQL Server 2005 Due to permission problem ,I am unable to use the command DBCC SQLPERF(logspace),I am unable to view the properties of the database. Please provide me the query or Advise. ...

How to get SQL Server Date in its native format?

I need to get a Date from an SQL Server Database (SQL Server 2000), the date is stored as such: 2009-09-30 00:00:00.000 I want to pass this date into a Classic ASP function to use this date in the Database somewhere else, however when I get the date, it converts in my ASP code to a locale-dependant version, such as: 30/09/2009 I ju...

DATENAME(MONTH,GETADATE()) is returning numeric value of the month as '09'

Hi, When I run the following query [SELECT DATENAME(MONTH,GETDATE())], ideally speaking it should return value as 'September' but its returning value as '09'. I am running this query on MS SQL Server 2005. Is there anything I need to configure with MS SQL Server 2005? Please find the details of the SQL Server 2005 Component Name ...

How to return table from T-SQL Stored Procedure

SQL Newbie here, and I'm having a hell of a time finding what should be a simple code example to answer what I think is a simple question. I need to write a stored procedure that does three things in order: 1) Select rows from one table 2) Update rows in another table, using values from the results table in #1 3) Return the results tabl...

Another simple SQL question

Hello everyone, i have this query and count(artikel.artikelid) returns 2 instead of 3. i know why, because i have the artikelid twice (8135) in the 'where in...' part but i would like it to return 3 here is my problem query: SELECT cg.CategorieGroepID, cg.GroepsNaam, cg.BenodigdAantal, cg.ActieCatI...