When should you enable the RowGuid column property in SQL Server 2005? - sql-server

The MSDN documenation states:
Indicates whether SQL Server uses the column as a ROWGUID. You can set this value to Yes only for a unique identity column.
This doesn't tell me why I would have this enabled or disabled.

Setting the column as ROWGUID tells SQL Server that that row will be used as a GUID. By default SQL Server will set the default value of the row to NewID() which will generate a GUID.
So, you would use it when you want to use GUIDs, which are globally unique. This makes them useful for replicating and merging databases since you know that no two rows will ever (theoretically) have the same id.

Related

Ms Access with a linked SQL Server

I have MS Access which is linked to SQL Server
I'm typing on a keyboard with Kurdish Central layout.
Data in SQL Server is no problem, but in MS Access it's showing a column as
#Deleted
This problem is only in Kurdish.
What is the solution to this problem?
Thanks for everything ...
I don't believe this has ANY relevance in regards to the language used.
Make sure the server table has a PK id, and also add a row version column to the sql server table. (row version is called timestamp - but has ZERO to do with time - worlds worst name in history for a column type in sql server).
So, ensure the sql table has a PK column defined, and also that timestamp column. Now, rel-link the access table and try again.

SQL Server Numeric with Identity not converting to Auto Number in MS Access using linked tables

I am using ACCDB with SQL Server linked tables.
I have a table with a Numeric column, primary key and an identity column.
But when I link it to Access database, it is getting converted as Number and not Auto Number.
Any thoughts how to correct this?
An autonumber in Access is actually a long integer (int in SQL Server), with an additional property creating an autonumber. If your SQL Server data type is actually numeric, I don't see how Access can recognize it as an autonumber. When using Access as a front end to SQL Server, it is best to use data types that Access easily recognizes.

How do I add the IDENTITY property to existing SQL Azure table?

I have created a couple of tables in SQL Azure and forgot to mark the primary keys as identity columns. There is no data in the tables yet, but the check box marked Is Identity is disabled.
How do I make an existing primary key an identity column in SQL Azure?
You create a new table. You can't change the IDENTITY property in a regular SQL Server instance either - well, depending on your settings, SSMS might let you, but it doesn't tell you what it actually does behind the scenes - drops the table and re-creates it. Don't believe me? Script it out or profile it.

What is the suitable data type for DB replication?

I'm creating a DB using SQL Server 2008.
This DB will be used in two countries and at some time (every day) they will be synchronized, I'll use the Replication service to accomplish that.
Most of the tables are using an Int column with Identity increment. But the tables will be empty when deployed so both countries will have a row with identity 1, 2, and son. I've never use replication before so I wanna know if there will be an error when the tables are synchronized?
Should I use a GUID data type instead?
Replicate Identity Columns (MSDN):
Replication offers three identity range management options:
Automatic. Used for merge replication and transactional replication with updates at the Subscriber...
Manual. Used for snapshot and transactional replication without updates at the Subscriber...
None. This option is recommended only for backwards compatibility...
So, yes, you can continue to use IDENTITY, provided you read through the information on replication and choose an option that makes sense for you.
Under Automatic, what it does is each server grabs a range of usable identity values and hands the individual values out as needed. Provided synchronization occurs often enough so that the ranges aren't completely exhausted, you'll never notice this detail.
And this allows you to scale out later as needed - as opposed to e.g. a MOD scheme where one server hands out odd values and the other even - you can't easily add a third server to such a scheme.
By your description, it sounds like you want to implement so called Merge replication.
In SQL Server you would not need to change the identity to a GUID, however, if you don't SQL server will automatically add another column called rowguid for each table and you may end up with duplicates of your original identity column. To circumvent this, you could have the servers assign mod 2 IDs.
In my opinion it makes most sense to use a GUID for the IDs altogether. Don't forget to set the ROWGUIDCOL property on your identity columns. Good luck.
Relevant MSDN:
http://technet.microsoft.com/en-us/library/ms152746.aspx
Consider adding a deviceID field to all tables users can update. With each device making changes using its own ID as part of the PK, there cannot be conflicts across devices.

ALTER TABLE with a default: SQL Server vs Oracle

We have some tables in an Oracle database with several million rows. When we alter one of these tables to add a new column, we specify a default. This is very slow to run as Oracle has to update all existing rows with the default. The solution is to ensure the column is defined as NOT NULL because then Oracle (recent versions only) will not update all existing rows with the default - the subsequent presence of a null in one of these columns tells Oracle that it requires a default and it will provide the default on the fly.
My question is regarding SQL Server: does it exhibit similar behaviour when adding a column and providing a default? If not, are there any best practices in efficiently adding new columns with default values, and are there any advantages in defining a column as NOT NULL?
Prior to SQL Server 2012 adding a NULLable column w/o default was very vast, but adding a DEFAULT contraint would be slow, as every row has to be updated. Since SQL Server 2012 adding a DEFAULT is also fast, a metadata only operation, when possible.

Resources