sql-server-2008

How to rebuild view in SQL Server 2008

There is a view in my DB that someone defined with a * from one table. I just added a new column to that table and I want the view to reflect the new column. Besides re-executing the view creation script, is there another way to rebuild the view? I am looking for something similar to how sp_recompile will recompile a stored procedure ...

Why do my indexes get dropped when I change an Index'd view's schema?

Hi folks, Server: MS Sql Server 2008 When i create an indexed view .. and i then alter the view's schema, the index's all get dropped. It's sooo annoying! Can someone explain why this is? At first I thought that it could be because the fields the index requires are not in the schema any more (we did just alter it, right?) .... but fo...

SQL Server equivalent of Javascript UnEscape

I have a table in SQL Server 2008 with a column having the string stored in JavaScript Escape format. When queried from application, I am doing the JavaScript UnEscape of the returned string, so no issues. How do i UnEscape the string when I directly query the database? Is there any equivalent function for JavaScript UnEscape in SQL? ...

Adding a new stored procedure to an existing Visual Studio 2008 database project

I have imported an existing SQL Server 2008 database to a Visual Studio 2008 database project, to version control database objects and perform database code migration. This works fine and I can build and deploy to dev, test, staging, live etc. Now I want to add a new stored procedure (with a grant statement) to the existing database pro...

Having problems loading PHP Driver for SQL Server 2008 Express

Hello all, I am trying to make use of the PHP driver for MS SQL Server version 1.0. I have everything setup but I think I am having trouble loading up the extension php_sqlsrv_ts.dll. I have gone to the command line and try this: C:\wamp\bin\php\php5.3.0>php.exe --re sqlsrv Exception: Extension sqlsrv does not exist C:\wamp\bin\php\p...

Calculate Hash or Checksum for a table in SQL Server

I'm trying to compute a checksum or a hash for an entire table in SQL Server 2008. The problem I'm running into is that the table contains an XML column datatype, which cannot be used by checksum and has to be converted to nvarchar first. So I need to break it down into two problems: calculate a checksum for a row, schema is unknown be...

SQL Server 2008 Upgrade/compile - Column Alias and Table Alias

One of databases I develop for is being upgraded to SQL 2008 (from SQL 2000). The upgrade advisor is flagging an issue that I don't think is an issue. I was hoping that there is documentation that this is a known issue so that my DB team will just let it pass. The error is saying that in SQL 2008 you cannot use a table alias and a col...

What the linq query for SQL like and Soudex for sql server 2008?

In sql server, we can issue sql to get data like select * from table where column like '%myword%' select * from person where Soundex(LastName) = Soundex('Ann') what's the linq query to match above sql? ...

Functions in SQL Server 2008

Does sql server cache the execution plan of functions? ...

Control flow in T-SQL SP using IF..ELSE IF - are there other ways?

I need to branch my T-SQL stored procedure (MS SQL 2008) control flow to a number of directions: CREATE PROCEDURE [fooBar] @inputParam INT AS BEGIN IF @inputParam = 1 BEGIN ... END ELSE IF @inputParam = 3 BEGIN ... END ELSE IF @inputParam = 3 BEGIN ... END END Is there any other ways? For example, in C...

SQL Server dynamic column list in contains function

I have a database table in SQL Server 2008 with 5 nvarchar(max) columns. We're using the CONTAINS function to look for text in these columns. We can look in all five columns using this kind of query: SELECT * FROM SomeTable ST WHERE CONTAINS( (ST.ColumnA, ST.ColumnB, ST.ColumnC, ST.ColumnD, ST.ColumnE) , '"Strawberry"') Now we want ...

T-SQL query on huge table running slow depending on join conditions

Hi, we have a huge table of companies (17 million entries) for which we want to find duplicates according to search critera (based on phone number). The query runs very slow (5 minutes+) Here is a simplified version of the query, but the problem is the same : SELECT C1.* FROM dbo.Company AS C1 WITH(NOLOCK) INNER JOIN dbo.Company AS C2 ...

JPA Support for SQL Server 2008 using NetBeans 6.7.1

I am able to create a simple JPA Java application from NetBeans using Apache Derby database. But when I try to do the same with SQL Server 2008, I keep getting the following error: SEVERE: Application class sample.DBTestApp failed to launch javax.persistence.PersistenceException: No Persistence provider for EntityManager named RS6910SQL...

SQL Server 2008 autocomplete for "TOP" keyword

Either the autocomplete in SQL Server Management Studio 2008 is buggy, or I am. Either way, when I try to type this and hit the spacebar: SELECT TOP Autocomplete immediately changes it to this (Topics is a table in one of our databases, btw): SELECT Topics Is there a way to fix, or at least gracefully work around this? ...

What is the cost of an unused sproc

I've inherited a database with a surprisingly high number of unused sprocs. I've extracted the names of the used sprocs from the DLL that access it (all access is via that DLL), and from EXEC statements in those sprocs, and there are a couple hundred that are not called. Further, almost all have suspiciously verbose, uniform names: I sus...

Correct Use of XML datatype in SQL Server?

I have an application that allows my users to make temporary changes to an ongoing booking. I have recenlty read about the new XML datatype in SQL server, and the corresponding SqlXml type. I am thinking of using the new type to store the previous values of the object so that I can later revert to them. Something like: Booking Table:...

Cannot save database project: *.dbp file in Visual Studio

I have a database project (.dbp) open in Visual Studio 2008 as part of a solution. I've added a new sql script to the project. When I try to save the database project so that I can check it in, VS shows me a dialog: Some Unicode characters in this file could not be saved. To save all the information in this file, use 'Save As'; and ...

SQL Server 2008 resolving localhost to a computer name

We're in the process of switching from Windows Server 2003 to Windows Server 2008, and we've encountered a frustrating problem: In the old environment, some developers used sql server 2005 and others used sql server 2008. No problems. Our connection strings all pointed to: localhost/sqlserver. Now, on the new Server 2008 environment, Sq...

SQL Server connection issue

Hello everyone, I am using VSTS 2008 + .Net 3.5 + C# + SQL Server 2008 Enterprise on Windows Server 2003. I am using the following connection string, and labtest1 is the local machine name and I connect from local machine using ADO.Net. Then it always fail with connection error. But when I change in the connection string from "labtest1"...

Add data field to existing table with LIVE DATA

Hi, I'm working on a project which generate report every quarter. So there is a table supporting this: Report: ID(int) Quarter(byte) ... But later, the requirement changed and need the system to support more then one report in the quarter like this: 2-1, 3-2, ... How can I support this requirement change? Thanks in advance! ...