sql-server-2008

Merging rows from two databases

I have two (or more) different databases, identically structured but each containing different data. How would I go about merging the data of one database into the other? This is a harder problem than I first thought. I have a table with primary keys, so a simple INSERT INTO db1.table1 SELECT * FROM db2.table1 may fail with clashing p...

Retreive file stored as varbinary(max) filestream in SQL 2008 with MS Access

I have a MS Access 2003 mdb acting as a front end for a SQL 2008 back end. The back end contains a table with a varbinary(MAX) filestream column. I can use the front end to upload files to the database using a stored procedure. I'd like to store images in the BE for display in the front end, but I can't figure out how to bind the files s...

Connecting to a named instance of SQL Server 2008 from classic ASP

My ASP application connects to the network server where SQL Server 2000 is installed with no problem. The old code that works: myConn.Open ("Driver={SQL Server}; Server=myNetwrkServer; Database=myDB; UID=myID;PWD=myPWD;Trusted_Connection=NO;") An instance of SQL server 2008 was installed on t...

SQL 2008 Full Text Search Word Proximity

Hello Folks, I have been reading the Full Text help files for CONTAINS, FREETEXT, CONTAINSTABLE and so forth on MSDN and elsewhere, but I am not able to find the solution I am looking for. I would like to be able to query with the following criteria: Example value: "The quick brown fox jumped over the lazy dogs." Select * from MyText...

Connecting from classic ASP app to an instance of SQL server 2008

Hi, My classic ASP app is connecting to SQL server 2000 installed on a network server. The current code works: myConn.Open ("Driver={SQL Server};Server=myNetServ;Database=myDB;UID=myID;PWD=myPWD;Trusted_Connection=No;") Now my app needs to connect to a named instance "SQL2008" of the SQL server 2008 installed on the same network serve...

Hirerchy Query Help Required

Hi Guys, I have an oracle background and now working on a project which is SQLServer based so stuck and therefore need your help. I have the following tables which I am using for Menu Management and Tree Population. Menu menu_id -------> (PK) int menu_name ----> varchar(30) Menu_Template node_id -----> int node_name --> varchar(50...

Split concatenated field into separate parts

Using SQL Server 2008, I am trying to do something similar to this post regarding splitting a concatenated field into separate parts for normalization purposes. The problem with the solutions in the linked post is that they only work for delimited values. The data I am attempting to split would be similar to: UserID -- ConcatField 1 -...

Problem getting the progress status of a SQL-Server restore job

I want to use the script from http://www.wisesoft.co.uk/articles/tsql_backup_restore_progress.aspx to get progress information of a specific running SQL-Server restore job. To achive this, I have changed it a little bit: SELECT command, s.text, start_time, percent_complete, CAST(((DATEDI...

Differences Between SQL Server 2008 and SQL Server 2008 R2 from a developer's POV

I am setting up my development machine and I am wondering if I should install SQL Server 2008 R2 (for Developers) or SQL Server 2008 (for Developers) on my machine. All of the databases that I work with are on SQL Server 2008 (not the R2). So I am torn. Should install what I am currently using? or should I be a bit forward looking an...

Entity Framework and Sql 2008 always wants to recreate

After having some trouble with Entity Framework and SQL 2008 I decided to do a simple test so I created the following class. After testing it with a generated sdf I created a table with the same structure in a test database using sql 2008. public class People { [Key] int ID { get; set; } string FirstName { get; set; } st...

SQL advanced query - problem with single row aggregate sub query in select clause

I'm trying to execute the following query but I receive a runtime error stating that: "The column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause." Line number two below is the one that fails with the error above. I don't understand why this query doesn't execute as no g...

How to create Sub Item on Xml Linq

In northwind database .I use order and orderDetails table.I want to create a xml file ,where order show on Item tag on XML and orderdetails show on sub item.Suppose orderid=1 show on Item tag then orderdetais**table information of **OrderID=1 show on sub-Item. XElement xml = new XElement("MyMenu", from c in db.Ord...

Avoid NULL columns using DEFAULT Empty String

Hi, how can I create a Column with the default value being an empty string? thanks guys! ...

Safest way to get last record ID from a table

In SQL Server 2008 and higher what is the best/safest/most correct way to retrieve the ID (based on autoincrementing primary key) out of the database table? to retrieve the value of the last row of some other column (like, SELECT TOP 1 FROM Table ORDER BY DESC)? ...

Database design to support multiple clients

If you were building a database with tables Documents, Clients, Users and Firms, where in Firms you would store the companies that use the software how would you design the first three tables to support multiple Firms to store in them? So, in Documents we want to store documents for all the firms, of course, we need to tell them appart s...

books/links/samples on Microsoft Sync Framework for sqlite sync with sql 2008

Hi, i'm new to Microsoft Sync Framework and trying to synchronise an sqlite db with sql server 2008 and so fare I read about it on the following websites: http://sqlite.phxsoftware.com/forums/p/1381/6011.aspx http://www.vitalygorn.com/blog/post/2008/01/Microsoft-Sync-Framework-Support-in-Visual-Studio-2008.aspx http://www.codeproje...

idea to write procedure?

i pass parameter as productid, i check in productrelated table whether this product related product are there or not if it is not there i want to check sample productid in departmentreplated table if it is not there i find the department of the productid and find the that productid related department product.. Plz help me how to wri...

Copying rows in a database when rows have children

I need to make a copy of a row in a table and also copy all the rows that link to it via its foreign key in other tables. And then copy all the rows that link to these rows. The problem is when I make a copy of the row the key is going to change. How can I propagate these changes through the relationships between tables? ...

Find "missing" records in a bridge/data-intersect table

I'm generating images from an original and storing them in a table. I want a query that will check for gaps. The image sizes are kept in a 3rd table, and each original should have 1 generated image for each record in the type table. Where's what I've got so far: SELECT oi.OriginalImageID, it.ImageTypeID FROM dbo.OriginalImages AS...

SQL Server 2008: Backing up database before running stored procedure

I have a stored procedure that runs once a week that's initiated by the user through the click of a button on our internal website. I'd like to automatically backup the database before the code in the procedure actually runs. So I've created a separate stored procedure with the following code: DECLARE @Path varchar(50) SET @Path = '\\1...