sql-server-2008

Best datatype for SQL table with lots of long text fields

Hi, I have the following table in a SQL Server 2008 database with lots of long varchar fields for text descriptions. I want to know what is the best datatype to use for these. Currently I'm using varchar with 2000 character limit but this might cause problems if people need to add more text. Is there a problem using TEXT more than once...

SSRS 2005 or 2008 Report Model Data Caching?

Hello, Whether in SSRS 2005 or 2008, someone said that SSRS Report Model will cache the data defined within the report model and you will be required to update the report model regularly to get the new data into the report model views... is that correct? To me, it seems the report mdoel stores the definition/metdata only... could some...

Copy database offline mode

I have beeen using SMO for a while for transfering databases. It was pretty easy to handle from c# by using the TransferDatabase task. For my current project this gets to slow. I have to switch to offline mode, where the database is detached and atached. What is the least troublesome way to start such a process from c#? I know that the...

mirroring state of the database went to disconnected state in SQL Server 2008

I have 4 databases mirrored using High Protection mode without witness server between two servers(principal and mirror) that are in the same domain. Manual failover worked fine for several days. But later somehow the IP of the principal server was changed in the DNS, then onwards the mirror state of these databses went to disconneted sta...

Row locks - manually using them

I basically have an application that has, say 5 threads, which each read from a table. The query is a simple SELECT TOP 1 * from the table, but I want to enforce a lock so that the next thread will select the next record from the table and not the locked one. When the application has finished it's task, it will update the locked record...

Implementing application security - App Level & DB level (ASP .NET & SQL Server 08)

Hello, I am about to deploy an ASP .NET application (developed with LINQ-to-SQL). I have taken following precautions: Database access via user with limited access, however, since application is to access the sensitive data, I can't deprive this limited access user from it Database server is not exposed to external network - is hidin...

Retrieving Content from a Sub Content

I'm using SQL Server 2k8 and have a table that needs to be able to pull dynamic content. So, I was thinking of having 2 columns which would act like a Parent and Child. ContentId - SubContentId - ContentInfo 100 100 data here 101 100 data here 102 100 data here 103 100 ...

Using Time columns with NHibernate, Fluent NHibernate and SQL Server 2008

Hello, I have a table with a time column in my SQL Server 2008 database. The property of the object I'm trying to map to is a TimeSpan. How can i tell FluentNHibernate to use the TimeAsTimeSpan NHibernate type, so that I don't have cast problems? ...

How would one use Lucene to help implement search on a site like StackOverflow?

I've asked a simlar question on Meta StackOverflow, but that deals specifically with whether or not Lucene.NET is used on StackOverflow. The purpose of the question here is more of a hypotetical, as to what approaches one would make if they were to use Lucene.NET as a basis for in-site search and other factors in a site like StackOverfl...

SQL - how to count groups of rows and display the top/bottom 3

I realise this is likey to be an easy one, but my SQL is basic at best. Lets say I have a table containing a list of orders, with 'item_id' being one of the columns. I need to display the 3 least (or 3 most) popular orders of item. I know that I need to group the orders using item_id and then count them. Then I need to display the bott...

Store array in SQL Server 2008

I am developing a contact manager application using SQL Server 2008 (service-based database) . Most contacts have several emails or several phone numbers. So is there a way to store an array as a datatype in SQL Server? Or does anyone have an alternative to this way? ...

Foreign tables in SQL Server updated with Primary Key

The title might be a little misleading because I didn't really know what to call it. Here is my dbml and I am using the repository pattern to communicate between my application layer and my SQL layer. As you can see, I have four tables. Three of them have a foreign key to ContactId. I used this method because I need to store an "array", ...

Should you use outer join fetching with NHibernate and Sql Server 2008?

On outer join fetching, the Nhibernate documentation says: If your database supports ANSI or Oracle style outer joins, outer join fetching might increase performance by limiting the number of round trips to and from the database (at the cost of possibly more work performed by the database itself). Outer join fetching al...

Create View with Mutliple Tables in SQL Server 2008

I'm converting an app to use SQL Server 2008 that is currently using SQLite. How would I do the following view in SQL Server 2008? I can't seem to figure out the syntax for calling multiple tables: CREATE VIEW new_mimetypes AS SELECT DISTINCT fd.mimetype AS 'newMimetype' FROM files_detail AS fd WHERE ...

SQL Server: Top 10 salespeople per week - and previous rankings

select * from ( select year, week, salesperson, count(*) as transactions, rank() over(partition by week order by count(*) desc) as ranking from sales where year = '2010', group by year, week, salesperson ) temp w...

Is there a downside by chosing ntext as datatype for all text columns?

Possible Duplicate: Are there any disadvantages to always using nvarchar(MAX)? Is there a general downside by chosing 'ntext' as column type instead of a type that contains chars but with a limited max size like 'char' or 'varchar'? I'm not sure whether a limited column size is applyable to all my colums. Therefore I would us...

Cannot rename a column that is "replicated", probably due to CDC

I want to run the following rename EXECUTE sp_rename N'dbo.Semesters.IsPublic', N'Tmp_ShowNCs', 'COLUMN' I get the error Msg 4928, Level 16, State 1, Procedure sp_rename, Line 547 Cannot alter column 'IsPublic' because it is 'REPLICATED'. Msg 0, Level 20, State 0, Line 0 A severe error occurred on the current command. The results, ...

Encrypting filestream data

SQL Server 2008 supports data at rest security through TDE (Transparent data encryption), but the encryption excludes files stored on harddrive through FILESTREAM feature. How have you handled encryption of this data on file system stored through FILESTREAM? Encrypted File System seems to be an option, but would cause problem during DB...

SQL2008: Is there a way to throttle Change Data Capture (CDC) throughput?

I'm trying to find a way to 'throttle' CDC on SQL2008. The reason being that under normal circumstances, CDC performs brilliantly, but as soon as it needs to deal with a 'large' number of rows, it starts tanking. Typical throughput is between 1000 and 3000 rows a second. It starts to die at about 5000 rows per second. Usually, this is...

Long Running Merge

When I'm doing synchronization between database in different system, I'm getting the "long running merge" warning in the replication monitor. As my database consists of lakhs of records, so it is taking some time to execute which causes the warning as "long running merge". Will it affect the records to transfer or Shall I just ignore the...