Data localization in SQL Server with GUIDs or…?

I need to make a database that is highly localized. For almost all entities I need a translation to 5+ languages. Some entities even require and additional resource localized (like images which I enter as paths). The question now is: 1: LOOKUP TABLE PER ENTITY/TABLE (kinda bloated schema?) should I create a “Localized” localization lookup […]

SP taking 15 minutes but the same query when executed returns results in 1-2 minutes

So basically I have this relatively long stored procedure. The basic execution flow is that it SELECTS INTO some data into temp tables declared with he # sign and then runs a cursor through these tables a generate a ‘running total’ into a third temp table which is created using CREATE. Then this resulting temp […]

SQL Server to .Net type conversions

I have the following map that I use to convert betwen SQL Server types, SQLData types, and .NET types: /// <summary> /// The map of types. THis maps all the corresponding types between sql server types, .net sql types, and .net types /// </summary> public static List<SqlTypeConversionHolder> TypeList = new List<SqlTypeConversionHolder>() { new SqlTypeConversionHolder(“bigint”, typeof(SqlInt64),typeof(Int64)), […]

FluentNHibernate – Setting default value for DB columns (SQL Server)

does anyone know a way how I could set through mapping the default value of a column so for e.g. when I generate DB from mappings I would have DateTime column having getdate() as default value? I tried so far this (looks exactlly like what I need) but it doesn’t work this.Map(x => x.LastPersistedOn, “DateModified”) […]

SQL Select COUNT(Value=Value) Possible?

I want to Count all the rows that only have the value I want like this: SELECT Users.Balance, Users.FreeBids, COUNT(Bids.Burned = 0) AS ‘ActiveBids’, COUNT(Bids.Burned = 1) AS ‘BurnedBids’ FROM Users INNER JOIN Bids ON Users.ID = Bids.BidderID WHERE Users.ID = 2 GROUP BY Users.Balance, Users.FreeBids It says “Invalid Syntax Neat ‘=’ It works perfectly […]

What data-type should I use to store monetary values?

I’ve read I should use money, but in todays fast paced world maybe that’s obsolete now. What should I use?

Does a Join table (association table) have a primary key ? many to many relationship

Does a Join table (association table) have a primary key ? many to many relationship. I’ve seen some Join tables with a primary key and some without can someone please explain when you would have a primary key in a join table and why? Thank you in advance;-)

How to implement a simple lock mechanism for multi-user application?

I really don’t want to re-invent the well here, so I’m asking for ideas to implement a simple (row) lock mechanism in a multi-user DB application. Suppose I have a Table called Products which of course has an ID (PK), and also a rowversion column (which is not used so far), and I want to […]

How to query current user's roles

I’m looking for a select statement which will retrieve a list of all database roles for my current connection. I want to create a view which will return all roles to a client software, such that the software can adjust its user interface according to the roles (e.g show/hide menu entries etc)

Good books or sites for advanced SQL queries or puzzles?

I work with SQL almost on a daily basis and want to improve my SQL skills. I am looking for online resources or books for advanced queries for real life problems. I liked Joe Celko’s books and I am looking for similar resources. I am also interested in SQL puzzles but ones which solve real […]

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