sql-server

Practical limit for the number of databases in SQL Server?

In one of the stackoverflow podcasts (#18 I think) Jeff and Joel were talking about multi vs single tenant databases. Joel mentioned that "FogBugz on Demand" used a database per customer architecture and I was wondering if there is a point beyond which you'll need to have multiple database servers to distribute the load? ...

How do I convince someone they need to upsize from ms access to sql server or similar

I am having a real problem at work with a highly ingrained developer obsessed with ms access. Users moan about random crashes, locking errors, freeze's, the application slowing down (especially in 2007) but seem to be very resistant to moving it. Most of the time they blame the computer and can't be convinced it's the fact its a mdb sat ...

Why would LINQ to SQL perform better than a straight SQL query?

Strange performance outcome, I have a LINQ to SQL query which uses several let statements to get various info it looks like this public IQueryable<SystemNews> GetSystemNews() { using (var t = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.Isolatio...

How do I add a new replicated table to a SQL Server 2005 DB that is in merge replication?

We have merge replication set up over a distributed environment (50 to 1500km between offices) for a SQL Server 2005 database of about 350Gb. We now need to add a couple of new tables that must also be in replication, but without pushing the new snapshot to all the subscribers. Is this possible, and if so, what would be the best way to...

CLR UDF Exception In SQL Server 2005

When I try my CLR UDF, I am getting this error: Msg 6522, Level 16, State 1, Line 1 A .NET Framework error occurred during execution of user-defined routine or aggregate "getFileSize": System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture...

Query to get all revisions of an object graph

I'm implementing an audit log on a database, so everything has a CreatedAt and a RemovedAt column. Now I want to be able to list all revisions of an object graph but the best way I can think of for this is to use unions. I need to get every unique CreatedAt and RemovedAt id. If I'm getting a list of countries with provinces the union lo...

How does the SQL Server JDBC Trusted Connection Authentication work?

How does the SQL Server JDBC Trusted Connection Authentication work? (ie how does the trusted connection authenticate the logged in AD user in such a transparent and elegant fashion and how can I implement a similar authentication solution for my client-server applications in Java without a database connection or any use of the existing ...

SQL Server Active Directory Import Issues with British Summer Time (BST)

I'm using SQL Server ADSI to import data from Active Directory and using the whenChanged field to control if I need to reimport the members of a group. Problem is the date is being returned in GMT and I'm currently in BST. So, did a member change at 9:50 this morning, the AD tools I have say 9:50, but the ADSI query returns 8:50. This...

What is best practice for this problem (different properties for different categories)?

Hi. I have some products that belongs to the some category. Each category can have different properties. For example, category cars has properties color, power, ... category pets have properties weight, age, ... Number of categories is about 10-15. Number of properties in each category is 3-15. Number of products is very big. M...

Sybase Developer Asks: How To Create a Temporary Table in Oracle?

I'm familiar with Sybase / SQL server, where I can create a temp. table like this: SELECT * INTO #temp FROM tab1 , tab2 WHERE tab1.key = tab2.fkey SELECT * FROM #temp WHERE field1 = 'value' #temp only exists for the duration of this session, and can only be seen by me. I would like to do a similar thing in Ora...

What's the difference between creating a UNIQUE index as "index" or as "constraint" in SQL Server?

When creating an index over a column that is going to be UNIQUE (but not the primary key of the table), SQL server let's me choose a few options: 1) I can choose for it to be a Constraint or an Index. I'm guessing this means that if I set it as constraint, it won't use it when querying, only when writing. However, the only efficient way...

Unknown token received from SQL Server

I got this error when trying to run a query in SQL server query analyzer. What is the reason? ...

SQL Server 2005 - Error_Message() not showing full message

I have encapsulated a backup database command in a Try/Catch and it appears that the error message is being lost somewhere. For example: BACKUP DATABASE NonExistantDB TO DISK = 'C:\TEMP\NonExistantDB.bak' ..gives error: Could not locate entry in sysdatabases for database 'NonExistantDB'. No entry found with that name. Make sure that ...

How do I determine if a column is in the primary key of its table? (SQL Server)

I am currently using... select Table_Name, Column_name, data_type, is_Nullable from information_Schema.Columns ...to determine information about columns in a given database for the purposes of generating a DataAccess Layer. From where can I retrieve information about if these columns are participants in the primary key of their table...

What is a good tool to get SQL code completion with SQL Server 2005?

I've tried Red Gate's SQL Prompt and like it, but cannot afford it at the moment. I miss the good code completion that this tool provides. Are there any good free tools out there that have SQL code completion (table and column names, etc)? I've tried TOAD, but it was quite buggy. It would crash, and would also leave connections open ...

SQL Server - Running large script files

I have a database table on a development server that is now fully populated after I set it running with an import routine for a CSV file containing 1.4 million rows. I ran the Database Publishing Wizard on the table, and now I have a 286MB SQL script on my local machine. The problem is, I can't figure out how to run it. If I load it i...

intelligent database search

The issue is there is a database with around 20k customer records and I want to make a best effort to avoid duplicate entries. The database is Microsoft SQL Server 2005, the application that maintains that database is Microsoft Dynamics/SL. I am creating an ASP.NET webservice that interacts with that database. My service can insert cu...

String Manipulation in MS SQL Server

Can anyone give me a complete list of string manipulation function in Microsoft SQL Server (2000 or 2005)? (I don't need a lecture about doing all my string processing in the presentation layer. And, I don't need a list of MySQL string functions.) Thanks! ...

How do I insert the contents of a subselect in MS SQL Server?

I want to do something like insert into my table (select * from anothertable where id < 5) What is the correct MSSQL syntax? Thanks! ...

What's the syntax for variables in an MSSQL stored procedure?

I have a simple query like this: select * from mytable where id > 8 I want to make the 8 a variable. There's some syntax like declare @myvar int myvar = 8 but I don't know the exact syntax. What is it? Thanks! ...