sql-server

SQL Server COLLATION on table name

For a SQL Server database with collation set to "Latin1_General_100_CS_AS" I want to run a query like: SELECT * FROM tableName, only the table name in the database is called TableName. SELECT * FROM TableName works fine SELECT * FROM tableName gives error: Msg 208, Level 16, State 1, Line 1 Invalid object name How can I make...

SQL Server Fulltext search yields no results

I have SQL Server 2005 Express Edition with Advanced Services. I enabled FullText and created a catalog as follows: create FullText catalog MyDatabase_FT in path 'mypath' as default I then created a FullText index as follows: create FullText index on Cell (CellName) key index PK_Cell with CHANGE_TRACKING AUTO I executed the fol...

SQLCLR using the wrong version of the .NET Framework

During a recent restart of our development server the SQL Server started using .NET 4.0 for the SQLCLR. This means that nothing using the CLR in SQL works, or at least that's my understanding by reading these sources: http://software.intel.com/en-us/blogs/2009/10/16/sql-server-2008-sqlclr-net-framework-version/ www.sqlskills.com/BLOGS/...

Out-of-range Datetime issue using LINQtoSQL

This is really confusing me. Here is a snippet of my model: * SQL Server * Event ----- Id (int, PK) NOT NULL Title (varchar(100)) NULL LastModified (datetime) NULL EventDates ---------- Id (int, PK) NOT NULL StartDate (datetime) NULL EndDate (datetime) NULL * C# * Event ----- public int Id public string Title public DateTime LastM...

Should a data warehouse developer know Powershell scripting?

I am a SQL Server (2005 & 2008) data warehouse developer (SSIS, SSAS, SSRS, SQL) and I am wondering if it would be worth the effort and time to learn Powershell scripting. Are there applicable uses from a development perspective? I understand that from a DBA view there is considerable power in Powershell for administration - does any o...

Sql server messed up degree symbol

Some of the degree sysmbols in my sql server database are displaying like this: 173┬░F. When I do a search for that - SELECT * FROM PRoduct WHERE description LIKE '%┬░%', it does not bring them up. How can I find (and replace) such characters? ...

Which inserts faster, XML field or Varchar(max) field?

We have a history table that stores xml web service requests and responses. Currently it stores them into an XML field, but we're having performance issues with inserts. We only insert records, no updates, selects or deletes. We've truncated the table and rebuilt the index, to no avail. The table has a Primary clustered index on the ...

al32utf8 in oracle and SQL Server and DB2 pulling data

I have a non-utf8 oracle database running on 11.1.0.7. We need to support greek characters. So we have two options: use nvarchar, nclob fields for those fields that need greek (it is not all fields). We have tested this and gotten it to work with java coding. convert Oracle to AL32UTF8 database. I am not asking how to do this. I got t...

I need to convert my Mysql database to SQL Server 2005 database

I need to convert my Mysql database to SQL Server 2005 database, Is there any tools available for this conversion. ...

Using SQL Server for web applications

As far as I understand, due to license reqirements all web applications, which use MS SQL Server, use SQL Server Express (free) or SQL Server web edition (processor license). Is it so? What are other specific features of SQL Server usage for web app? ...

How to write this SQL average query in linq

Here's the SQL I would like run: DECLARE @StartDt DATETIME, @EndDt DATETIME SET @StartDt='2009-01-01' SET @EndDt='2010-06-01' SELECT AVG(DATEDIFF(day, CreatedDt, CompletedDt)) AVG(DATEDIFF(day, CreatedDt, ComplianceDt)) FROM MyTable WHERE RequestDt BETWEEN @StartDt AND @EndDt Can this be expressed in Linq (C#) and have it all run...

Get the identity value from an insert via a .net dataset update call

Here is some sample code that inserts a record into a db table: Dim ds As DataSet = New DataSet() da.Fill(ds, "Shippers") Dim RowDatos As DataRow RowDatos = ds.Tables("Shippers").NewRow RowDatos.Item("CompanyName") = "Serpost Peru" RowDatos.Item("Phone") = "(511) 555-5555" ds.Tables("Shippers").Rows.Add(RowDatos) Dim custCB As SqlComma...

How is timezone handled in the lifecycle of an ADO.NET + SQL Server DateTime column?

Using SQL Server 2008. This is a really junior question and I could really use some elaborate information, but the information on Google seems to dance around the topic quite a bit and it would be nice if there was some detailed elaboration on how this works... Let's say I have a datetime column and in ADO.NET I set it to DateTime.UtcNo...

VSDBCMD returns "An unexpected failure occurred: Object reference not set to an instance of an object."

I have been succesfully using the command line database deployment tool VSDBCMD on my dev and test environments but the tool fails in our integration environmrnt. I am using the VS 2010 version of the tool. The servers have all of the prerequisites including: .net 4.0 sql server compact edition 3.5 sp1 (as well as the full edition of 2...

SQL Server Index Naming Conventions

Is there some standard way to name indexes for SQL Server? It seems that the primary key index is named PK_ and non-clustered indexes typically start with IX_. Are there any naming conventions beyond that for unique indexes? ...

SQL Convert Nvarchar(255) to DateTime problem

I'm using SQL server 2008. I have 2 Tables: Table 1 and Table 2. Table 1 has 1 column called: OldDate which is nvarchar(255), null Table 2 has 1 column called: NewDate which is datetime, not null Example data in Table 1: 26/07/03 NULL NULL 23/07/2003 7/26/2003 NULL 28/07/03 When i try CAST(OldDate as datetime) I get this error: ...

How to attach a SQL Server database from the command line

Is it possible to enter a command line command (like in a batch file) to attach a detached database to SQL Server, in stead of opening the management studio and doing it in there? ...

Do I have to use Stored Procedures to get query level security or can I still do this with Dynamic Sql?

I'm developing an application where I'm concerned about locking down access to the database. I know I can develop stored procedures (and with proper parameter checking) limit a database user to an exact set of queries to execute. It's imperative that no other queries other then the ones I created in the stored procedures be allowed to ...

SMO ConnectionContext.StatementTimeout setting is ignored

I am successfully using Powershell with SMO to backup most databases. However, I have several large databases in which I receive a "timeout" error "System.Data.SqlClient.SqlException: Timeout expired". The timout consistently occurs at 10 minutes. I have tried setting ConnectionContext.StatementTimeout to 0, 6000, and to [System.Int32]::...

Database mirroring: "witness" server what is it for?

What is a witness server used for? Why use it? ...