sql

Querying Postgresql with a very large result set

In an application I need to query a Postgres DB where I expect tens or even hundreds of millions of rows in the result set. I might do this query once a day, or even more frequently. The query itself is relatively simple, although may involve a few JOINs. My question is: How smart is Postgres with respect to avoiding having to seek ar...

Transfer Data between databases with postgres

I need to transfer some data from another Database. The old database is called paw1.moviesDB and the new database is paw1. The schema of each table are the following Awards (name of the table)(new DB) Id [PK] Serial Award Nominations (name of the table) (old DB) Id [PK] Serial nominations I want to copy the data fr...

What are the reasons *not* to use a GUID for a primary key?

Whenever I design a database I automatically start with an auto-generating GUID primary key for each of my tables (excepting look-up tables) I know I'll never lose sleep over duplicate keys, merging tables, etc. To me it just makes sense philosophically that any given record should be unique across all domains, and that that uniqueness...

Java: Do something on event in SQL Database?

Hello I'm building an application with distributed parts. Meaning, while one part (writer) maybe inserting, updating information to a database, the other part (reader) is reading off and acting on that information. Now, i wish to trigger an action event in the reader and reload information from the DB whenever i insert something from t...

Formating SQL XML-field in gridview

Hi, I have a SQL table with some normal fields and one xml-type field. I need help with formatting the xml-type field. I want to display the the information in a gridview in asp.net but i want to apply formatting to it. Does anyone know how I need to do? Thanks. PS. If it's to any help, I use a linqdatasource as source to my gridview...

Is there something like SqlAlchemy's SqlSoup for Java?

I'm looking for a Java ORM that works from database reflection - I need to just point it at a DB, and start being able to walk through the entire set of tables, etc. Ideas? ...

TSQL, How to get smalldatetime's time between two smalldatetime's times ?

I have Table with two smalldatetime columns, where one is startTime and other one is endTime. I need to select all values from table which between times of both columns compared to getdate()' time. I'm using SQL-Server 2005. example startTime endTime value1 2/2/01 16:00 2/2/01 18:00 1 2/2/01 21:00 2/2/01 22:00 2 2/2/01 05:...

How to apply Containstable for two join tables?

product table pid modelnumber 1 a 2 b 3 c ProductTransation pid name description... 1 ball ball 2 bat cricket bat i create fullText for Modelnumber in product table. Same for name & Description in productTransaction table. Now i want to join this table if i search through modelnumber or name result sh...

Join a single row in one table to n random rows in another

Is it possible to make a join in SQL server that joins each row from table A to n random rows in another? For example, say I have a Customer table, a Product table and an Order table. I want to join each customer to 5 random products and insert these rows into the order table. (And each customer should be joined to 5 random rows of his o...

TSQL, select values from large many-to-many relationship

I have two tables Publishers and Campaigns, both have similar many-to-many relationships with Countries,Regions,Languages and Categories. more info Publisher2Categories has publisherID and categoryID which are foreign keys to publisherID in Publishers and categoryID in Categories which are identity columns. On other side i have Campai...

Sybase: programmatically turn off foreign key checks

Hi, I need to do bulk inserts/updates/deletes on a table-by-table basis via JDBC. Database is Sybase. Because of FK checks, I can't do this, because I temporarily violate integrity. In MySQL I can easily turn off and on constraint checks, by issuing a simple command. Is there some way to do the same in Sybase? Thanks. ...

i want to make condition statement but unsuccessful..

hi i want to make condition statement in my function. i use this method : If String.ReferenceEquals(hotel, hotel) = true Then insertDatabase() Else updateDatabase() End If if i try to insert a data already in the database, the function will directly go to the updateDatabase().. the problem is, if i try to in...

How to connect to remote SQL Server database using Visual C#?

I am creating a Windows forms application and my SQL Server database is on a remote server. How can I connect to it using Visual C# and ADO.NET? ...

Filter rows on the basis of "First Name" + "Last Name" in SQL

Hi, I have a user table in my database which contains two columns FirstName and LastName. Now in my front end there is a textbox to filter out the users from this table. Let's suppose I am taking that input from the front end in the form of a input parameter "@SEARCHKEYWORD". I have created a sample below: DECLARE @Test TABLE ([ID] IN...

Please explain this delete top 100 SQL syntax

Basically I want to do this: delete top( 100 ) from table order by id asc but MS SQL doesn't allow order in this position The common solution seems to be this: DELETE table WHERE id IN(SELECT TOP (100) id FROM table ORDER BY id asc) But I also found this method here: delete table from (select top (100) * from table order by id as...

Shrinking database

I have been tasked to shrink a SQL server 2005 database. This ia a live database and is runing at about 35gb. How do I shrink a database? Can this be done while that database is live? How big will that database bw when it has been shrunk? Thanks in advance. ...

Files and filegroups sql server 2005

Can we move default file to another filegroup. sample code is given below Sample code create database EMPLOYEE ON PRIMARY ( NAME = 'PRIMARY_01', FILENAME = 'C:\METADATA\PRIM01.MDF', SIZE = 5 MB , MAXSIZE =50 MB, FILEGROWTH = 2 MB), ( NAME = 'SECONDARY_02', FILENAME = 'C:\METADATA\SEC02.NDF' ), FILEGROUP EMPLOYEE_dETAILS ( NAME = 'EMP...

What causes SQL Server to return the message 'The statement has been terminated'?

I have a very simple INSERT statement being executed from a PHP script running on a Linux Apache web server. I can run the query fine from within SQL Management Studio and it normally runs fine from PHP as well. However, every once in awhile I get an error message from my PHP script that the query failed and the mssql_get_last_message(...

SQL: ATER COLUMN to shorter CHAR(n) type

I'm working with MS SQL SERVER 2003. I want to change a column in one of my tables to have fewer characters in the entries. This is identical to this question: http://stackoverflow.com/questions/2281336/altering-a-table-column-to-accept-more-characters except for the fact that I want fewer characters instead of more. I have a column i...

Component Properties window - only three things can be seen rather than 20+

Hi All, Trying to edit an SSIS package, when I go to the advanced editor on the update database package I can only see on the component properties page three properties. ID, Name and Description. when my colleague opens this up he can see 20+ options including the SQL option I am needing to be able to edit. Is this an issue with my SQ...