sql

What's the MAXIMUM number of records and tables MYSQL supports?

What's the MAXIMUM number of records and tables MYSQL supports? I've just seen a figure of 60,000 tables and 5 billion records but i'm sure it much more than that now? Does anyone know? Also love to see a comparison with other RDBMS's out there? Thank you in advance ;-) ...

Connecting to an external SQL Database from within SharePoint code

I have some event handlers which are tracking list items in my SharePoint lists. I would like to Audit the use of these in an external database (SQL 2005) outside of SharePoint. What is the best practice for doing something like this? I can't find many examples of this being done but it seems like it would be something that is done freq...

How to pass parameter to stored procedure

Hello everyone, I am using SQL Server 2008 Enterprise on Windows Server 2008 Enterprise. In the stored procedure, I need to pass parameter to a select-where-like statement. For example, @department is store procedure input parameter, its type is varchar(20), select * from sometable where somecolumn LIKE '%@department%' but seems m...

Can I reorder SQL selections after the limit has been applied?

I'd like to see the last ten rows from our mysql database in ID order. Naively, I'd expect to be able to do something like this: SELECT * FROM ( SELECT * FROM things ORDER BY id DESC LIMIT 10) ORDER BY id ASC but that isn't valid syntax. What's the correct way of expressing the query I'm trying to run? ...

TSQL Update with inline, grouping and between

Dear Board, I want to update a date from the minmuim start date which occurs bewteen the currentdate and the original date. The SQL I have is: update TableA set [Stop_Date] =DATA.Min_Start FROM TableA JOiN (select min(TableB.START_DTTM ) as Min_Start from TableB where TableB.CancelReason ='...

How to store an array of bytes in Oracle?

Hi, I want to store a short array of 64 bytes in Oracle database (a password hash). I thought char(64 byte) is what I need, but it seems like it doesn't work. In Microsoft SQL, I use binary and varbinary types. What type do I need to use in Oracle? Every example I've found uses blob to store binary data, but I suppose blob is intended ...

What is alternative way to store temp data in a temp table?

Hi All, In our web app, we are creating session table in database to store temporary data. So the temp table will be created and destroyed for every user. I have some 300 users for this web app. So for every user these table will be created and destroyed. i heard that this way of design is not good due to performance issues. I am usin...

update one table using data from another table

I am trying to update my current table by drawing data from another table. My database (dbo_finance) column - test The other database is assestsc and I am going to pull the data from column issuename1, however I only want to pull the issuename1 when the field [MinSecClass] is = 9. This is what I wrote UPDATE dbo_finance SET [dbo_finan...

left join turns into inner join

SELECT a.foo b.bar c.foobar FROM tableOne AS a INNER JOIN tableTwo AS b ON a.pk = b.fk LEFT JOIN tableThree AS c ON b.pk = c.fk WHERE a.foo = 'something' AND c.foobar = 'somethingelse' Having the and clause after the where clause seems to turn the left join into an inner join. The behavior i am seeing is if there isnt 'somethingelse' i...

update multiple records in multiple nested tables in oracle

I have an oracle table with nested tables in some of the columns. Now, I need to be able to update all the records in each nested table, in each of the records of the main table. How is this accomplished? Any of the ways that I've tried, I get errors about either not be able to perform updates on that view, or single row subquery returns...

How do I put textarea data into an SQL Server database?

(This is classic ASP) I'm sure this is just a case of escaping the text, but I haven't found anything yet. I have a textarea that may contain all sorts of characters and I need to UPDATE the record with whatever is in that textarea, but I'm getting an error that breaks my SQL query, which I'm positive is related to the content of the tex...

Database field definitions

Hi, I need to do a data migration from a data base and I'm not too familiar with databases so I would like some clarification. I have some documentation that could apply to either an Oracle or a SQL database and it has a column defined as NUMBER(10,5). I would like to know what this means. I think it means that the number has 10 digits ...

NHibernate dialect for Interbase

Hi all I do a good deal of work with an Interbase server. I would like to develop a data access layer for it using NHibernate but there isn't a readymade dialact for Interbase. Does anyone know, is there an NHibernate dialect which is used for generic ANSI-only database work, or if any of the existing dialects will work okay with Inter...

One-to-Many Table Join?

I have one table (webRooms) which has a number of rows which match those in a second table (Residency). Table 1 looks like this: ID | dorm_building | dorm_room | occupant_num Table 2 looks like this: student_ID | dorm_building | dorm_room What I'd like is to get results like this: ID | dorm_building | dorm_room | o...

Heavily fragmented Indexes - SQL Server 2005

I recently inherited a poorly maintained production database with heavily fragmented indexes (most of the indexes with more than 80% fragmented). I requested downtime with my manager to perform Index rebuild, but unfortunately downtime is not allowed at the moment. If online Index reorganize too is not option, can I do the following? R...

TSQL Merge statement hanging

I currently run the following statement and the query never completes. I am unsure why as I use the same query with other source tables and it completes very quickly, this source table is not bigger. merge into dbo.Tickets_Amends as target using dbo.Tickets_Healthchecks_parentlesstickets as source on (target.fault_ID = source.fa...

SQL Query to get latest user comment per blog post limited to one for each user?

I have multiple users submitting comments on multiple blog posts. Users can comment multiple times on each blog post. I need a SQL Query (sql server 2008) to get the last comment for each User given a BlogPostId. Lets say 3 users submit a total of 10 comments on a specific blog post. For Blog Post #1, User A has submitted 5 comments,...

iBatis error when applying parameter map - Caused by SQLException: Cursor is closed

I am debugging an issue with a null ResultsMap returned from calling a stored procedure via iBatis for java. Here is a truncated copy of the exception I'm receiving. DataAccessException: Exception calling procedure Caused by: com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in ibatis-map.xml. --- The error ...

what is the best possible schema for the following condition?

I need some help in creating the best possible table schema for the following condition. There is a competition where people are allowed to signup in groups. Each group has a groupid, each user has a uid, each group has group specific data like group_question_id etc. A single user can be part of multiple groups. Each user can answer t...

Tying user ids in a table to meaningful values in another table in SQL Server

I have the following table, let's call it People: id | customer | shipper | buyer | 1 | 1 | 2 | 3 | 2 | 4 | 5 | 6 | 3 | 7 | 8 | 9 | And this ties in to a User_ID table: id | Name | 1 | Stan | 2 | Brian | 3 | Amy | What's the best practice f...