sql

One to One database relation?

In my free time I started writing a small multiplayer game with a database backend. I was looking to separate player login information from other in game information (inventory, stats, and status) and a friend brought up this might not be the best idea. Would it be better to lump everything together in one table? ...

How do I flip a bit in SQL Server?

I'm trying to perform a bitwise NOT in SQL Server. I'd like to do something like this: update foo set Sync = NOT @IsNew Note: I started writing this and found out the answer to my own question before I finished. I still wanted to share with the community, since this piece of documentation was lacking on MSDN (until I added it to the C...

Can I do a find/replace in t-sql?

I basically have an xml column, and I need to find and replace one tag value in each record. ...

Delete all tables in Derby DB

How do i delete all the tables in the schema on Apache Derby DB using JDBC? ...

what does "Total Length of columns in constaint is too long" err mean in Informix?

I get the Total length of columns in constraint is too long. erro from the following sql] Failed to execute: CREATE TABLE GTW_WORKFLOW_MON ( WORKFLOW_NAME VARCHAR(255) NOT NULL, WORKFLOW_LOADED NUMERIC(20) NOT NULL, ACTIVITY_NAME VARCHAR(255) NOT NULL, FLAGS INTEGER NOT NULL, MONITOR_NAME VARCHAR(255) NOT NULL, CLASSNAME VARCHAR(2...

what is the max length of an informix column and can it be increased?

I am trying to create a table with the following CREATE TABLE GTW_WORKFLOW_MON ( WORKFLOW_NAME VARCHAR(255) NOT NULL, WORKFLOW_LOADED NUMERIC(20) NOT NULL, ACTIVITY_NAME VARCHAR(255) NOT NULL, FLAGS INTEGER NOT NULL, MONITOR_NAME VARCHAR(255) NOT NULL, CLASSNAME VARCHAR(255) NOT NULL, STR0 VARCHAR(255), STR1 VARCHAR(255), STR2 VARCHAR(...

SQL Cursors...Any use cases you would defend?

I'll go first. I'm 100% in the set-operations camp. But what happens when the set logic on the entire desired input domain leads to a such a large retrieval that the query slows down significantly, comes to a crawl, or basically takes infinite time? That's one case where I'll use a itty-bitty cursor (or a while loop) of perhaps most d...

Tool: ETL from an ODBC to SQL 05?

I just want a simple tool that will help me quickly write scripts/packages that I can schedule to run. My transform requirements are pretty simple (changing column names, merging/splitting tables, and date conversions). I'll sacrifice flexibility for speed of development on this one. Any come to mind? ...

Is there an agreed ideal schema for tagging

I have a photo website and i want to support tags as my original category bucketing is starting to fail (some pictures are family and vacations, or school and friends). Is there an agreed tagging db schema? I still want to support having photos as part of an album. Right now i have a few tables: Photos PhotoID PhotoAlbumID Captio...

Table Creation DDL from Microsoft Access

Is there any easy way to retrieve table creation DDL from Microsoft Access (2007) or do I have to code it myself using VBA to read the table structure? I have about 30 tables that we are porting to Oracle and it would make life easier if we could create the tables from the Access definitions. ...

NOT IN vs NOT EXISTS

Which of these queries is the faster? NOT EXISTS: SELECT ProductID, ProductName FROM Northwind..Products p WHERE NOT EXISTS (SELECT 1 FROM Northwind..[Order Details] od WHERE p.ProductId = od.ProductId) Or NOT IN: SELECT ProductID, ProductName FROM Northwind..Products p WHERE p.ProductID NOT IN (SELECT ProductID FROM Northwind..[O...

What Oracle driver should I install in my MS SQL server to be able to use DTS to copy data from the Oracle server to the MS SQL server?

Hi, I have an Oracle server (version 9, I believe) and a MS SQL server (version 2000). The MS SQL server is running MS Windows Server 2003. I would like to use DTS to extract some data from the Oracle server and pour it into the MS SQL server. I'm having problems finding out what driver I should install on my MS SQL server for it to b...

SQL Server: Copying column within table

Hi, what is the easiest way to copy the all the values from a column in a table to another column in the same table? ...

How do I get the count of null value columns per row in a return set?

I'm looking for a query which will return me an extra column at the end of my current query which is the count of all columns within the return set which contain a null column. For example: Col 1 - Col 2 - Col 3 A B 0 A NULL 1 NULL NULL 2 Is there a simple way to get this return set based on the row values r...

Ado.net Getting the schema for a table

Given an SQLConnection object how can you get a schema for a single table? I was trying this the other day and I seemed to be able to get the schema from a DataSet which I'd gotten from running a query, but all the schema info I could get from the connection seemed to be related to what tables were available and not the actual details o...

SQL Server Management Studio, getting title bar to show more detail.

I use SQL Server Management Studio 2005(SSMS) for most of my T-SQL and general SQL DB maintenance, but one thing that I would love to change is the level of detail the title bar gives you about each instance of SSMS you have open. I would love to be able to see the connected server from the active tab at the very least. e.g. Any i...

Query showing list of associations in many-to-many relationship

Please note that the same question already has been asked in http://stackoverflow.com/questions/111341/combine-multiple-results-in-a-subquery-into-a-single-comma-separated-value, but the solution involves creating a function. I am asking if there is a way to solve this without having to create a function or a stored procedure. I have ...

Selecting a maximum order number in SQL

I have a table that records a sequence of actions with a field that records the sequence order: user data sequence 1 foo 0 1 bar 1 1 baz 2 2 foo 0 3 bar 0 3 foo 1 Selecting the first item for each user is easy enough with WHERE sequence = '0' but is there a way to selec...

How to find "holes" in a table

I recently inherited a database on which one of the tables has the primary key composed of encoded values (Part1*1000 + Part2). I normalized that column, but I cannot change the old values. So now I have select ID from table order by ID ID 100001 100002 101001 ... I want to find the "holes" in the table (more precisely, the first "hol...

How do I rename a column in a database table using SQL?

If I wish to simply rename a column (not change its type or constraints, just its name) in an SQL database using SQL, how do I do that? Or is it not possible? This is for any database claiming to support SQL, I'm simply looking for an SQL-specific query that will work regardless of actual database implementation. ...