sql

Subqueries in linq

Hello, I've been trying for a couple of days to write to "translate" this query in LINQ with no success so far. Could you guys please help me? I would also appreciate some explanation to learn actually something out of it. Here is the T-SQL query: SELECT R.ResourceID, R.DefaultValue FROM Resources as R JOIN (SELECT [t0].[NameResou...

mysql/php: keeping an extra record while paging

I have a list of records that I want to page through using LIMIT however the first record that is returned without LIMIT is also the root identifier for the rest of the records and I need to keep it for every page. Is this possible? (I would just prefer not to run a extra sql statement) id | index | title 1 | 0 | index of t...

Oracle: How do I convert hex to decimal in Oracle SQL?

How do I convert hexadecimal to decimal (and back again) using Oracle SQL? ...

SQL query to linked index server does not work w wildcards

Hello folks, this statement I use in a sproc (where the search phrase 'reiseportal*' is a parameter) does not work with a wildcard, as I recognized: DECLARE @strSQL NVARCHAR(MAX) SELECT @strSQL= 'SELECT FileName, path, size, vpath from "GRIP-SERVER"."Web2"..SCOPE() where contains ('SELECT @strSQL=@strSQL + CHAR(39) + CHAR(39)+ 'reise...

Sine curve on graph - SQL

Hi, Im trying to create a easy sine curv in SQL which alternates between the values (0-23). I have the following variables: x, which is the current offset. y which is the destinated offset, and z which is my max value(23). Anyone that could help me with the expression? Have googled and read about it, but havent got it to work yet.. W...

Retrieve last (latest) distinct highest value

I want to retrieve the most recent requestid from table tblquoteproposal` for perticular customerId here 3, in this example ID 2 & ID 4. table tblrequest requestid Customerid 6 2 7 4 8 3 9 3 Table tblquoteproposal id requestid QuotePraposalLink comment 1 6 ...

Create table from existing DataTable/Dataset data with ADO.net ?

I need to create two tables. The first one I can get via database with a command. No sweat. The second one is built from the first one with nested SELECT statements, JOINs, and operators like SUM, AVG etc. So it needs more functionality than filtering and sorting. It is done in C# with .NET 2.0, so no advanced features available. Ess...

SQL - Combine two tables for one output

Say I have two tables: KnownHours: ChargeNum CategoryID Month Hours 111111 1 2/1/09 10 111111 1 3/1/09 30 111111 1 4/1/09 50 222222 1 3/1/09 40 111111 2 4/1/09 50 UnknownHours: ChargeNum Month Hours 111111 2/1/09 ...

How can I have my Postgresql SELECT return data from columns with the same name?

In a SELECT call we are returning two different timestamps, but because each column is each called 'timetag' we cannot differentiate between them in the results. The obvious solution of renaming one of the columns will result in a large amount of refactoring which we want to avoid. Our query looks something like this: DECLARE p_cur...

Return another value when row is inexistent

Hello, In a database table with a structure like this : Table 1 Name | Id A 1 B 2 Table 2 Table1's ID | IntValue 1 11 2 66 now, there is a query which joins the 2 tables and outputs something like A | 11 B | 66 but the problem is that when, let's say row (A,1) gets deleted from table1 the...

How do I search a NTEXT column for XML attributes and update the values? MS SQL 2005

Duplicate: this exact question was asked by the same author in http://stackoverflow.com/questions/1221583/how-do-i-update-a-xml-string-in-an-ntext-column-in-sql-server. Please close this one and answer in the original question. I have a SQL table with 2 columns. ID(int) and Value(ntext) The value rows have all sorts of xml strings in...

Portable SQL to determine if a table exists or not?

Is there a portable way of determining if a database table already exists or not? ...

Tricky SQL-aggregate query with DateTimes

I have the following DataTable (counting hours of work): start | end | time -----------------+------------------+------------------ 2009-05-01 08:00 | 2009-05-01 10:00 | 2009-05-01 02:00 2009-05-02 07:30 | 2009-05-02 11:00 | 2009-05-02 03:30 2009-05-03 23:00 | 2009-05-04 02:00 | 2009-05-03 03:00 There's a ...

Read UTF8(XML) Data from SQL Server 2005 the most efficient way

I want to read lots of data(single column nvarchar(max)) from SQL Server 2005 and deserialize it to an object. We are currently using the following, but this is not fast enough is there a better/efficient way to do it? using(MemoryStream stream = Encoding.UTF8.GetBytes((string)cmd.ExecuteScalar())) { XmlTextReader xmlReader; DataCon...

Sql statement teaser...

ok so this is what I am trying to achieve is to have two SELECT statements and then join results of each so I have something like this SELECT table.ID, tst.Value FROM blah AS table JOIN results AS tst ON tst.RUNID = table.RUNID WHERE table.RUNID IN ( ...// nothing important but in the end i get my tst.Value ) second statement is ...

LEFT JOIN using OR

I was wondering how I would return the result of the left most condition in a OR clause used in a LEFT JOIN if both evaluate to be true. The solutions I've come upon thus far both involve using CASE statement in the SELECT, this does mean I'd abandon the OR clause. The other solution involved using a CASE statement in an ORDER BY. Is ...

Insert array with PostgreSQL ECPG

I am using ECPG with PostgreSQL 8.4. I have a function which takes a struct containing pointers to a couple of dynamically allocated, "null"-terminated arrays of integers (I have defined null in this case to be -1, as there is no need for negative values, as in #define INT_ARR_NULL -1 struct foobar { int * foo; int * bar; }; v...

SQL query result in a string (or variable)

Is it possible to output SQL query result in one string or variable? (i'm bad in php and mysql) Let's say I have db "agents" with columns - agent_id, agent_fname, agent_lname, agent_dept. Using this query: $sql = SELECT a.`agent_fname` FROM agents a WHERE a.`agent_dept` = 'FCA' I want to get a string or a variable, so I can use it in...

Displaying totals within a specified date range in Microsoft Access

Although I have experience with SQL and generating HTML reports with PHP, I'm a relative beginner with Microsoft Access. I'm currently using Microsoft Access 2007 to connect to MSSQL Server 2005. I have a table of Reports that looks something like this: ReportID DateCreated Author ... I'd like to create a form that allows the user t...

How to join tables together on columns with different datatypes?

A Microsoft Access implementation is throwing a type mismatch error while trying to execute a macro that opens up some queries. Most of the tables are linked to a SQL Server and I need to join two of the tables together that have different datatypes. Table A: REFERENCE TEXT Table B: REFNO NUMBER I would ordinarily want to correct the...