Just sharing some of my inconsequential lunch conversations with you... RSS  

Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Monday, November 23, 2009

Error converting Oracle VM

We’ve been converting out VMWare Server 1 and 2 to ESXi4. Today 2 of out Oracle servers stopped working after being VMWareConverted to ESXi. For some strange reason, oracle just managed to screw up the instance, and we got the following error:

ORA-01034 : ORACLE not available
ORA-27101 : shared memory realm does not exist

I had to re-register the service. Something like:

SET ORACLE_HOME=<my oracle home>
SET ORACLE_SID=<my oracle sid>

# delete service
oradim -delete -sid MCH9

# register service
oradim -new -sid <my oracle sid> -intpwd <my sysdba password> -startmode AUTO -pfile <my init.ora>




Thursday, November 12, 2009

SQL Server ignored default schema

Ignorance is not always a bless… In this case, it took us a lot of time figuring out why wasn’t the default schema kicking in. This one is well documented:

The value of DEFAULT_SCHEMA is ignored if the user is a member of the sysadmin fixed server role. All members of the sysadmin fixed server role have a default schema of dbo.

Friday, October 23, 2009

SQL Azure Migration Wizard

Here’s the easiest way to migrate your SQL database to SQL Azure: SQL Azure Migration Wizard:

The SQL Azure Migration Wizard helps you migrate your local SQL Server 2005 / 2008 databases into SQL Azure. The wizard walks you through the selection of your SQL objects, creates SQL scripts suitable for SQL Azure, and allows you to migrate your data.

Tuesday, May 05, 2009

Resetting an SQL Server table’s seed

Here’s how:

DBCC CHECKIDENT('voc_BizStep', RESEED, 0)

Wednesday, April 08, 2009

Service Pack 1 for SQL Server 2008

Service Pack 1 for SQL Server 2008 will be available today for customers. The Service pack is available via download at http://www.microsoft.com/downloads/en/default.aspx and is primarily a roll-up of previous cumulative updates, quick fix engineering updates and minor fixes made in response to requests reported through the SQL Server community. While there are no new features in this service pack, customers running SQL Server 2008 should download and install SP1 to take advantage of the fixes which increase supportability and stability of SQL Server 2008.

As announced here. Buuu, no fun….

Thursday, January 15, 2009

GDR with huge databases

Just had my first GDR experience with a 3000 tables database (Navision…). It wasn’t fast, but it worked!

PS: SSMS just refused to list the tables without filter conditions on this database. Has it should, though it couldn’t harm to have a ‘get all tables’ operation.

Wednesday, January 14, 2009

Using GDR through scripts

One of the features I like the most on GDR is how well decoupled it is from the tool itself. We have just had a great experience synchronizing a database where we and the client both develop.

As we don’t have access to the database server other than RDP, we opted for exporting the script on the server and importing it back on our development servers. A word of caution: remember to uncheck the ‘Include if NOT EXISTS’ option on the script generation, GDR just doesn’t like it :) Thanks for the tip, Samorrinha.

Tuesday, November 11, 2008

Changing your SQL Server name

Cloning VM machine's is something we usually do, but SQL Server doesn't like it's machine's name to be renamed. Here's a cool one I didn't know of - I used to re-run the setup, it really didn't installed it again, just clean it up. But here's a better way:

sp_dropserver <old_name>
GO

sp_addserver <new_name>, local
GO


Now all we have to do is:




  • restart SQL instance


  • delete all logins associated with old machine's name


  • add them back



There you have it :)

Monday, October 27, 2008

LINQ 'Row not found or changed'

This was pretty annoying... after a while getting an unexpected 'Row not found or changed', here's the solution:

disabled concurrency checks on *all* fields, then added them back one at a time.  Turns out the culprit was a string field that was nullable in the DB but not set as nullable in the designer.

Should probably have chosen EF. No comments...

Monday, October 20, 2008

LINQ to SQL Bug?

Here a great little LINQ to SQL bug. Consider the following code:

    IEnumerable<MasterEntity> masters = db.ExecuteQuery<MasterEntity>(
@"select * from MasterEntity master join DetailEntity detail on master.id = detail.MasterId
);



Not imagine if you have the same name column both on MasterEntity and DetailEntity, let's say 'IsMandatory'. When you try and get a this property form a MasterEntity object, what should you get?




  1. MasterEntity.Name?


  2. An exception, as Name can be ambiguous?



