Can there be constraints with the same name in a DB?

This is a follow-on question from the one I asked here. Can constraints in a DB have the same name? Say I have: CREATE TABLE Employer ( EmployerCode VARCHAR(20) PRIMARY KEY, Address VARCHAR(100) NULL ) CREATE TABLE Employee ( EmployeeID INT PRIMARY KEY, EmployerCode VARCHAR(20) NOT NULL, CONSTRAINT employer_code_fk FOREIGN KEY (EmployerCode) REFERENCES Employer ) […]

How to count 2 different data in one query

I need to calculate sum of occurences of some data in two columns in one query. DB is in SQL Server 2005. For example I have this table: Person: Id, Name, Age And I need to get in one query those results: 1. Count of Persons that have name ‘John’ 2. Count of ‘John’ with […]

JBoss AS 5 database connection pool re-connect routine for MS SQL Server

I’d like to come up with the best approach for re-connecting to MS SQL Server when connection from JBoss AS 5 to DB is lost temporarily. For Oracle, I found this SO question: “Is there any way to have the JBoss connection pool reconnect to Oracle when connections go bad?” which says it uses an […]

What's the difference between an SQL transaction at the stored procedure level and one at the SqlConnection level?

Say a stored procedure on MSSQL Server uses an SQL transaction using BEGIN TRANSACTION/COMMIT TRANSACTION, how does that differ from beginning and commiting one using ADO.NET via SqlConnection.BeginTransaction()?

SQL Server 2008 Installation

I’m trying to install MS SQL Server 2008 on my Win 7 enabled laptop. I’m facing a problem while selecting the path to install. When I go on choose ‘installation’ and then when I click on ‘New SQL Server stand alone installation or add features to an existing installation’ it pops up a browse dialog […]

How to get the count of digits after the decimal point in a float column in ms sql?

I have to count the digits after the decimal point in a database hosted by a MS Sql Server (2005 or 2008 does not matter), in order to correct some errors made by users. I have the same problem on an Oracle database, but there things are less complicated. Bottom line is on Oracle the […]

SQL Server specific types support for OrmLite

I just learned about a genius type that would simplify a lot of my work but it looks like my preferred ORM does not recognize it. Is there a workaround to let ServiceStack OrmLite recognize HierarchyId in SQL Server? Any suggestions about which files to modify and any hints how to proceed? EDIT : Here […]

What's SQL Server's analogue of MySQL's unicode_ci collation?

As far as I understand, in MySQL unicode_ci (utf8_unicode_ci in particular) collations are meant to support all the characters regardless to locale. I need to achieve the same with SQL Server 2008 R2. My database is going to contain data in very different languages (not limited to latin-based alphabets). I am not going to use […]

SQL Server query dry run

I run a lot of queries that perform INSERT‘s, insert SELECT‘s, UPDATE‘s and ALTER‘s on tables, and when developing these queries, the intermediate steps that are run to test that various parts of the query work, potentially change the table or the data within the table. Is it possible to do a dry run of […]

Entity Framework – how to manage tables in different databases but on the same server?

I am using SQL Server 2008. It seems as though in EF I need a different entity context for each database. Joining tables between databases means having to allow for this which is inconvenient and makes it more likely that I would simply put everything in one database. Am I missing something? Surely EF can […]

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