sql-server-2008

Using XQuery in SQL Server 2008 to search for content

Hi, Take the following 4 example XML documents: <Example> <Colour>orange</Colour> </Example> <Example> <Car colour="orange">Ford Focus</Car> </Example> <Example> <County>Orange County</County> </Example> <Example> <Orange>555</Orange> </Example> These are all stored in a SQL Server database in a table...

SQL Server: conventions for naming a schema

Consider a database server whose job today is to house one database. Likely the database will be moved in the future to another database instance which houses multiple databases & schemas. Let's pretend the app/project is called Invoicer 2.0. The database is called AcmeInvoice. The database holds all the invoice, customer, and product i...

Setting multiple scalar variables from a single row in SQL Server 2008?

In a trigger, I have code like: SET @var1 = (SELECT col1 FROM Inserted); SET @var2 = (SELECT col2 FROM Inserted); Is it possible to write the above in a single line? Something conceptually like: SET (@var1,@var2) = (SELECT col1,col2 FROM Inserted); Obviously I tried the above, without success; am I just stuck with the first method?...

How do I GRANT ALTER ANY LINKED SERVER to a role?

Our database has a named database role. Our service account is a member of this role. This makes our database creation scripts simpler. However, I'd like this role to be able to create linked servers. If I try the following: USE OurDatabase GO GRANT ALTER ANY LINKED SERVER TO OurRole GO ...it fails with Permissions at the server sc...

SQL Server Service Broker -- Communicating Between Non-Domain Servers Over a VPN

Are there any good options for connecting two SQL Server 2008 instances via Service Broker if neither of those servers are in a domain, but we have full control over the logins and credentials? We're thinking of using this technology for enterprise-level data consolidation, but our servers run at client sites and are not configured as m...

What is the best way to encrypt SSNs in SQL Server 2008?

I am developing a new web application using .NET 3.5 and SQL Server 2008 that will need to store some Social Security Numbers. I've been doing some initial reading on database encryption and it's a little bit confusing. I would be nice to encrypt the SSNs using an asymmetric key, since that way the public facing application wouldn't be ...

Database Create on SQL Server2008 Express/Windows VIsta Home Edition

I successfully installed Express on Windows Vista Home Edition. When I tried to create a database using the account under which it was installed I received this message: TITLE: Microsoft SQL Server Management Studio Create failed for Database 'Test1'. (Microsoft.SqlServer.Smo) ADDITIONAL INFORMATION: An exception occurred while exe...

Visual Studio Website: Can't create an SQL Database!

Hi, I'm using Visual Studio 2008 SP1 with SQL Server 2008. I'am trying to add an SQL Server File (MDF) in my Website project. Then I get the following error: Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify... I've been using Google without any results, and I'm in deep need ...

Do you need to specify all fields in an insert

When performing an insert lets say from C# into a SQL Server table (using parameterized sql statements), do you need to specify every table field in the insert statement? I noticed that the fields that I do not specify in the insert default to the defaults set in the table. I don't know if that's good or bad in my insert statement to...

Returning table-type by function

Can user-defined table-valued (or any other function) return table-type in SQL Server 2008? ...

What's the point of creating a user in order to access the DB located at SQL Server 2008

Hello, So far, after creating DB with all the schema, all I have done so for was accessing them (tables) by reference through ConnectionStrings. Now, twice, I've read that it's better to create a DB user and access the DB trhough that user by including him in the c*onnectionString*. I'd like to know why so? Thank for helping ...

Altering a Table Column to Accept More Characters

What would the command be for Microsoft SQL Server 2008 to alter an existing column to allow for more characters? Would this have an effect on any previous entries in the column if I'm only expanding it? I have a URL column that I need to add about 100 characters to. ...

How to speed up mssql_connect() in PHP 5.2.X

Hello folks, I'm working on a project where a PHP dialog system is communicating with a Microsoft SQL Server 2008 and I need more speed on the PHP side. After profiling my PHP scripts, I discovered that a call to mssql_connect() needs about 200 milliseconds on that particular system. For some simple dialogs this is about 60% of the who...

Online Hosting and online SQL database

Hi All, I am busy creating a asp.net web site and using MS SQl 2008 as the Database. I am looking for a cloud based hosting solution for both the database and the web site. I would like to keep the costs down, until more clients are using the system. What are your experiences and suggestions? If I can have decent availability and th...

Does the Developer edition of SQL Server let you have multiple users?

Does anyone know if the 2008 Developer edition of SQL Server allows you to have multiple developers access it on the same server? I called Microsoft, but the guy I talked to didn't seem to know the answer. Has anyone tried it? I am a developer that uses the Express edition now on one server and all four of our developers use it in our L...

A way to add a constraint between two domains in a table without using a trigger?

I have a following table, Client. create table Client ( ClientID int identity primary key, TaxID varchar(12), SSN varchar(12) ) GO Client can have either TaxID or SSN or both. But either one should exist. Currently, I am enforcing the rule thru following trigger. create trigger trgClient_UniqueTaxIDSSN ...

Looking for good method for versioning SQL Server databases

I have multilpe versions of my software that I need to run at any moment. We have a copy of each of our client's data in each version, which is a database. I am trying to find a good way to accomplish this in SQL Server. At first I was thinking of having everything in one once instance of SQL Server and tacking the version# on the end o...

Optimization of SQL Server Indexes

I have a table with several non PK-related indexes. Unfortunately there's some duplicity in that several indexes reference the same column with the same sort order. I typically create covering indexes which represent aggregations of non PK-related indexes for my tables because as long as the column is indexed it will use it if appropri...

SQL Transaction Error Handling

Do you guys see any problems with the way I handle errors in the following stored procedure? I am still not confident enough with SQL to realize if I am doing anything wrong. Thank you :) CREATE PROCEDURE [dbo].[UserAccounts_Create] @username varchar(255), @email varchar(255), @password nvarchar(127), @id bigint OUTPUT A...

Message Queue Task in SSIS is stuck.

I'm using message queue task in SSIS to receive message from a private queue, I set MessageType To "String message to variable" and Compare to "None" When I debug on this package, it's stuck at message queue task, I've checked the private msmq, there are some messages in it. Any ideas/Help? Thanks ...