sql

Paging SQL Server 2005 Results

How do I page results in SQL Server 2005? I SQL Server 2000, there was no reliable way todo this but I'm now wondering if SQL Server 2005 has any built in method. What I mean by paging is, for example, if I list users by their username, I want to be able to only return the first 10 records, then the next 10 records and so on. Any help...

Sql query, count and group by

if i have data like this: Key Name1 Dan2 Tom3 Jon4 Tom 5 Sam6 Dan What is the sql query to bring back the records where the Name is repeated 2 or more times. So the result i would want is Tom Dan...

Timer-based event triggers

I am currently working on a project with specific requirements. A brief overview of these are as follows: Data is retrieved from external webservices Data is stored in SQL 2005 Data is manipulated via a web GUI The windows service that communicates with the web services has no coupling with our internal web UI, except via the database....

Sql to query a dbs scheme

In SqlServer. How do you query a db to bring back all the tables that have a field of a specific name? ...

Backup SQL Schema Only?

I need to create a backup of a SQL Server 2005 Database that's only the structure...no records, just the schema. Is there any way to do this? EDIT: I'm trying to create a backup file to use with old processes, so a script wouldn't work for my purposes, sorry...

SQL: Distribution of table in time

I have a MySQL table with approximately 3000 rows per user. One of the columns is a datetime field, which is mutable, so the rows aren't in chronological order. I'd like to visualize the time distribution in a chart, so I need a number of individual datapoints. 20 datapoints would be enough. I could do this: select timefield from entr...

What program can I use to generate diagrams of SQL view/table structure?

I've been tasked with redesigning part of a ms-sql database structure which currently involves a lot of views, some of which contain joins to other views. Anyway, I wonder if anyone here could recommend a utility to automatically generate diagrams to help me visualise the whole structure. What's the best program you've used for such p...

Is there any trick that allows to use Management Studio's (ver. 2008) IntelliSense feature with earlier versions of SQL Server?

New version of Management Studio (i.e. the one that ships with SQL Server 2008) finally has a Transact-SQL IntelliSense feature. However, out-of-the-box it only works with SQL Server 2008 instances. Is there some workaround for this? ...

SQL Case Statement Syntax?

What is the full correct syntax for the SQL Case statement? ...

What point should someone decide to switch Database Systems

When developing whether its Web or Desktop at which point should a developer switch from SQLite, Mysql, MSSql, etc, etc...

How should I organize my master ddl script.

I am currently creating a master ddl for our database. Historically we have used backup/restore to version our database, and not maintained any ddl scripts. The schema is quite large. My current thinking: Break script into parts (possibly in separate scripts): table creation add indexes add triggers add constraints Each script wo...

Firebird's SQL's Substring function not working

I created a view on a machine using the substring function from Firebird, and it worked. When I copied the database to a different machine, the view was broken. This is the way I used it: SELECT SUBSTRING(field FROM 5 FOR 15) FROM table; And this is the output on the machine that does not accept the function: token unknown: FROM B...

Inheritance in database?

Is there any way to use inheritance in database (Specifically in SQL Server 2005)? Suppose I have few field like CreatedOn, CreatedBy which I want to add on all of my entities. I looking for an alternative way instead of adding these fields to every table....

SQL Server 2000/5 Escape an Underscore

How do I escape the underscore character? I am writing something like the following where clause and want to be able to find actual entries with _d at the end. Where Username Like '%_d'...

Multiple foreign keys?

I've got a table that is supposed to track days and costs for shipping product from one vendor to another. We (brilliantly :p) stored both the shipping vendors (FedEx, UPS) with the product handling vendors (Think... Dunder Mifflin) in a "VENDOR" table. So, I have three columns in my SHIPPING_DETAILS table that all reference VENDOR.no. F...

how to pass a comma separated list to a stored procedure?

So I have a Sybase stored proc that takes 1 parameter that's a comma separated list of strings and runs a query with in in an IN() clause: CREATE PROCEDURE getSomething @keyList varchar(4096) AS SELECT * FROM mytbl WHERE name IN (@keyList) How do I call my stored proc with more than 1 value in the list? So far I've tried exec getSom...

Learning SQL

I am a software engineer and I work for a small company, which means I have to do just about everything myself. So what is the best way to learn absolutely everything you need to know about SQL? Everything from the language, to managing databases, to programming to a database with C# 2.0 and what what version to use (free for commercial ...

What's the best way of converting a mysql database to a sqlite one?

I currently have a relatively small (4 or 5 tables, 5000 rows) MySQL database that I would like to convert to an sqlite database. As I'd potentially have to do this more than once, I'd be grateful if anyone could recommend any useful tools, or at least any easily-replicated method. (I have complete admin access to the database/machines...

Dropping a group of tables in SQL Server

Is there a simple way to drop a group of interrelated tables in SQL Server? Ideally I'd like to avoid having to worry about what order they're being dropped in since I know the entire group will be gone by the end of the process. ...

SQL Server Recovery States

When restoring a SQL Server Database, I notice that there are 3 different Recovery States to choose from: Restore with Recovery Restore with No Recovery Restore with Standby I've always left it at it's default value, but what do they all mean? (Preferably in layman's terms) ...