Can Enums in C# can be use of replacement of Lookup tables(e.g SportType,MatchType)

I have some table in database.Taking about only two 1-Sports 2-Match<> ……. In sports table there is columns SportType<br> and In Match table there is column MatchType Option 1: I have option to create SportType and MatchType Table Option 2: and second option is to crate Enums of SportType and MatchType Some people don’t prefer […]

Perform date range query from a single column control table (SQL Server)

Let’s say I have the following tables tableA seq datea 1 2010-01-01 2 2010-02-01 3 2010-03-01 tableb dateb sthvalue 2010-01-11 AAA 2010-01-12 AAB 2010-02-03 CCC 2010-02-06 CCD 2010-02-10 CCE 2010-03-05 FFF I want to join the two tables on tableb.dateb is within the daterange of tablea i.e. output should be seq datea dateb sthvalue 1 […]

How to compute the difference between binary fields?

I want to have a field that’s stored as a binary(64) (fixed length) and then I want to be able to query the “closest match”. To do so, I just want to find the absolute difference between each byte, and then sum the differences. An example w/ four-byte strings: 13 AF 83 52 – E9 […]

SQL Queue processing with UPDLOCK, READPAST and still getting deadlocks

The following stored procedure is working like a champ. This stored procedure facilitates queue processing for thousands of records and frequently fires simultaneously (sometimes threaded up to 7 or 8 times at any given instant): Alter Procedure sp.QueueProcessSingle As DECLARE @aid int update TABLE1 set [active] = 1, @aid = aid where aid=( SELECT TOP […]

What is livelock exactly? In SQL when/how does it happen? Anything T-SQL developer can do to avoid it?

I have encountered this jargon for SQL Server, I am just not able to understand what it is exactly it happens in SQL Server. I am looking at some SQL Server example where it occurs… I have been searching on google but all keep getting is 2 people in corridor example.

Unable to delete a record due to foreign key restriction

In my database, I have a table called “departments”. It contains information about the individual departments. The “name” column of this table is declared as the primary key. Now one of my departments was removed. So I wish to remove that department record, and its related information, from my database. However, a foreign key restriction […]

How to get firstdate and lastdate of eachmonth

Using Sql Server 2000 Table1 id sdate edate 001 05/01/2012 25/02/2012 002 19/02/2012 17/04/2012 ….. sDate, eDate format is dd/mm/yyyy I want to get firstdate and lastdate of eachmonth from the table1 like 01/01/2012 31/01/2012, 01/02/2012 29/02/2012 Expected Output id sdate edate 001 05/01/2012 31/01/2012 001 01/02/2012 25/02/2012 002 19/02/2012 29/02/2012 002 01/03/2012 31/03/2012 002 […]

SQL Server 2008 view error with case statement

I cant figure out why this code executes as a query but when I execute it in a view it throws a the multi-part identifier could not be bound, error. When I take out the case statement It works in the view, so I believe it is something that has to do with the case […]

Connecting to a remote web server and SQL database using Visual Studio

I need to set up and SQL server database hosting with a 3rd party web hosting service. To simplify the deployment process, I’d like to be able to develop the web site within a Visual Studio environment in exactly the same way as VS allows local machine or domain web sites to be edited. […]

Get date from substring in where clause of a sql select *EDITED*

I have a date stored within a text field with other text. Why didn’t they just put this in a date field? I have no idea, but I do not have the power to change it now. Elsewhere in the code, I am doing this to get the records where this date is in a […]

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