Well, on my code it happen to return... DetailEntity.Name! Yes, on my dev box the implementation seems to return the first projection by name. If you really want MasterEntity.Name to get returned, you'll have to get:



    IEnumerable<MasterEntity> masters = db.ExecuteQuery<MasterEntity>(
@"select master.* from MasterEntity master join DetailEntity detail on master.id = detail.MasterId
);


Funny, right? I'd expect MasterEntity.Name to get returned, as your asking for a MasterEntity object, right? No ambiguousness here, or am I wrong?

Tuesday, August 26, 2008

NHibernate: 2 - Entity Framework: 1

Sorry, couldn't help picking on Entity Framework. Ayende has annouced it, NHibernate 2 final is out! May the best win. Wait, better yet, may they both win.

Thursday, August 07, 2008

SQL Server 2008 is in RTM!!

Yeap, the rumors where real - though I didn't believe in them :) SQL Server is in RTM!

SQL Server 2K8 now has 7 versions. Simple to choose, no?

  • SQL Server 2008 Enterprise. SQL Server 2008 Enterprise is a comprehensive data management and business intelligence platform that provides enterprise-class scalability, data warehousing, security, advanced analytics and reporting support for running business-critical applications. With this edition, it is possible to consolidate servers and perform large-scale online transactional processing.
  • SQL Server 2008 Standard. SQL Server 2008 Standard is a complete data management and business intelligence platform that provides best-in-class ease of use and manageability for running departmental applications.
  • SQL Server 2008 Workgroup. SQL Server 2008 Workgroup is a reliable data management and reporting platform that delivers secure, remote synchronization and management capabilities for running branch applications. This edition includes core database features and is easy to upgrade to the Standard or Enterprise edition.
  • SQL Server 2008 Web. SQL Server 2008 Web is designed for highly available, Internet-facing Web-serving environments running on Windows Server. SQL Server 2008 Web provides the tools necessary to support low-cost, large-scale, highly available Web applications or hosting solutions for customers.
  • SQL Server 2008 Developer. SQL Server 2008 Developer allows developers to build and test any type of application with SQL Server. This edition features all of the functionality of SQL Server Enterprise but is licensed only for development, test and demo use. Applications and databases developed on this edition can easily be upgraded to SQL Server 2008 Enterprise.
  • SQL Server 2008 Express. SQL Server 2008 Express is a free edition of SQL Server that features core database functionality including all of the new SQL Server 2008 data types, in a small footprint. This edition is ideal for learning and building desktop and small server applications, and for redistribution by ISVs.
  • SQL Server Compact 3.5. SQL Server Compact is a free embedded database designed for developers and is ideal for building stand-alone and occasionally connected applications for mobile devices, desktops and Web clients. SQL Server Compact runs on all Microsoft Windows platforms, including the Windows XP and Windows Vista operating systems, and on Pocket PC and smartphone devices.

Just kidding, the more the merrier, our clients are entitled to a broader choice of features and prices.

Thursday, July 24, 2008

SQL Server 2008 still in Q3

A corporate vice president within the Microsoft Server and Tools business announced that SQL Server 2008 will be included in the August price list. According to InfoQ and many others, this would be a sign of an early August RTM.

Apparently this won't happen. ArsTechnica view:

Microsoft is still expecting the new version to arrive sometime in Q3. As Andrew Fryer put it on his blog: "Bottom line—It will be out sometime in Q3 when it’s ready," the fact that it is available on August's price list does not guarantee that it will become available then.

Andrew is probably right.

Saturday, May 03, 2008

Where the heck are Entity Framework samples?

Ok, Entity Framework is still to be released, but where the heck are EF samples? Take Following Real-World ASP.NET MVC Projects: Linq to SQL. Take Dynamic Data Controls: easily bindable with Linq To SQL, couldn't hook them up with EF. Most bloggers samples: Linq To SQL. Take Microsoft demoware apps: Linq To SQL. Can anyone point me to some nice EF samples other then Astoria?

Sunday, April 13, 2008

NHibernate 2.0 has reached alfa

