sql

Implementing chat system: where to store chat data?

Hello everyone, i am implementing a chat system in asp.net, much like google chat and i use xmhttp to send and receive data, and i am using a single table to store all chat for all user. i wanted to create global temporary tables in sql using a XMLHttpRequest so as to be abl to organise data better(instead of storing all the chat in a ...

preg_replace easy for a pro

i want to find first select ... from and replace that only, following code replace all select..from in sql query, i just need for first select..from preg_replace('#select(.*?)from#is', "select count($expr) as counted from", $sql); ...

How to split a really long mysql result set into two lines?

Suppose you have a result that is 100 chars long but you only have a 50 char width. How do you split a MYSQL result into two rows of 50 chars each? Could you clarify the question a bit? Are you looking to insert 100 chars of data into a 50 char column? Or do you have 100 chars in the database but only have space in your app to display 5...

Determine the size of a SQL result set in KB

I am hoping to find how I can get the kb size of a result set in OracleDB. I am not an sysadmin, but often run queries that return over 100k rows and I would need to find a way to determine what is the total kb size. thank you ...

SQL Server 2008 R2 hemisphere limitation

Does any one know if the limitaition on SQL Server 2008 that a geography cannot be larger than a hemisphere (described here) has been fixed/relaxed in 2008 R2? ...

How can I use a variable from a subquery?

I have this query: (SELECT e.IdEvent,e.EventName,e.EventSubtitle,e.EventDescription,l.LocationName,e.EventVenue,EventStartDate,e.EventEndDate,e.EventHost,c.CategoryName,l.LocationCity,l.LocationState,e.isTBA, (SELECT s.status FROM jos_rsevents_subscriptions s WHERE s.IdUser = 72 AND s.IdEvent = e.IdEvent LIMIT 1) as status FROM jos_rse...

Dynamic create WHERE clause from user Search criteria

I have what I'm sure is a fairly common issue, and I don't want to re-invent the wheel. I have a search form where users can specify search criteria and type of search (AND OR Ext..). The form passes back id's that map to column names and values. Currently, I'm using server side Java to glue the strings together into a where clause. It...

SQL Server 'Resume Next' Equivalent

I'm working on a project in VB.net which takes large text files containing T-SQL and executes them against a local SQL database, but I've hit a problem in regards to error handling. I'm using the following technologies : VB.net Framework 3.5 SQL Express 2005 The SQL I'm trying to execute is mostly straight-forwards but my app is co...

Parse a date from unformatted text in SQL

I'm trying to figure out an elegant way to get a date from a text column that has data like this "YYYYMMDD"...so we might see "20060508" as a value in the column, which I would like to be able to return from a query as a date (May 8, 2006). I'm sure I can hack something together given enough time, but the approaches I'm thinking of seem...

SQL Server Stored Procedure Call in PHP - Can't get xml data it returns back into php

Trying to call an SQL SERVER stored procedure from php. Think I've got it working but I can't get the data it returns back into php. I'm copying my php code and also the sample SQL SERVER code below. Believe my problem is how do get the data back from reportData? mssql_execute() just returns boolean true. Looks to me like the procedure...

Sql Server check case sensitivity?

How can I check to see if an SQL Server is case sensitive? I have previously been running the query: SELECT CASE WHEN 'A' = 'a' THEN 'NOT CASE SENSITIVE' ELSE 'CASE SENSITIVE' END But I am looking for other ways as this has actually given me issues in the past. Edit - A little more info: An existing product has many pre-written Store...

" If condition" as one of the constraints to a Column Field ?

I have a Sales tax column in one of my SQL Table where Data is stored. I was wondering is it possible to place an constraint on the table itself for the Sales Tax Column saying " if > June 2008 tax is 2 % " else "tax is 4 %"? Should that come from stored procs related to that Table? ...

Hibernate subquery

I have a problem in creating subqueries with Hibernate. Unfortunately the Subqueries class is almost entirely undocumented, so I have absolutely no clue how to convert the following SQL into a Hibernate Criteria: SELECT id FROM car_parts WHERE car_id IN ( SELECT id FROM cars WHERE owner_id = 123 ) I was hoping the following would 'jus...

Locking in sqlalchemy

I'm confused about how to concurrently modify a table from several different processes. I've tried using Query.with_lockmode(), but it doesn't seem to be doing what I expect it to do, which would be to prevent two processes from simultaneously querying the same rows. Here's what I've tried: import time from sqlalchemy.orm import session...

BASH - Single quote inside double quote for SQL Where clause

I need to send a properly formatted date comparison WHERE clause to a program on the command line in bash. Once it gets inside the called program, the WHERE clause should be valid for Oracle, and should look exactly like this: highwater>TO_DATE('11-Sep-2009', 'DD-MON-YYYY') The date value is in a variable. I've tried a variety o...

Comparison Query to Compare Two SQL Server Tables

I would like to know how to compare two different database table records. What I mean is I will compare two database tables which may have different column names but same data. But one of them may have more records than the other one so I want to see what the difference is between those two tables. To do that how to write the sql query ?...

is there a way to get all profiles in ASP.NET membership

Is there an API in the ASP.NET membership, implementation to get all user profiles at once. If not, is there another good way to get all the names (first + last) of all the users. I'm trying to avoid the many SQL requests generated by getting the user profiles one at a time. ...

carriage return and line-feeds

'DateM (Monday): ' + ISNULL(@Mon,'')+CHAR(13)+CHAR(10) 'DateT (Tuesday): ' + ISNULL(@Tues,'')+CHAR(13)+CHAR(10) RESULTS: Is not wrapping. DateM (Monday): Sep 8 2009 12:00AM DateT(Tuesday): Sep 9 2009 12:00AM I want it to wrap. DateM (Monday): Sep 8 2009 12:00AM DateT(Tuesday): Sep 9 2009 12:00AM ...

BRACKETS in SQL if conditions

I have a Rate column in one of my SQL Table where Data is stored. The data in the rate column , is coming thro an Stored proc. In that existing stored proc, I found the condition BEGIN IF @taxPrd < '07/01/2000' OR @taxPrd >= '11/01/2001' AND @taxPrd < '04/01/2003' BEGIN I changed it to ...

how to find a value between ranges in sql server

My condition is My query is returning this 2 10 150000 where 2=startingslab and 10 = endingslab 11 20 250000 21 31 150000 now i want to get the price details for startingslab =3. i.e 15000.I know i need to process it row by row as between is not working. Is there any ...