sql-server-2008

In SSMS is there a way to generate a script for table creation based on the table output by a view?

In SSMS is there a way to generate a script for table creation based on the table output by a view? ...

What are my options for a search engine database on windows

I have a project to create a high traffic search engine similar to altavista.com. The windows .NET C# will be used for the project. I am looking for a good search engine database that can handle a very high load. I have taken a look at lucene and sql server 2008. I have read that lucene tends to get corrupt when the load is very high. So...

How to Rename a Database without losing data?

HEllo All, I am in a problem in my sql database.I have a DB in sql 2005.I just want to rename that DB and want it in sql 2008 without losing its data.For examble,i have a mdf and a ldf file of a DB named "Hello" in sql 2005 with a 1000 data,i want to save this DB in sql 2008 in another name "HAi".Anybody please help me....... ...

Split Multiply Arrays Loop Trough Records and Insert Records in SQL server 2008

Hi I am trying to split multiple arrays and insert them into SQL Server. From my query string I receive the following Sport.aspx?ReaderID=A1B5A0F5C4E4A1B5A0F5C4E4&DataID=11B6C56A90B645B6C56A90B6,10 Oct 2010 13:15:20,|22B6C56A90B645B6C56A90B6,10 Oct 2010 14:15:26,|&Msg=04 What I need to do is split the pipe delimited field into MyTagI...

Merge 2 SQL Server databases

I need to merge 2 SQL Server 2008 databases. The scenario is as follows: I have a test server and a production server. They differ a little from structure. The test server has some extra tables. Now I need the structure of the test database on the production server, with the data from the production database. What is the easiest way ...

Is their an elegant way to track the modification of all columns of one table in SQL Server 2008

There is a table in my database containing 100 columns. I want to create a trigger to audit the modification for every update operation. What I can think is to create the update clause for all columns but they are all similar scripts. So is there any elegant way to do that? ...

Setting IsPrimaryKey=true on column in table with no primary key

Hi, I'm writing a quick app using LINQ to SQL to populate a db with some test data and had a problem because one of the tables had no primary key as described by this bloke Can't Update because table has no primary key. Taking the top answer I added the IsPrimaryKey attribute to an appropriate column and the app worked even though the...

SQL: Need to return specific dates for sku's

Here is what i have: UPDATE webdev.tempdb.dbo.MediaResource SET Date_Min_Enabled = PRAH.DateCreated FROM FeedBack.dbo.Part_Resource_Associations_History as PRAH JOIN WebDev.DataWareHouse.dbo.Inventory as I on I.SKU = PRAH.PartNumber JOIN FeedBack.dbo.Part_Resource_Associations as PRA on PRA.PartNumber = I.SKU This only return...

How to commit and rollback transaction in sql server?

Hi, I have a huge script for creating tables and porting data from one server. So this sceipt basically has - Create statements for tables. Insert for porting the data to these newly created tables. Create statements for stored procedures. So I have this code but it does not work basically @@ERROR is always zero I think.. BEGIN TR...

Is there a better way to write this query?

So let's say I'm trying to get a list of all my users who belong to a certain user group. Easy: SELECT * FROM users, usergroups WHERE usergroups.user_group_id = 1 NOW, let's say I want to get a list of all users who belong to a certain user group AND who have an email that ends in .edu. SELECT * FROM users, usergroups WHERE use...

SQL: Counting Problem relating to two tables

I have a table with columns : Sku, Count in another table there are sku's with different images, so in this table one sku is repeated several times with multiple file extensions, what i need to do is to count the number of images that a sku has in the second table and then update the count column in the first table with that number. I w...

LINQ to Entities, several one-to-one references to the same tables and naming

Hi, I've started porting a .NET SQL Server application to LINQ to Entities. I have (among others...) one table called Users, and one called Time. Time is reported on a specific user (UserId), but it is also recorded which user made the report (InsertedByUserId) and possibly who has updated the Time since insert (UpdatedByUserId). This g...

SQL And NULL Values in where clause

So I have a simple query that returns a listing of products SELECT Model, CategoryID FROM Products WHERE (Model = '010-00749-01') This returns 010-00749-01 00000000-0000-0000-0000-000000000000 010-00749-01 NULL Whitch is correct, so I wanted only get the products whose CategoryID is not '00000000-0000-0000-0...

Why does SQL Server 2008 order when using a GROUP BY and no order has been specified?

I'm running into a very strange issue that I have found no explanation for yet. With SQL Server 2008 and using the GROUP BY it is ordering my columns without any ORDER BY specified. Here is a script that demonstrates the situation. CREATE TABLE #Values ( FieldValue varchar(50) ) ;WITH FieldValues AS ( SELECT '4' FieldValue UNION AL...

Database Design for an Internal Admin Chat System

Hi, I'm trying to implement an internal chat system for our admins to use, but I'm not too sure on the database design. I have this (below) so far, but would appreciate a verification and/or recommendation for improvement. Employees { EmployeeId (smallint) // ... } Chat { ChatId (int) Stamp (datetime) // Obsolete, ignor...

Studio Express connect failed (SQL Server 2008)

I got this error A network-related or instace-specific error occurred while establishing a connection to sql server . the server was not found or was not accessible. verify thai the instance name is correct and that sql server is configured to allow remote connections. (privider: Named Pipes Provider,error:40...

Is there a way to specify a cascading delete, on a query by query basis?

On a project I'm working on we've got some tables with numerous foreign key relationships, and because it's in early development the number of relationships will likely change. We'd like to be able to delete records from certain tables but are reluctant to set up cascading deletes on the foreign key relationships. We've considered the ...

Which edition of SQL Server 2008 should I install on dev machine?

Which edition of SQL Server 2008 should I install for development purposes? I'm presuming the developer edition, but... What I do is (SQL Server 2005 until now): Develop databases to plonk onto our web server (that runs SQL Server Express) Manage and extend these database using the SSMS (SQL Server Management Studio) Develop SQL Se...

Why is my SQL Server faster when restarted?

We have a .net winforms application accessing a SQL Server 2008 database over .net web services. Occasionally our application behaves very slow, but after restarting the SQL Server service, the application performs much faster. We do have automatic scheduled job that runs every night to clear buffer and procedure cache with following c...

SQL Server Error "Could not open a connection to SQL Server"

Hello. I know this is a known issue. But I've tried everything I found out and I can't solve it yet. I've a .Net winforms app. It needs to connect to a SQL Server in a remote server in the same network. It works perfectlly in my machine, but it doesn't in antoher machine from my work. Both machines have Windows 7 and installed the SQL s...