Here it is! Ayende posted an extensive list of all the changes and new features. Here's my small list:

  • most of Hibernate 3.2.6 features;
  • new inheritance mapping strategies;
  • new events infrastructure (it's about time!).

With the Hibernate 3.2.6 maturity and the Linq for NHibernate developing experience NHibernate 2.0 will be a though competitor to match on the OR/Ms showdown.

Tuesday, February 05, 2008

Get control over your database

Or "Get Your Database Under Version Control", as compiled by Jeff Atwood:

K. Scott Allen just wrote a brilliant five part series on the philosophy and practice of database version control:

  1. Three rules for database work
  2. The Baseline
  3. Change Scripts
  4. Views, Stored Procedures and the Like
  5. Branching and Merging

Managing your database versions is just darn hard. In my opinion, the schema itself is the easy part, data is often the problem - at least on unstable staging scenarios that derive from production data.

Sunday, December 30, 2007

Red Gate SQL Data Generator 1.0 Beta

From the guys beyond SQLPrompt (code completion for SQL Server), this tool is aimed at generating test data for SQL Server databases, from scratch or from existing sources of data like SQL tables or CSV files.

Features:

  • Full SQL Server 2000 and 2005 support
  • All data types supported except CLR types
  • Pre & Post Scripts execution
  • Command-line access version
  • Import data from CSV or SQL tables
  • Customizable generator settings that allow configuring the amount of nulls, unique values, minimum and maximum values, etc..
  • Diverse range of inbuilt generators

On my first test I didn't find a simple dictionary generator like we have on hour internal generators. Oh well...

Heard it from David Hayden.

Thursday, December 27, 2007

Querying Many To Many associations using the Criteria API

Ayende as just posted about querying many to many associations using Criteria. Here's how:

DetachedCriteria blogAuthorIsJosh = DetachedCriteria.For<User>()
.Add(Expression.Eq("Username", "josh")
.CreateCriteria("Blogs", "userBlog")
.SetProjection( Projections.Id())
.Add(Property.ForName("userBlog.id").EqProperty("blog.id"));

DetachedCriteria categoryIsNh = DetachedCriteria.For(typeof(Category),"category")
.SetProjection(Projections.Id())
.Add(Expression.Eq("Name", "NHibernate"))
.Add(Property.ForName("category.id").EqProperty("postCategory.id "));

session.CreateCriteria(typeof (Post),"post")
.CreateAlias("Categories", "postCategory")
.Add(Subqueries.Exists(categoryIsNh))
.CreateAlias("Comments", "comment")
.Add(Expression.Eq("comment.Name", "ayende"))
.CreateAlias("Blog", "blog")
.Add(Subqueries.Exists(blogAuthorIsJosh))
.List();

I had already tried it but with no results. Looks like a refactoring week is approaching for me if I can get it to work over our HBMs :)

Thursday, December 20, 2007

Scaffolding in ASP.NET: Dynamic Data Support

Here's the scaffolding live-cycle, according to David Ebbo:

  1. Define your model: this step is not specific to Dynamic Data, but this is where it all starts. You have a database, and you create a model for it. Currently, this is done using Linq to SQL. In the future Linq to Entities will be supported as well.
  2. Test a scaffolded version of your app: with no additional effort, Dynamic Data lets you run a scaffolded web application on top of your schema. Although this scaffold has a 'standard' UI, it lets you try all CRUD operations on your tables. Furthermore, it has full support for relationships. For instance (assuming Northwind), the Products page would let you navigate to a product's category info, and editing a Product's category would show you a rich drop down with category names (instead of IDs).
  3. Customize the shared page views: you then get to make changes to the page templates that are used to display the scaffolded views. That, you can make changes that will affect the view of all the tables.
  4. Customize the specific pages: the next step is to define some custom UI for specific pages. e.g. you could write one of Products and another for Categories. The nice thing is that while you do this, you still get the standard scaffolded view for all the other tables. This lets you create specfic pages at your own pace, while keeping a functional application at every point.
  5. Annotate your model: you can add attributes to your model to add extra knowledge about certain fields. e.g. you could set a Range on the product's UnitsInStock field so it only allows values between 0 and 50. The UI would then automatically pick this up and validate inputs accordingly. The great thing is that you are keeping this information on your model, and don't need to 'pollute' your pages with it.
  6. Create custom field templates: all fields in Dynamic Data are rendered via field templates, which are basically user controls. You can also create custom templates, which can be very powerful. e.g. in the above case, you could create a field template that renders a range as a slider control instead of a textbox. Again, your page would pick that up without you having to add this custom UI directly in the aspx file.

Sunday, December 16, 2007

Moving it up to the cloud

Amazon SimpleDB is a web-services based storage system. It rents web services interface to create and store multiple data sets, query your data and return the results.

The way the samples were written seem to target product directories, and that makes sense, coming from Amazon :)

Development Catharsis :: Copyright 2006 Mário Romano