Tag: database

Best way to add a new column with an initial (but not default) value?

I need to add a new column to a MS SQL 2005 database with an initial value. However, I do NOT want to automatically create a default constraint on this column. At the point in time that I add the column the default/initial value is correct, but this can change over time. So, future access […]

how to rethrow same exception in sql server

I want to rethrow same exception in sql server that has been occured in my try block. I am able to throw same message but i want to throw same error. BEGIN TRANSACTION BEGIN TRY INSERT INTO Tags.tblDomain (DomainName, SubDomainId, DomainCode, Description) VALUES(@DomainName, @SubDomainId, @DomainCode, @Description) COMMIT TRANSACTION END TRY BEGIN CATCH declare @severity int; […]

Is it good database design to have admin users in the same table as front-end users?

I have users who can login on a front-end page, and admins who can login on an admin page. Should both users and admins be “Users” with different roles, or should they be split in different tables?

How do I get the creation date of a MySQL table?

This question already has an answer here: How to display all the tables with more information (create date, size,…) in a MySQL database? 1 answer

How do you unit test your T-SQL

How do you unit test your T-SQL? Which libraries/tools do you use? What percentage of your code is covered by unit tests and how do you measure it? How do you decide which modules to unit test first? Do you think the time and effort which you invested in your unit testing harness has paid […]

SQL Server 2008 R2 Stuck in Single User Mode

Having executed a DB deploy (from a VS SQL Server database project) on a local database, which failed, the database has been left in a state where it has single user mode left on (the deploy runs as single user mode). When I connect to it from SSMS and try something like the following: ALTER […]

Why database designers do not make IDENTITY columns start from the min value rather than 1?

As we know, In Sql Server, The IDENTITY (n,m) means that the values will start from n, and the increment value is m, but I noticed that all database designers make Identity columns as IDENTITY(1,1) , without taking advantage of all values of int data type which are from (-2,147,483,648) to (2,147,483,647), I am planning […]

How do you migrate SQL Server Database Diagrams to another Database?

My team recently rebuilt their SQL Server 2005 development database from scratch using the TFS source files. Afterwards, we had a nice clean database that more closely matched our test and production environments. However, we also lost the database diagrams that had been created over the months in the old development database. Does anyone know […]

Why is “close existing connections to destination database” is grayed out on SQL Server 2012 Management Studio?

I am normally using SQL Server 2012 Management Studio to restore a SQL Server database from a “bak” file. I do this by overwriting an existing database. In the “Options” page, there is a check-box labeled “Close existing connections to destination database”, which I mostly check because the target database is always “in use”, even […]

Which tools do people use to create Data Dictionaries?

On the project that I am working on I have a couple of databases. Each table and each column in the database has a description set (as an extended property in SQL 2005). As a part of the documentation going to the client we need to produce a data dictionary showing all of the tables […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.