sql

How to prevent CAST errors on SSIS ?

Hello, The question Is it possible to ask SSIS to cast a value and return NULL in case the cast is not allowed instead of throwing an error ? My environment I'm using Visual Studio 2005 and Sql Server 2005 on Windows Server 2003. The general context Just in case you're curious, here is my use case. I have to store data coming from ...

sql error while running the jsp pages

when i am running the application it displaying the following error. error is java.sql.SQLException: [Microsoft][ODBC driver for Oracle][Oracle]ORA-00020: maximum number of processes () exceeded at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957) at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114) ...

Sum computed column in Django QuerySet

Given the following Contribution model: class Contribution(models.Model): start_time = models.DateTimeField() end_time = models.DateTimeField(null=True) is it possible, using the Django database API, to reproduce the following SQL statement? SELECT SUM(end_time - start_time) AS total_duration FROM contribution; I've figured...

how to open multiple connections on multiple servers in the same ssms instance using batch file

I have a lot of sql server 2008 servers with many databases on each server. I usually forget which database is on which server. I want to create a batch file named after the name of the database that opens a connection to this database in the currently opened SSMS instance and not in a new instance. ...

How to get number of selected node

CREATE PROCEDURE [dbo].[FlowClientGetNum] (@ID_ListGroupParIzm Integer, @ID_ListParIzm Integer) AS SELECT Number of my @ID_ListParIzm FROM -- sure this string doesn't works -- SELECT C.ID_ListParIzm, FROM CfgListParIzm C WHERE C.ID_ListGroupParIzm = @ID_ListGroupParIzm AND C.VisibleOnTab=1 ORDER BY C...

oracle sql converter CharacterConverter12Byte problem in jdbc

I was working on a simple GUI script yesterday using jdbc in eclipse. When I went to run the program, I got a pop up screen asking me about character conversion in jdbc. I had no idea what this was and neither did my professor (no surprise there). Now every time I run a program, even one that doesn't use SQL I get the same error. 0 - ...

Retreiving names of people who performed a specific action and personalising the message

I have an Actions table that records the actions taken by the users: ActionId, UserId The Actions table holds the name and other details about the action, and Users table similarly holds the name and details about the users. Now, in my application, I want to inform a user about the actions his friends have taken, something like: ...

SQL join problem

I want to retrieve all records from one table when there are no matches in the second table. So it is kind of the opposite of an inner join. ...

Oracle SQL case when for ordering

I have to sort out my data by some column, such that some specific value appears first. So for a query like this ... SELECT rtrim(taskid) into v_taskid FROM tasks where /* some where clausers */ and rownum = 1 ... I have based it on case when, but what bothers me is three nested selects I have now: SELECT rtrim(taskid) ...

How hard would you try to make your SQL queries secure?

I am in a situation where I am given a comma-separated VarChar as input to a stored procedure. I want to do something like this: SELECT * FROM tblMyTable INNER JOIN /*Bunch of inner joins here*/ WHERE ItemID IN ($MyList); However, you can't use a VarChar with the IN statement. There are two ways to get around this problem: (The Wr...

LINQ: Count number of true booleans in multiple columns

I'm using LINQ to SQL to speed up delivery of a project, which it's really helping with. However I'm struggling with a few things I'm used to doing with manual SQL. I have a LINQ collection containing three columns, each containing a boolean value representing whether an e-mail, mobile or address is availble. I want to write a LINQ que...

How can convert 15000000.00 to 15,000,000 in SQL server?

There is a one value 15000000.00 with Numeric datatype in SQL server. How can i get or convert the value 15000000.00 to 15,000,000? ...

SQL Server 2008, join or no join?

Just a small question regarding joins. I have a table with around 30 fields and i was thinking about making a second table to store 10 of those fields. Then i would just join them in with the main data. The 10 fields that i was planning to store in a second table does not get queried directly, it's just some settings for the data in the ...

Help with SQL statement (JOIN)

Hi everyone, I'm having some trouble with an SQL statement that have to find the number of students attending a course. My Database design look likes this: Table Course: id | course_name Table Student: id | name And to connect the two many-to-many relationship I've an table: Table course_student: id | course_id | student_id What I ...

pipelined function

Can someone provide an example of how to use parallel table function in oracle pl/sql. We need to run massive queries for 15 years and combine the result. SELECT * FROM Table(TableFunction(cursor(SELECT * FROM year_table))) ...is what we want effectively. The innermost select will give all the years, and the table function will t...

SQL query to identify completely contained subset

I am scratching my head to figure out a solution to the following question: I have a table with two fields, USER_ID and CLIENT_ID. For each USER_ID there are 1 to n CLIENT_IDs. Let us say that user A is linked to clients 1,2 and 3. I want to construct a query that returns other users that also are linked to all of these clients. They m...

Oracle (Old?) Joins - A tool/script for conversion?

I have been porting oracle selects, and I have been running across a lot of queries like so: SELECT e.last_name, d.department_name FROM employees e, departments d WHERE e.department_id(+) = d.department_id; ...and: SELECT last_name, d.department_id FROM employees e, departments d WHERE e.department_i...

In mysql or postgres, is there a limit to the size of an IN (1,2,n) statement?

I've got quite a few SQL statements like such: SELECT foo FROM things WHERE user_id IN (1,2,3..n) Is there a known limit to the number of elements that will safely fit in an IN clause like that? ...

Summarising (permanently) data in a SQL table

Geetings, Stackers. I have a huge number of data-points in a SQL table, and I want to summarise them in a way reminiscent of RRD. Assuming a table such as ID | ENTITY_ID | SCORE_DATE | SCORE | SOME_OTHER_DATA ----+-----------+------------+-------+----------------- 1 | A00000001 | 01/01/2010 | 100 | some data 2 | A00000002 | 01...

SQL Server 2005 triggers

I created a trigger on a table for updates. If any update happens, I want to store the old value in separate table. I am trying to get the old value from "inserted" table, but this table is not populated with old values after update. Here is the sample code: CREATE TRIGGER [dbo].[Logs_Update] ON [dbo].[Logs] AFTER UPDATE AS DE...