sql

Sybase: create a database from a backup file

Hi there, Using SQL statements (sybase) how can I create or restore a full database given the conpressed backup file (myDatabase.cmp.bak). The reason i'm saying create or restore is that the DB already exists but I can drop it before creating it if that's easier. Do I need to worry about Device files? For example if the backup file us...

SQL Database error

ERROR 1044 (42000) at line 17: Access denied for user 'user'@'117.120.4.172' to database 'bios' Hi, I encounter the following error when I to access my database. What should I do to resolve this issue? ...

Not using Where when Right side is null - problem with left join

I have a query: Select a.Col1,b.Col2 From a Left Join B b ON a.C = b.C Where b.D ='someValue' But when right side is null, I don't get record , so Left Join doesn't work. Do you know how to change this query to correct query ? ...

SQL error stating invalid column name when I have verification if it exists. Why?

There is staging script, which creates new column DOCUMENT_DEFINITION_ID stages it with values of MESSAGE_TYPE_ID + 5 and then removes column MESSAGE_TYPE_ID. First time everything run ok, but when I run script second time I'm getting this error: Invalid column name 'MESSAGE_TYPE_ID'. It makes no sense since, I have verification i...

File not found exception while reading .sql file present in grails-app/conf/sql

Hi, I have an sql query in my controller action (select * from table....where.....et al). This query is fired when the user submits a page. It is a 50 lines code that takes in 3 parameters. For eg: select * from employee where empDate='params.empDt' and empNum=params.empNum order by params.sort asc. In the above case the query tak...

How cen i get a time between two dates when they are not in the same day?

Hello, i was searching in the past questians and couldn't find what i was looking for, In my web app i need to get all the records in order table where the orders where orders in a certian shift: A shift has an openning date only and a record id in shiftTypes. shiftTypes holds the time of start and ending of a shift(implicitly) Now,...

How to write select query for this?

I have column COMPONENT_AMOUNT(money) ,MONTH_FOR(int), YEAR_FOR(int) and COMPONENT_TYPE(int). I want to find the sum of amount according to condition. I have written my query like this but it solve my purpose. My purpose is that if one select Nov-2010 then it will sum the amount up to this selected month including all the month of 2009....

SQL Server query with null value

In my C# code, I have to do an SQL Query like this : context.ExecuteStoreQuery("SELECT * FROM MyTable WHERE Field0 = {0} AND Field1 = {1}", field0, field1) When field1 = null in c# and NULL in database this query doesn't work. (I have to use a different syntax with IS NULL) How can I correct this without make an if (in reality, ...

split string unless enclosed betwen other strings

Hi all, I know this question have been asked endless times but I can't find a working solution for my case. I want to split a string in PHP (5.3) using semicolons as delimiters unless they are between $BODY$ strings. The goal is to split SQL statements where statements can be procedures (postgresql in this case). Example: select; st...

Any SVN like database solutions\librarys which are opensource and work OK with Java?

I want to have my DB server opensource and capable of saving hystory of record changing. Meaning I do not want it to be way 2 complicated , I'd love to operate with it like with JDOs but with some kind of revision extention... or SQL like DB with extended sintax and search capabiletis... So is out there any such? ...

SQL Server multiple many-to-many join query

I currently have a one main table with multiple other tables associated with it via many-to-many joins (with join tables). The application using this database needs to have search functionality that will print out multiple rows matching specific criteria, including all the values in the join tables. The values from the join tables also n...

SELECT with multiple subqueries to same table

I'm using the same SQL pattern over and over, and I know there has to be a better way, but I'm having trouble piecing it together. Here's a simple version of the pattern, where I'm pulling back the student's information and the last book they checked out, if one exists: SELECT TStudents.*, BookName = (SELECT TOP 1 BookName ...

Select statement using 2 tables returns 4million reocrds instead of 500k

I created a small mapping table to associate values with values from another table. When I perform the select I get back 4million reocrds~. I know it has to be something trivial I'm doing. Would appreciate if someone could A) Tell me what I'm doing wrong and B) Tell me what literature I should be reading so I understand these issues :)...

Writing an inheritance query written in SQL using an inner join?

I confess that my knowledge of SQL (using mySQL) extends little beyond the standard queries required for database management, and that the majority of my data manipulation has been done through php. I have been keen to change that, and have enjoyed success until now, and would appreciate it if someone could advise me on how I create a s...

SQL Event Notification vs. WMI

What is the preferred or best practice when creating alerts for database mirroring state changes, e.g. Event Notification, WMI, etc.? Does one have an advantage over the other, e.g. performance, etc? ...

SQL select latest record revisions in one of three language supplied in order of preference.

So, I've got a table structure in SQL Server 2005 that has the following composite primary keys: Id int Culture char(5) (eg: en-US, en-GB etc...) Created datetime The User table has PrimaryCulture and SecondaryCulture columns representing the users language preferences. The Application table contains a single Culture column represent...

Why doesn't this specific syntax work for upserting?

Hello, I'm using SQL Server 2005 and I want to synchronize two tables which have the same definition but exist in different databases. MERGE INTO only exists in 2008 and I'd prefer a syntax where I don't have to specify columns in the UPDATE. So I stumbled upon various posts using the following syntax: UPDATE Destination FROM (Source I...

Anyone know of a tool to convert SSRS (RDL) reports to Crystal Reports (RPT)?

I'm looking for a tool that will assist in the conversion from SSRS to Crystal. I've found numerous tools that will go the other way (From Crystal to SSRS), but none that will work for my specific need. ...

SQL Server: Howto get foreign key reference from information_schema ?

In SQL Server, how can I get the referenced table + column name from a foreign key? Note: Not the table/column where the key is in, but the key it refers to. Example: When the key [FA_MDT_ID] in table [T_ALV_Ref_FilterDisplay]. refers to [T_AP_Ref_Customer].[MDT_ID] such as when creating a constraint like this: ALTER TABLE [dbo].[T_...

MySQL time between days

I have an application storing the times a restaurant is open: My code to get the currently open restaurants. My SQL query (simplified) looks like SELECT * FROM `restaurants` r WHERE r.from <= NOW() AND r.to >= NOW(); The problem here is, there's an entry which rolls over -- it's for a restaurant open from 11 AM to 3 AM the ...