sql

SQL Server Query Question

Running SQL Server 2008, and I am definitely a new SQL user. I have a table that has 4 columns: EmpNum, User, Action, Updatetime A user logs into, and out of a system, it is registered in the database. For example, if user1 logs into the system, then out 5 minutes later, a simple query (select * from update) would look like: EmpNum...

PL/SQL function while executing throws Out Process Memory Error

I have PL/SQL function, which is programmed to sort a set of data. This function work fine without any error, when called directly as a PL/SQL Function. However, when I call this Function Via a Unix Shell Script, even though the script returns a success code and throws an Out Process Memory Error and function is actually not executed. ...

SQl count() help with a select statement

HI im using this code SELECT MACH_NO, COUNT(MACH_NO) AS TOTAL_REPORTS FROM MAINTENANCE_LOG GROUP BY MACH_NO; to retrieve some data which gives MACH_NO TOTAL_REPORTS 1 4 5 2 8 1 7 1 now how can i retrieve only where total reports is bigger than three? I TRIED WHE...

Sorting tree with other column in SQL Server 2008

Hi, I have a table which implements a tree using hierarchyid column Sample data: People \ Girls \1\ Zoey \1\1\ Kate \1\2\ Monica \1\3\ Boys \2\ Mark \2\1\ David \2\2\ This is the order using hierarchyid column as sort column I ...

select distinct over specific columns

A query in a system I maintain returns QID AID DATA 1 2 x 1 2 y 5 6 t As per a new requirement, I do not want the (QID, AID)=(1,2) pair to be repeated. We also dont care what value is selected from "data" column. either x or y will do. What I have done is to enclose the original query like this SELECT * FROM (<original ...

Add command's paramter for jobs with SqlServer 2008

Hi, Is it possible to add command line parameters for a program in an SQL Server job ? We can add a specific job to execute a command line program in C#, with one parameter. but we have an error when we are specifying a second... Any idea ? Thanks for your help. ...

Is it possible to query a XML file with SQL?

Currently I'm working on a case where we don't want to change to much on a c#/wpf program, but like to add a feature. Currently we allow certain users to add sql queries to a database to retrieve customer data, hereby a custom connection string/ provider name must be specified. With this information it's possible to create the connection...

How can I combine result and subquery for IN comparison (mysql)

In order for a school project i need to create the following situation within one mysql query. The situation is as such, that a child's tags and a parent's tags need to be combined into one, and compared to a site's tags, depending on a few extra simple equals to lines. For this to happen I only see the option that the result of a subq...

SQL join to grab data from same table via intermediate table

Hi Could someone help me with building the following query. I have a table called Sites, and one called Site_H. The two are joined by a foreign key relationship on page_id. So the Sites table contains pages, and the Site_H table shows which pages any given page is a child of by having another foreign key relation back to the site table ...

What is the maximum length of a string parameter to Stored procedure?

I have a string of length 1,44,000 which has to be passed as a parameter to a stored procedure which is a select query on a table. When a give this is in a query (in c# ) its working fine. But when i pass it as a parameter to stored procedure its not working. Here is my stored procedure where in i have declared this parameter as NVARCHA...

what's wrong in this sql?

select id from dm_unit where aa like '%'||?||'%' ...

Convert sql query

I have used this query in sql,pls convert this query to use for access database. Table structure is UserID,Username,LogDate,LogTime WITH [TableWithRowId] as (SELECT ROW_NUMBER() OVER(ORDER BY UserId,LogDate,LogTime) RowId, * FROM @YourTable), [OddRows] as (SELECT * FROM [TableWithRowId] WHERE rowid % 2 = 1), ...

SQL Server 2005: Invalid object name exception

In VS2005, I am using a DLL which accesses a SQL Server. The DLL returns a SQLException Invalid object name 'tableXYZ' but tableXYZ is a table in the database. Should it be looking for dbo.tableXYZ instead? Is this a permissions issue with the login being used? ...

Little Employee/Shift timetable HELP!!!

Morning Guys, I have the following tables: operator(ope_id, ope_name) ope_shift(ope_id, shift_id, shift_date) shift(shift_id, shift_start, shift_end) here is a better view of the data http://latinunit.net/emp_shift.txt here is the screenshot of a select statement to the tables http://img256.imageshack.us/img256/4013/opeshift.jpg...

How to export into word format using Reporting Services (SSRS)

Using Reporting services in SQL Server 2005 in asp.net with c#, how can we export reports in word document? Thanks In Advance.!! ...

MySQL ORDER BY offset

In a MySQL query how would I select: all rows, ordered by column name those with name > 'f' should come first, then the rest alphabetically so I'd get G, H, …, X, Y, Z, A, B, C …, F. ...

Hibernate - controlling Insert and Update Queries

Consider the following association Book has OneToMany Chapters If i execute: session.save(book) session.save(chapter) session.getTransaction().commit() Hibernate generates insert query for Book and insert query for Chapter But if i execute: session.save(chapter) session.save(book) session.getTransaction().commit() Hibernate execu...

Export view data programmatically in Access/SQL Server

We have an Access application front-end connected to a SQL Server 2000 database. We would like to be able to programmatically export the results of some views to whatever format we can (ideally Excel, but CSV / tab delimited is fine). Up until now we've just hit F11, opened up the view, and hit File->Save As, but we're starting to get re...

Using variable from Code-behind in SQL Query, asp.net C#

I am trying to use a variable from the code-behind page in a sqlDataSource WHERE statement. I am using Membership.GetUser().ProviderUserKey to obtain the UserId of the logged in user and I would like to only show record that have this UserId as a foreign key. How can I write the SQL for this? Thanks much, Carl Here is what I have so fa...

Creating a SQL update query based on multiple columns and records in same table

I have got a table which contains 5 column and query requirements: update row no 8 (or id=8) set its column 2, column 3's value from id 9th column 2, column 3 value. means all value of column 2, 3 should be shifted to column 2, 3 of upper row (start from row no 8) and value of last row's 2, 3 will be null For example, wit...