sql

SQL Join Question

Hi All, I will be joining multiple tables all with the same columns, is there anyway so setup the query so the specific table prefix is not needed? Or am I trapped into using select a._id,b._id....z._id ? ...

sql server 2005 .mdf .ldf files

I have those 2 files (.MDF and .LDF) how could i attach them to microsoft sql server in order to see their content ? ...

SQL Design: Big table, thread access serialization.

Hi there. I have one BIG table(90k rows, size cca 60mb) which holds info about free rooms capacities for about 50 hotels. This table has very few updates/inserts per hour. My application sends async requests to this(and joined tables) at max 30 times per sec. When i start 30 threads(with default AppPool class at .NET 3.5 C#) at one tim...

NHibernate to dynamically create/alter/delete tables

I know NHibernate is an ORM and it isn't normally used to create tables but I also know that NHibernate is able to create an entire database given some mappings. I would like to know if there is an obscured API that I could use to dynamically create/alter/delete tables. I could do it with ADO.Net but I would like to abstract the code fo...

PostgreSQL issue with named arguments in a function

PostgreSQL 8.4 on Linux - I have a function - CREATE OR REPLACE FUNCTION production.add_customer ( name varchar(100), email_address varchar(300), street_address text, city varchar(50), state varchar(2), zip varchar(10), secret1 bytea, secret2 bytea, secret3 bytea, secret4 bytea, referrer text) RETURNS integer...

SQL Server: How to order by date, if the date is < GetDate()

Hi, Here's an interesting one... hope I can explain it well... I have a collection of competitions in a single table in my SQL Server DB. I'm doing a full text search over them, which works fine. However, some of the competitions are closed, and I want these closed comps to show up after the open comps, while still respecting the rank ...

How do I Create a Comma-Separated List using a SQL Query?

I have 3 tables called: Applications (id, name) Resources (id, name) ApplicationsResources (id, app_id, resource_id) I want to show on a GUI a table of all resource names. In one cell in each row I would like to list out all of the applications (comma separated) of that resource. So the question is, what is the best way to do this ...

How to get affected rows in previous MySQL operation?

mysql_affected_rows is to get number of affected rows in previous MySQL operation, but I want to get affected rows in previous MySQL operation. For example: update mytable set status=2 where column3="a_variable"; Before this operation, status of some rows is already 2, and I want to get affected rows in previous MySQL operation, you c...

Cumulative average number of records created for specific day of week or date range...

Yeah, so I'm filling out a requirements document for a new client project and they're asking for growth trends and performance expectations calculated from existing data within our database. The best source of data for something like this would be our logs table as we pretty much log every single transaction that occurs within our appli...

SQL Server: How do you remove punctuation from a field?

Hey everyone, Any one know a good way to remove punctuation from a field in SQL Server? I'm thinking UPDATE tblMyTable SET FieldName = REPLACE(REPLACE(REPLACE(FieldName,',',''),'.',''),'''' ,'') but it seems a bit tedious when I intend on removing a large number of different characters for example: !@#$%^&*()<>:" Thanks in advance ...

HQL 'parsename' equivalent

I've discovered PARSENAME function as a good choice to order IP address stored in Database. Here there is an example. My issue is I'm using Hibernate with named queries in a xml mapping file and I am trying to avoid the use of session.createSQLQuery(..) function. I'm wondering if exists any PARSENAME equivalent function for HQL querie...

sql join - only select top row from 2nd table...

Bit of an sql noob, have a list in table a of customercodes/phone numbers, and table b has all the call records. I want to select the most recent call from table b for each of the customercodes/phone numbers in table a. So far I have: SELECT A.CustomerCode, A.PhoneNumber, B.StartTime FROM tableA A INNER JOIN t...

Informix: What happens when you delete a row with serial/serial8 primary key?

I had a quick question on serial data types used on primary key on informix db's. If I delete a row, will the serial key carry on counting or will it re-adjust for any rows that were deleted? So if current row is serial no 5, I delete number row withs serial no 3, will the next value be 6 and keep carrying on? Is serial no 3 that is no...

how can I get data in the table cell that is checked after submit

can someone give me help, please. here's my basic html <form action="addSomething.php" method="POST"> <table> <tr> <th>Add Data</th> <th>Description</th> <th>Quantity</th> </tr> <tr> <td><input type="checkbox" name="data[]" value="sample1" /> </td> <td class="desc">Newbie</td> <td>2</td> </tr> <tr> <td><input type...

How to DROP a version of a Stored Procedure in SQL Server

We have some legacy stored procedures that use the now deprecated feature of SQL Server that allowed you to create multiple versions of a procedure within a procedure. For instance we have.. [up_MyProc] [up_MyProc];2 You can still create these "versions" by appending the version on the end of the name. However without dropping the p...

The query has been canceled because the estimated cost of this query (1660) exceeds the configured threshold of 1500. Contact the system administrator.

"The query has been canceled because the estimated cost of this query (1660) exceeds the configured threshold of 1500. Contact the system administrator." I am getting error as above on live while running one of the stored procedure threads where parameter contain XML variable. I have checked the configuration value of QUERY_GOVERNOR_CO...

How to confirm SQL injection

Is there any way to confirm that a particular breach of security was done through SQL injection? ...

Import and work with an SQL database in Xcode

Hi, A simple question for everyone I think. I just begin to work with database for the Iphone. And so I create my database "external.sql" and I import it into Xcode. I create a simple Navigation Base application and I try to display all from module_category but its not working, told me that the table does not exist. So I try to display...

Hibernate HQL and Date

I have a MySQL table with one of the column type as Date. In my hibernate mapping file I have mapped this column to type java.util.Date. Now in HQL while trying to retrieve objects based on date equality I do not get any results if I set the Date using new Date(). If I normalize the date by setting hours, minutes and seconds to zero I ge...

How to add "weights" to a MySQL table and select random values according to these?

Hello, I want to create a table, with each row containing some sort of weight. Then I want to select random values with the probability equal to (weight of that row)/(weight of all rows). For example, having 5 rows with weights 1,2,3,4,5 out of 1000 I'd get approximately 1/15*1000=67 times first row and so on. The table is to be filled ...