sql-server-2008

Easy way to convert data table to hash table or sqldatareader to hashtable

Please tell me if there's an easy way to convert a DataTable to a HashTable or a SQLDataReader to a HashTable. I have to parse it through javascriptserializer. the code i m using, having some problem. please take a look and guide me. try { using (SqlConnection conn = new SqlConnection(ConnectionString)) { using (SqlComma...

Poor execution plans when using a filter and CONTAINSTABLE in a query

We have an interesting problem that I was hoping someone could help to shed some light on. At a high level the problem is as below: The following query executes quickly (1 second): SELECT SA.* FROM cg.SEARCHSERVER_ACTYS AS SA JOIN CONTAINSTABLE(CG.SEARCHSERVER_ACTYS, NOTE, 'reports') AS T1 ON T1.[Key]=SA.UNIQUE_ID but if we add a fil...

Dynamically change my schema

I am wondering if there is a way to change the schema that I am working in while inside Management Studio. For instance I may have a default schema of dbo. But there are times I may want to query objects in say the accounting schema. It would be nice if I could issue a command and make it so I no longer must include the accounting before...

Insert hex string value to sql server image field is appending extra 0

Have an image field and want to insert into this from a hex string: insert into imageTable(imageField) values(convert(image, 0x3C3F78...)) however when I run select the value is return with an extra 0 as 0x03C3F78... This extra 0 is causing a problem in another application, I dont want it. How to stop the extra 0 being added? The ...

How to find ALL descendants using HierarchyID for SQL Server

I need to find all descendants of a category using HierarchyID for SQL Server. I know how to find direct childs but I would like to find childs of childs of child..etc. Is there a way to do this using the hierarchyID. ...

Trying to verify understanding of foreign keys SQL Server

So I'm working on just a learning project to expose myself to doing some things I do not get to do at work. I'm just making a simple bug and case tracking app (I know there are a million this is just to work with some tools I don't get to). So I was designing my database and realized I've never actually used Foreign Keys before in any of...

what's a good way to synchronize a sql server 2008 database from a 2005 database automatically?

Ok, the scenario is... two servers, on completely different parts of the internet. The sql 2008 database just needs to get data updates and schema changes. It doesn't need to send anything to the 2005 database. Basically just suck data and schema as efficiently as possible automatically as a scheduled task. The database is quite huge...

How should I do this (business logic) in Sql Server? A constraint?

Hi folks, I wish to add some type of business logic constraint to a table, but not sure how / where. I have a table with the following fields. ID INTEGER IDENTITY HubId INTEGER CategoryId INTEGER IsFeatured BIT Foo NVARCHAR(200) etc. So what i wish is that you can only have one featured thingy, per hubId + categoryId. eg. 1, 1, 1...

Is there a way to turn this query to regular inline SQL

I would like to turn this query to regular inline sql without using stored procedures declare @nod hierarchyid select @nod = DepartmentHierarchyNode from Organisation where DepartmentHierarchyNode = 0x6BDA select * from Organisation where @nod.IsDescendantOf(DepartmentHierarchyNode) = 1 Is there a way to do it? ...

Get SQL Server 2008 Management Studio icons

I want to get icons from SQL Server 2008 Management Studio. Is it free ? If so where can I download it ? ...

WCF SERVICE gives us faulted response

My service is hosted on IIS7, windows 2008 server with sql server2008 express. I am getting following error when the process takes more than 2 minutes i got this response, i m unable to find out either it is due to sql server time out or wcf time out. my sql server process is also took long. An error occurred while receiving the HTTP re...

Proper Install Order For Visual Studio 2010 with SQL Server 2008 and Office 2007?

I want to create a Windows 7 64-bit (Ultimate) virtual machine with: Visual Studio 2010 (Ultimate) Office 2007 Enterprise (with Visio 2007) SQL Server 2008 (with SSIS and SSRS) but I am not sure if there is a correct order to install those items such that there will not be a loss of "awareness" of one application from another on tha...

Import SQL server database using batch

Hello, I need to import a database into a SQL Server instance using a batch script and the database is provided by an sql file. How can I do This? The SQL file was generated by the SQL Server management studio. ...

Can We use SqlCacheDependency with a product not containing ASP.net part?

Is SQLCacheDependency used in context of ASP.net or can it be used for a project of .net only. Rather tahn using ASP.net i am receiving request by listening on a port.I want to store data for my session in cache.If this data is fetched from database then i want it to be updated using something like SQLCacheDependency.Can I configure it f...

SQL Server 2008 Full Text Rebuild - Large Memory Usage Issue

Each time I perform a SQL Server 2008 FTS Catalog Rebuild, my server is left in a state where the SQL Server process is at 2.8+ GB of memory and is causing performance degradation of the machine. When recycling the SQL Server service, its goes back down to around 350 MB and performance is back to normal. Is it normal to have to restart...

Getting DateTimeOffset value form SQL 2008 to C#

I have a SQL 2008 table with a field called RecDate of type DateTimeOffset. For a given record the value is '2010-04-01 17:19:23.62 -05:00' In C# I create a DataTable and fill it with the results of "SELECT RecDate FROM MyTable". I need to get the milliseconds, but if I do the following the milliseconds are always 0: DateTime...

SQL View Creation

I have two tables Table FOO FooUniqueID| Year| Name| Worth| --------------------------- 1 2008 Bob 23.00 2 2009 Bob 40200 Table Bar BarUniqueID | Name | Value ----------------------- 1aBc Year 2009 I would like to create a view. That will select everything from FOO where the Year is equal ...

See images in SSMS?

I was browsing around and found this blog post: http://erikej.blogspot.com/2010/04/version-3-of-exportsqlce-now-available.html (It is for a great add in if you user SQL Server CE.) On that post I saw an screen shot of SSMS with images in the results. How is this done? I have images in my database (PNG files that are serialized via ...

How to save a Stored Procedure ?

Hello, I've been playing today with stored procedures. I'm stoned that I picked the basic of it up so easily. (I'll also try triggers very soon). Now, I'd like to know how to save my SPROC under the stored procedure folder (Programmability -> Stored Procedure) so that I can access it by name (eventually from my C# application). So far,...

SQL Server 2008 database mirroring madness

I'm trying to get database mirroring to work on SQL Server 2008 between two computers. I checked connectivity, but here's what I end up with: on the principal machine, the server can connect to the mirror but refuses to set up a mirroring partnership due to it being 'unable to connect' (I checked connectivity, everything works). The wei...