Archive for the 'SQL' Category

How to determine if a table exists in SQL Server Compact (SSC) Edition

March 10th, 2008

In one of my managed code project, I need to determine if a table exists in SSC.  This is pretty easy to do in regular SQL Server with T-SQL:

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[MyTable]') AND type in (N'U'))

SELECT 'Table exists.'

ELSE SELECT 'Table does not exist.'

However, this does not work in SQL Server Compact Edition.  First of all, SSC does not have sys.objects, second, SSC does not support conditional T-SQL.

After googling a bit, I found the first problem can be solved by using INFORMATION_SCHEMA.TABLES, how about the second problem?  I just could not find any conditional T-SQL reference in SSC.

I ended writing a c# function like this:

public static bool DoesTableExist(string tableName, SqlCeConnection ssceconn)
{
    string exsitTSql = @"SELECT COUNT(TABLE_NAME) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='" + tableName + "'";
    int cnt = (int) ExecuteScalar(exsitTSql, ssceconn);
    return (cnt == 1);
}

Posted in Mobile, SQL | No Comments »

SSDS MIX08 Session Summary

March 8th, 2008

Watched Nigel Eillis’ MIX08 presentation today: http://sessions.visitmix.com/?selectedSearch=BT05.  Here is a short summary on what I have learned about SSDS.

  • SSDS is a layer of WS been put on top of MSFT’s 18k+ SQL servers.
  • Taking Invitation only Beta application now, public Beta within 6 month, go live in Q1, 09.
  • SSDS supports REST and SOAP services now, will support more later.
  • There are three concepts you need to know:
    • Authority
    • Container
    • Entity
  • Authority contains Containers, and Container contains Entities.
  • No schema is needed for Containers and Entities.
  • Entities have two kinds of properties:
    • Fixed properties.  There are three so far:  ID, Kind, Version.  They are referenced as SomeEntity.ID, SomeEntity.Kind, SomeEntity.Version.
    • Flex properties.  Can be any number if them.  Referenced as SomeEntity["SomeProperty"].  Same property name on different entities needs not to be the same type.  E.g. “DatePublished” on EntityA can be a datetime, but on EntityB could be a string.
  •  Queries are in LINQ like syntax.
  • Product Page: http://www.microsoft.com/sql/dataservices/default.mspx.
  • Team Blog: http://blogs.msdn.com/ssds

Posted in SQL | No Comments »

Microsoft SQL Server Data Services

March 5th, 2008

I just got access to Amazon SimpleDB last Friday, yet get a chance to look at it.  Today, Microsoft announced Microsoft SQL Server Data Services (MSSDS).

“The service is designed for developers building Web-based applications that need a scalable, easily programmable and highly available utility-based data store.”

You can pre-register for the beta here.

I am anxious to take a look at this, since I already know a lot about MS SQL Server, I might use this a lot more than Amazon SimpleDB.

Posted in SOA, SQL | No Comments »



Permalinks By IIS Permalinks