sql

PostgreSql + Escape Enter Key from Query Statement ie Enter Key pressed betweent the data.

Suppose we have a textarea in which we put example string. Textbox contain : Earth is revolving around the Sun. But at the time of saving, I just pressed a enter key after "the sun". Now the statements in texbox :: Earth is revolving around the Sun. Now I am trying to fetch the data but unable just because of that enter key press...

SQL Server date_format

What is the function DATE_FORMAT in SQL Server I want to change my now date to d-m-Y h:i How to do ...

How to enforce unique constraint with LINQ to SQL

Hi, I'd like to enforce a unique constraint on two columns with LINQ to SQL. I have got a constraint configured on a SQL table, but is there a way to use it with LINQ to SQL? Unique constraint is applied to two columns, both of which are foreign keys. Thank you Edit: I could catch exception, that's if a very specific exception gets t...

How can I write this query?

I have this situation in a certain table: id | name 1 'Test' 2 'Test' 3 'Test' How can I make a query to select by distinct the name, but I also need the id column... even if I get the first occorrency of the element... something like, "if the name column repeats, give me the 1st record with this repetition"....

Can a stored procedure work with two different databases? How about two servers?

I am wondering if MySQL's stored procedures can work with two different databases on the same machine? How about if they are on different servers? ...

Help with SQL syntax

I am not very good with sqls and I am trying to understand an sql statement which I haven't seen before. We're using Oracle and the IBatis framework so this might be specific to one of those. I am not really sure. SELECT .... ,.... ,.... , PKG_LABEL.GET_LABEL_NAME('UOM',T100.CASE_DIM_UOM_CODE) AS caseDimensionsUOM , PKG_LABEL.GET_LAB...

SQL - extract time and offset from it

Hi, If I have a DateTime field within a table. How can I extract just the time from the row and then return an offset value. For example, I want to offset against midnight. So if the time is 00:45, I want the value 45. If the time is 23:30 I want the value -30. Thanks. ...

oracle sql: update if exists else insert

Possible Duplicate: Oracle: how to UPSERT (update or insert into a table?) Hi, I have a table in which a record has to be modified if it already exists else a new record has to be inserted. Oracle sql doesnt accept IF EXISTS, otherwise I would have done an if - update - else - insert query. I've looked at MERGE but it only wo...

Create a list of months between two dates in Access

I'm doing things with Microsoft Access. Now i want to make a list of dates between two dates. for example input : 1-1-2010 and 5-1-2010 give me the values. 1-1-2010 2-1-2010 3-1-2010 4-1-2010 5-1-2010 I want to do this in SQL if it's possible, otherwise in VBA. ...

SQL Select all days in a year with 9 blank INT fields

I am trying to get all dates in a year in a SELECT statement with 9 INT fields that have a value of 0 in them. So basically I need the following: 1/1/2007 0 0 0 0 0 0 0 0 0 1/2/2007 0 0 0 0 0 0 0 0 0 1/3/2007 0 0 0 0 0 0 0 0 0 and so on and so on for a whole year. The year is always the 1/1 - 12/31 This is part of a bigger query b...

how to retrieve bulk data from sql without slowing down the server/program

hi i have a program wherein it will retrieve data from sql based on a specific date range.. the problem is when the date range is set to a year or greater than that then the loading of data is so slow that sometimes the program will be not responding. Is there a way avoid this? ...

Remote Maintenance Plans in SQL Server 2008

I've set up a maintenance plan in instance #1 of SQL Server 2008. In theory, it will connect to instance #2 and back up those databases to the hard drive of instance #1. I have: Created a login on instance #2 Given that login the correct permissions needed to back-up a database (I tested it) Created a working connection in the mainte...

postgreSQL select works but delete does not.

I'm trying to change the following query into one that deletes the returned rows. SELECT bad_rows.* FROM votes as bad_rows INNER JOIN( SELECT MIN(id) as min_id, votes.object_id, votes.user_id FROM votes WHERE is_archived=FALSE AND votes.direction < 20 GROUP BY votes.object_id, votes.user_id, votes.content_type_id having COU...

SQL Server data to HTML layout

Hey all, I am trying this code below to be placed into my own HTML layout for export to a PDF. SELECT DISTINCT i.InvoiceNumber as 'Invoice', '$' + CONVERT(varchar(50),round((CONVERT(int,Points) * .1),0)) AS 'Amount', '$' + CONVERT(varchar(50), 1.50) AS 'Fee' FROM tblHGP HGP, OrderDetails OD, tblInvoices i JOIN tblCS cs ON i....

Need help with a complex SQL query - I think I need a two-stage inner join or something like that?

Okay, here's what I'm trying to do. I have a drupal table (term_data) in mysql that lists tags and their ID numbers and a second table, (term_node) that shows the relationship between tags and the data the tags refer to. For example, if node 1 had 3 tags, "A", "B" and "C". term_data might look like this: name tid A 1 B 2 C 3 ...

How can I create a table with a column with 3 only possible given values?

I'm making a SQL database with MySQL. I need a column that has only 3 possible values: "Total" "Hours" "OnDemmand". I mean that user has to select one of these three values, he will can't select another value. How can I do it? ...

ASP.NET MVC2: Database Result Scoring Methodology

One of the projects I am working on is a search engine. This search engine has 36 parameters that can be set to a search within the form, and results are displayed through a series of scoring mechanisms. For example, if you were searching for a desk with a certain width, it would find the desks closest to the desired width and then sor...

SQL UNION on 2 table variables where date is same but other data is not

I have 2 table variable @Data and @DateTable @Data conatains the following: Company Date Type Select Altec 12-1-2010 d 2 Altec 12-1-2010 a 2 Alect 12-3-2010 d 3 @DateTable contains the following: Company Date Type Select Altec 12-1-2010 a 0 Altec ...

Syantax error in SQL statement in VBA of MS Access

I wrote code: str = "INSERT INTO prod_LJ_Completion VALUES (" _ & 0 & ", " & PartID & ", " & cmbLJ_TypeID.value & ", " & isChk(chkLJ_Transformator.value) & ", " _ & isChk(chkLJ_LAD.value) & ", " & txtLJ_KevlarCable.value & ", " & txtLJ_GrayCable.value & ", " _ & txtLJ_WhiteCable.value & ", " & cmbLJ_CylinderTypeID.value & ",...

SQL Table Row Convert to List of Columns

What is the best way to convert a row with columns to a list with rows? In the list, I need one column with the old column name and one column with the old column value. For Example: Current: PersonId | PersonFirstName | PersonLastName | Need: ColumnName | ColumnValue Hope this makes sense. Thanks for any help. ...