sql-server-2008

All or None with SQLMetal?

I was looking to create a pre-build method for a web application using SQLMetal to bring any changes since the last build into my DBML file. Since we are just starting out with LINQ most of the large database is not in the DBML. Is there any way to use SQLMetal to just regenerate a handful (less than 10) of tables and about 3 SPROCs or...

Sql server Integration Services 2008-2005 compatibility

I recently developed an SSIS package on my dev machine using the 2008 version. Later I foud the customer had Sql server 2005 and doesn't plan to upgrade anytime soon. Is there a way to turn the 2008 package into a SSIS 2005 package, like a downgrade wizard? ...

Sql Server merge replication primary key violations

Using Sql Server 2008. Pretend I have a publisher and 2 subscribers A and B. The replicated table has a guid on it and also a primary key that is not the guid. Frequently, updates happen at both subscribers near simultaneously generating 2 different guids but the same primary key. Then when they go to syncronize I get primary key vio...

SQL Server 2008: TOP 10 and distinct together

As the title says, I'm using SQL Server 2008. Apologies if this question is very basic. I've only been using SQL for a few days. Right now I have the following query: SELECT TOP 10 p.id, pl.nm, pl.val, pl.txt_val from dm.labs pl join mas_data.patients p on pl.id = p.id where pl.nm like '%LDL%' and val is not null What I wan...

How do you generate INSERT stored procedures for all tables in a SQL2008 database?

I have a bunch of tables and I need to create basic INSERT stored procedures for all of them. Does anyone have anything that does this or a good start to do this? ...

SSIS: "Failure inserting into the read-only column <ColumnName>"

I have an Excel source going into an OLE DB destination. I'm inserting data into a view that has an INSTEAD OF trigger that handles all inserts. When I try to execute the package I receive this error: "Failure inserting into the read-only column ColumnName" What can I do to let SSIS know that this view is safe to insert into be...

Update Query/...

create procedure USP_Insert_Update_emp(@IntId int ,@chvmobile (20),@Chvename varchar(20),@intOutparameter int) as begin if (@IntId = 0) --Means user want to insert. /* /* Then I check here that, if mobile already exists then (In table id is auto generated) and for inserting user will enter @...

Is there an alternative to the Adventureworks database for SQL Server 2008?

I want to use something lighter than adventureworks. Is there an alternative at all? I have had a look at the Chinook database, but I just want see if there is an alternative. Google search doesn't help either. ...

Stored Procedure in SQL 2008

I have create a stored procedure with VB.NET This procedure goes to a remote Server (for the moment on my near server Win 2003) until now everything are ok The procedure is created and i call her from my program The name is sp_AddStreamDB mycommand = new sqlcommand("EXEC sp_AddStreamDB 'C:\sqlDATA\', 'RemoteDB'",RemoteSQLConn) myComm...

Troubleshooting SQL Server connection issues.

I'm relatively inexperienced at SQL Server, but am trying to troubleshoot some of the (non-SQL Server-related) logic and UI issues in a Delphi app someone else wrote which uses it. Currently trying to get the dev environment functioning. Here's the environment: Dev machine: Virtual machine (VMWare) running Windows XP, using Bridged Net...

What should be the table contain updated row for update trigger...

Hi everyone, A while ago i read the article for Trigger in SQL Server, and it said that i can use the Logical Table "Updated" for updated rows... And i got error: System.Data.SqlClient.SqlException: Invalid object name 'Updated'. After a while of google, i found out some more post that said only 2 logical tables available are: Insert...

Cannot use text, ntext, or image columns in the 'inserted' and 'deleted' tables.

Cannot use text, ntext, or image columns in the 'inserted' and 'deleted' tables. What should be the workaround in this case? :( ...

On which field was the keyword found? SQL Searching

I'm trying to make a detailed search engine for my web site. The keywords are being searched in multiple fields and tables. For example, using keywords: uludag university These keywords are being searched in the education, address, contactname, and contactsurname fields in my Members table. I have to do it so because there must b...

SQL Server 2008: Filtering Out Duplicate Rows Based on Multiple Columns

Hi, Thanks to everyone who helped me with my last question. This is a similar question, but now I have a better idea of what I want. Again I'm using MS SQL Server 2008, and I'm trying to figure out a query that is a little beyond my week of SQL experience. Right now I have the following simple query SELECT pl.val, pl.txt_val, pl.id FR...

Retrieve Last n number of records in SQL Server 2008

tblCurrent_locations Id BusNo Date Time 1 mh30q121 2009/12/18 11:00:00 2 mh30q121 2009/12/18 1245:30 3 mh30q121 2009/12/18 11:30:00 4 mh30q121 2009/12/18 1015:00 5 mh30q121 2009/12/18 11:00:00 6 mh30q121 2009/12/19 13:00:00 7 mh30q121 20...

Creating Stream DATABASE in a remote server

Whith the assistance of a very good fellow from this forum (Mr. DJHnz) i solve my first issue regarding the creation of a stream database Now i'm facing another issue I'm giving you the code: USE [master] GO /****** Object: StoredProcedure [dbo].[sp_AddStreamDB] Script Date: 12/21/2009 09:55:47 ******/ SET ANSI_NULLS ON GO SET QUO...

sql stored procedure that selects from array/list/xml input parameter

Hi All, I’m looking for idea’s/solution to the following problem. Require a stored procedure that accepts a single parameter (array, list, collection, xml, etc…). For each item in the array/list/collection/xml it will execute a query like this: Select * from <some table> t Where t.Name = Parameter.Name and t.datetime = Parameter.dat...

Trying to restore via t-sql script. Exclusive access could not be obtained because the database is in use.

I'm trying to restore backups of our production databases to our development server. When I run the following script which has previously worked: RESTORE DATABASE M2MDATA01 FROM DISK = 'C:\Install\SQLBackup\M2MDATA01.SQLBackup' WITH REPLACE, MOVE 'M2MDATA01' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\M2...

Get TOP rows out of child table WITH inner join

I want to inner join with a child table based on ID and get the top Row of the child table, I am not joining to take any data out of the child table, its just to validate that child table record exists for parent table. If I dont include TOP row there is chances of getting multiple rows of parent in the result set. -- Chances of multipl...

Production SqlSiteMapProvider issue - all the items 'disappeared'?

Hello, We have several ASP.NET applications that use a sitemap which is populated via a VB.NET implementation of the SqlSiteMapProvider example found at Wicked Code. It is compiled to a DLL, then installed and referenced from the GAC on the servers and from our locals as well. It has been working in production just fine for a few months...