nvarchar(max) vs NText

What are the advantages and disadvantages of using the nvarchar(max) vs. NText data types in SQL Server? I don’t need backward compatibility, so it is fine that nvarchar(max) isn’t supported in older SQL Server releases. Edit: Apparently the question also applies to TEXT and IMAGE vs. varchar(max) and varbinary(max), for those searching for those data-types … Read more

SQL Server Restore Error – Access is Denied

I created a database on my local machine and then did a backup called tables.bak of table DataLabTables. I moved that backup to a remote machine without that table and tried to do a restore but get the following error: System.Data.SqlClient.SqlError: The operating system returned the error ‘5(Access is denied.)’ while attempting ‘RestoreContainer::ValidateTargetForCreation’ on ‘c:\Program … Read more

Sql Server string to date conversion

I want to convert a string like this: ’10/15/2008 10:06:32 PM’ into the equivalent DATETIME value in Sql Server. In Oracle, I would say this: TO_DATE(’10/15/2008 10:06:32 PM’,’MM/DD/YYYY HH:MI:SS AM’) This question implies that I must parse the string into one of the standard formats, and then convert using one of those codes. That seems … Read more

How important is the order of columns in indexes?

I’ve heard that you should put columns that will be the most selective at the beginning of the index declaration. Example: CREATE NONCLUSTERED INDEX MyINDX on Table1 ( MostSelective, SecondMost, Least ) First off, is what I’m saying correct? If so, am i likely to see large differences in performance by rearranging the order of … Read more