sql

SQL Server 2008: How to find trailing spaces

How can I find all column values in a column which have trailing spaces? For leading spaces it would simply be select col from table where substring(col,1,1) = ' '; ...

Using .net Datetime in sql query

I have a DateTime object I want to compare against an sql datetime field in a where clause. I'm currently using: "where (convert( dateTime, '" & datetimeVariable.ToString & "',103) <= DatetimeField)" But I believe datetimeVariable.ToString will return a different value depending on the culture where the system is running. How would ...

How to export data with sql developer?

Hi, How to export oracle DB data with sql developer? I need all data, tables, constrains, structure and so on. Thanks ...

Translate SQL query to LINQ

THIS USER HAS ALREADY ASKED THE EXACT DUPLICATE A FEW MINUTES AGO http://stackoverflow.com/questions/2552190/sql-and-linq-query PhotoAlbums table AlbumID Title Date Photos table: PhotoID Title Date AlbumID SELECT AlbumID, Title, Date, (SELECT TOP (1) PhotoID FROM P...

How do I retrieve 10 days data up to date 'XYZ' from mysql with Perl when some days data are missing, i.e. public holidays.

Data is put into a MYSQL DB in the following format: | 2010-03-18 | 1.580 | 1.590 | 1.560 | 1.580 | 164500 | 1.580 | | 2010-03-19 | 1.570 | 1.570 | 1.560 | 1.570 | 178300 | 1.570 | | 2010-03-22 | 1.550 | 1.560 | 1.540 | 1.560 | 309000 | 1.560 | | 2010-03-23 | 1.560 | 1.560 | 1.550 | 1.550 | 284900 | 1.550 | I need to se...

Explanation of this SQL sanitization code

I got this from for a login form tutorial: function sanitize($securitystring) { $securitystring = @trim($str); if(get_magic_quotes_gpc()) { $securitystring = stripslashes($str); } return mysql_real_escape_string($securitystring); } Could some one explain exactly what this does? I know th...

How to check if object is sql to linq type

Hi, anyone know if there's any easy way to check if an object is an sql to linq type? I have a method like this but would like it to only accept valid types. public static void Update(params object[] items) { using (TheDataContext dc = new TheDataContext()) { System.Data.Linq.ITable table; if(items.Length > 0) ...

Need to speed up the results of this SQL statement. Any advice?

I've got the following SQL Statement that needs some major speed up. The problem is I need to search on two fields, where each of them is calling several sub-selects. Is there a way to join the two fields together so I call the sub-selects only once? SELECT billyr, billno, propacct, vinid, taxpaid, duedate, datepif, propdesc FROM trcd...

How do I do a semijoin using SQLAlchemy?

http://en.wikipedia.org/wiki/Relational_algebra#Semijoin Let's say that I have two tables: A and B. I want to make a query that would work similarly to the following SQL statement using the SQLAlchemy orm: SELECT A.* FROM A, B WHERE A.id = B.id AND B.type = 'some type'; The thing is that I'm trying to separate out A and B's logic i...

joining tables while keeping the Null values

I have two tables: Users: ID, first_name, last_name Networks: user_id, friend_id, status I want to select all values from the users table but I want to display the status of specific user (say with id=2) while keeping the other ones as NULL. For instance: If I have users: ? first_name last_name ------------------------ 1 John ...

mysql select from a table depending on in which table the data is in

I have 3 tables holding products for a restaurant. Products that reside in the bar, food and ingredients. I use php and mysql. I have another table that holds information about the orders that have been made so far. There are 2 fields, the most important ones, that hold information about the id of the product and the type (from the bar,...

Multi-statement Table Valued Function vs Inline Table Valued Function

A few examples to show, just incase: Inline Table Valued CREATE FUNCTION MyNS.GetUnshippedOrders() RETURNS TABLE AS RETURN SELECT a.SaleId, a.CustomerID, b.Qty FROM Sales.Sales a INNER JOIN Sales.SaleDetail b ON a.SaleId = b.SaleId INNER JOIN Production.Product c ON b.ProductID = c.ProductID WHERE a.ShipDate IS...

how to do a select * in jython and get the result

Hi everyone, how to do a select * from table in jython and get the result for each row into a list or string. i know how to do for select counmn_name1 ,column_name2 from table1 but not able to figure out for select * Please suggest .thanks ...

WPF/.NET data access models - resource recommendations

We're in the early design/prep phases of transferring/updating a rather large "legacy" 3 tier client-server app to a new version. We’re looking at doing WPF over Winforms as it appears to be the direction Microsoft is pushing development of the future and we’d like the maximize the life cycle/span of the apps. That said during the rewri...

One on One table relation - is it harmful to keep relation in both tables?

I have 2 tables that their rows have one on one relation.. For you to understand the situation, suppose there is one table with user informations and there is another table that contains a very specific informations and each user can only link to one these specific kind of informations ( suppose second table as characters ) And that cha...

Need help tuning a SQL statement

I've got a table that has two fields (custno and custno2) that need to be searched from a query. I didn't design this table, so don't scream at me. :-) I need to find all records where either the custno or custno2 matches the value returned from a query on the same table based on a titleno. In other words, the user types in 1234 for th...

MySQL SUM Query daily values of a week problem

Am trying to return the sum of each day of a week in mysql but it returns nothing despite having values for the 3rd Week of March 2010 SELECT SUM(expense_details_amount) AS total FROM expense_details WHERE YEAR(expense_details_date) = '2010' AND MONTH(expense_details_date) = '03' AND WEEK(expense_details_date) ...

Windows 7 64 Bit - ODBC32 - Legacy App Problem

Good day StackOverFlowlers, I´m a little stuck (really stuck) with an issue with a legacy application on my organization. I have a Windows 7 Enterprise 64 Bit machine, Access 2000 Installed and the Legacy App (Is built with something like VB but older) The App uses System ODBC in order to connect to a SQL 2000 DataBase on a Remote Serv...

Dynamic SQL to generate column names?

I have a query where I'm trying pivot row values into column names and currently I'm using SUM(Case...) As 'ColumnName' statements, like so: SELECT SKU1, SUM(Case When Sku2=157 Then Quantity Else 0 End) As '157', SUM(Case When Sku2=158 Then Quantity Else 0 End) As '158', SUM(Case When Sku2=167 Then Quantity Else 0 End) As '167' FROM Ord...

How can I set a Microsoft SQL field as identity but to START with a certain number?

Pretty newbie question. Thanks for helping. ...