The Alagad Technical Team Blog

Entries Tagged as 'SQL'

Oracle Thin Client and 'ROWID' Wierdness

Published By: Scott Stroz on Oct 1, 2009 at 07:15 AM
Categories: ColdFusion , SQL

Be careful when using the Oracle Thin Client JDBC drivers - they behave a little differently than the Oracle JDBC drivers that are shipped with ColdFusion Enterprise and Developer Editions.

View Full Entry | 0 Comments

 

Sproc to Cascade Deletes In SQL Server

Published By: Doug Hughes on Feb 19, 2009 at 04:02 PM
Categories: SQL

As a developer, from time to time you need to delete an record out of a database.  And, if that record has a number of tables that refer to it by foreign key (and heaven forbid those tables are themselves referenced), deleting a single row can be quite a headache.  This wouldn't be so bad if your foreign keys were set to cascade deletes, but they rarely are.  In these cases you're pretty much stuck writing a lot of SQL to delete one single record.

For situations like this I've created a stored procedure which will automatically cascade delete records for you.  Here's the complete sproc:

View Full Entry | 6 Comments

 

Delete Almost Everything From Your MSSQL Database

Published By: Doug Hughes on Sep 18, 2008 at 08:22 PM
Categories: SQL

Ok, this script is dangerous. Use it only when you intend to. If you delete stuff you don't want to, it's your problem! 

Anyhow, now that we're past the disclaimer, I'm posting this blog entry as a follow up to one Layne Vincent posted earlier this week on how to truncate most of your tables.  As it were, we are currently working on a project where pretty much everything related to the database is scripted.  We have a script we generate that will completely rebuild our database including all of it's tables, stored procedures, functions, basic lookup data etc.  The problem is, although the script has a chunk of code at the beginning to drop tables, the script takes no account of foreign key constraints and these drops simply don't work.  Besides, we also have a lot more than just tables we may want to drop.

View Full Entry | 6 Comments

 

Truncate Most of the Tables

Published By: Layne Vincent on Sep 16, 2008 at 08:30 PM
Categories: Alagad , SQL

Recently I was in need of a script for SQL Server 2005 that would go in and truncate all of my tables in a given database. Not too tall an order one would think. Just write the darn thing and off you go. Not so fast, Bucko. What about those pesky foreign-keys? What about tables I don't want truncated? What about the tedium in putting this thing together?

Well, after Googling and Googling and Googling some more I found this little jewel written by pvsramu in a forum entry over at SQLTeam.com. I thought I had found the answer...and I did, almost.

View Full Entry | 3 Comments

 

How To Make a Backup Plan for SQL Server 2005

Published By: Doug Hughes on Sep 15, 2008 at 07:55 AM
Categories: SQL

Over the weekend I received a question from a blog reader asking how to create a backup script for SQL server.  Rather than answering this in email I thought I'd share this knowledge with the world at large.

First off, you don't need to do anything too complicated to create a backup script.  SQL Server Management Studio has everything built in that you need. 

To start creating a backup script first check that SQL Server Agent is running.  If not, you'll get error saying that the 'Agent XPs' component is turned off.  To turn SQL Server on, simply open SQL Server Management Studio and rick click on SQL Server Agent and click Start.  SQL Server Agent will start and you should no longer get the error about 'Agent XPs'.

Unlike SQL 2000, creating a backup plan in SQL 2005 is not really very intuitive.  In SQL 2000 you could simply use a wizard to create a maintenance plan.  However in SQL 2005 you actually create a SQL Server Integration Services project which runs the backup for you.  (Actually this is the same basic thing you did in SQL 2000, but the interface was nicer.)

View Full Entry | 12 Comments