sql-server-2008

Set based insert into two tables with 1 to 0-1 relation.

I have two tables, the first has a primary key that is an identity, the second has a primary key that is not, but that key has a foreign key constraint back to the first table's primary key. If I am inserting one record at a time I can use the Scope_Identity to get the value for the pk just inserted in table 1 that I want to insert into...

How to set default value for guids in sql server 2008?

I have a uniqueidentifier column in a table and it's not a key or index. I want to set the default value using NEWSEQUENTIALID(), but I get the error: Error validating default for column.. But if I use NEWID() no error. What's going on? ...

How can I concatinate a subquery result field into the parent query?

Hi folks, DB: Sql Server 2008. I have a really (fake) groovy query like this:- SELECT CarId, NumberPlate (SELECT Owner FROM Owners b WHERE b.CarId = a.CarId) AS Owners FROM Cars a ORDER BY NumberPlate And this is what I'm trying to get... => 1 ABC123 John, Jill, Jane => 2 XYZ123 Fred => 3 SOHOT J...

I want to install SQL Server 2008 Enterprise and SQL Server 2008 Express on the same machine, which should I install first?

I want to install SQL Server 2008 Enterprise and SQL Server 2008 Express side-by-side on the same machine, which should I install first for a simpler install process and easier maintenance in future? ...

Combining LIKE with IN in SQL

Instead of executing: SELECT a FROM b WHERE a LIKE 'a%' OR a LIKE 'b%' OR a LIKE 'c%' is there a way to execute something functioning like this pseudocode? SELECT a FROM b WHERE a IN ('a%', 'b%', 'c%') ...

Is it possible to create an indexed view with SQL Server 2008 which selects from another indexed view?

Is it possible to create an indexed view with SQL Server 2008 which selects from another indexed view? create view V1 as (select 1 as abc) create view V2 as (select abc from V1 group by abc) ...

How can I connect to Sql Server 2008 remotely using an IP Address?

When I publish my project clients will need to be able to setup the initial configuration, and part of that is the Sql Database Connection. I have an instance of Sql Server 2008 running on my system (MSSQLSERVER2008) as well as SQLEXPRESS2005. I am trying to use the following connection string locally just to see if this works, and I can...

what is wrong with my create table SQL?

Hello everyone, I am using SQL Server 2008 management studio to execute the following SQL statements, and here is the related error message from SQL Server management studio. Any ideas what is wrong? SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create TABLE [dbo].[BatchStatus]( [BatchID] [uniqueidentifier] NOT NULL CONSTRAINT...

What is most effective and easy way to batch INSERT query into SQL 2005/8

Hi! I'm new to ADO.NET so asking for help. I have to insert large number of records in one table. What is best-practice, effective and easy way to do that? I found an article called Batch Requests (ADO.NET Data Services Framework) but it isn't clear for me. Also I found an article about BULK INSERT but such method uses external file, I...

retrieve specific range of rows in a SQL Server table

Hello everyone, I have a table structure like (OrderID [uniqueidentifier], OrderDesciption [nvarchar]), I am using ADO.Net + C# + VSTS 2008 + SQL Server 2008. The table is big, and I want to let client give me two inputs, begin range index and end range index, and I will return specific rows of the table which is in the range (between b...

Sql Stored Procedure With a Lot of Parameters

I am using Sql Server 2008. My Stored Procedure accepts almost 150 parameters. Is there anything wrong with that performance-wise? ...

How do I specify a column to be unique in the scope of a relationship in SQL Server 2008?

It's easier with an example. I have two tables: Books and Chapters. Both have Title and Id columns. Chapters also has a Book column which is a foreign key to Books.Id. Books.Title is unique (I don't want two books with the same title). Now my problem is defining Chapter.Title uniqueness. I want it to be unique as long as Books.Id is the...

What is a good automated data import method for SQL Server?

I'm in the process of porting some SQL Server 2005 databases to SQL Server 2008. One of these databases has an associated import application (Windows task) which uses SSIS with a DTS package to import a large dataset from an MS Access database nightly. In upgrading to SQL Server 2008, I discovered that I can't run the same console appl...

Sql Processing vs. ASP.NET Runtime processing

I know in general it is a good practice to move as much processing as possible from Sql Server to the application (in my case ASP.NET). However what if the processing on the application level means passing 30+ extra parameters to the Sql Server. In this case is it worth moving the processing to the Sql Server? Here's the specific dilemm...

How to pass User Defined Table Type as Stored Procedured parameter in C#

In SQL Server 2008, we can define a table type and use it as Stored Procedures' parameters. But How can I use it in C# invocation of this SP? In other words, how to create a table or list and pass it into Stored Procedure in C# code with this new feature of SQL Server 2008? ...

Is there any way to expand the Processes pane in Sql Server 2008 Activity Monitor?

This should possibly be a Microsoft support question, but does anyone know if there's a way to expand the Processes (or any of the other panes) in SSMS 2008 Activity Monitor? All i actually want to see is a list of running processes, but even if i collapse all the other panes i can't expand one to fit the screen. It seems like such a s...

SQL Server 2008 express performance in production environment?

Hi there, I am about to move servers and i was talking to somebody and they suggested using sql server express 2008 installed on the servers. I have full access to the server. Does this express engine work at the same speed (performance) as a true sql server 2008? I know about the limitations i..e max 4 GB per DB ... and max 1 GB of r...

Error: Cannot alter or drop column 'x' because it is enabled for Full-Text Search

I'm refactoring an old database and removing columns no longer in use. The DB used to have full text indexing, so, some column are marked for full text. How can I remove them? Notes: DB is MS SQL Server Express 2008 Full text search service is no longer installed Edit: I have tried ALTER FULLTEXT INDEX ON tableName DROP (Colu...

SQL Server 2008 Management Studio Toolbox item is missing

In SQL Server Management Studio, the VIEW menu's TOOLBOX item is not visible. Can any one help me make it visible? ...

Getting Login error in sql server 2008

Hi All, I have SQL server 2008 and it was working fine ,but today while starting SQL server I am getting the following error : "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server i...