sql-server-2008

Can I create database schema based on a non-standard raw Excel format?

Schema has been described crudely in Excel as follows: tablename columnname columnid type length description table1 table1col1 1 int 4 blah blah table1 table1col2 2 varchar 15 dah dah dah table2 table2col1 1 int 4 etc table3 table3col1 1 money 10 $$$ There is a ...

Scheduling Procedures in sql server 2008 am i doing it the right way or there are issues?

EDIT : Problem with the email I get mailbox unavailable exception! DBEmail.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Xml.Serialization; using System.IO; using System.Xml; using System.Text; using System.Net; using System.Net.Mail; using System.Xml.Linq; public partial ...

SQL Server 2008 - ssas user permission

I'm new to ssas and i'm fighting with users permissions... I have a cube with a region dimension i.e region A and region B. I created a role to filter dimension data so that members of that role have only access to region A. I put user A in this role. Now, when I test this configuration, if I select the role A in the security context,...

How do I add breakpoints to a stored SQL Procedure for debugging?

I am trying to debug a SQL procedure, and am using the following query to do so. USE [database] GO DECLARE @return_value int EXEC @return_value = [dbo].[Populate] @ssId = 201 SELECT 'Return Value' = @return_value GO The problem is, the procedure I am testing, (Populate) doesn't seem to stop at any of the breakpoints I ...

Compare Every Record from Two Tables

Assuming I have two SQL tables consisting of a single column, i.e. Table 1 Table 2 a1 a2 b1 b2 c1 c2 Is there a succinct SQL command to compare each record in one table against each record in the other? (and return true if any record from table 1 matches any recor...

Elegant way to delete rows which are not referenced by other table

Hi, I have two tables (Tasks and Timeentries), which are connected by a foreign key (TimeEntries.TaskID references Tasks.ID) Now I'd like to delete all rows from Tasks which are not referenced by the TimeEntries table. I thought that this should work: DELETE FROM Tasks WHERE ID not IN (SELECT TaskID FROM TimeEntries) But it affects ...

Deleting a detached database SQL 2008

I detached a database, and when i try to re-attach it i am getting error: CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\RoadMap.mdf'. (Microsoft SQL Serve...

SQL Server 2008 Clone table with indexes in .Net

What would be the simplest way to create an exact structural replica for Table1 and all its indexes in the same database. Let's say Table1Dupl where all constraints/indexes from Table1 with suffix Dupl. I understand that I may do manual renaming "script table as " "create to" from Management Studio, but looking for fully programmatic w...

How to get the last tuple from a table with SQL Server 2008 R2?

I want to get a field from the last tuple I have inserted to a table using SQL Server 2008 R2? ...

Using SQL Server 2008 R2 with Visual Studio Express

I want to create either "LINQ to SQL" classes or use "Entity Framework" from Visual Studio Express 2010. When I attempt to add a data source my only options are: "Microsoft Access Database File" "Microsoft SQL Server Compact 3.5" "Microsoft SQL Server Database File" Do I need VS2010 Pro to use LINQ to SQL or EF? I thought I could d...

sql 2008 procedure

CREATE PROCEDURE csGorevDuzenle @duzenle int, @grup_ad varchar(30), @islem_grubu varchar(30), @tamamlayan varchar(30), @kayit_zamani datetime, @sonuc_zamani varchar(30), @arayan varchar(30), @telefon varchar(20), @tanim varchar(1000), @durum varchar(15), @aciklama varchar(1000) AS if @duzenle = 1 then BEGIN UPDATE gorevle...

Ignoring Apostrophes In Contains

Simple question, perhaps a difficult answer. We're using CONTAINS but when matching criteria containing apostrophes (because these are for French road names), then obviously they don't match. So for example, searching for "Lislet" when the database contains "L'islet" yields nothing. I've looked into using dictionaries and thesauruses ...

SQL Server Deadlocks (SQL Server 2000)

Hi, I have one customer experiencing 5+ deadlocks per day. 170+ other customers don't get any deadlocks at all. I've implemented deadlock tracing and can see the select/update/insert deadlocks occurring. I implemented a with (rowlock) hint and this sorted the initial deadlock out. However, the thing still deadlocks further on down t...

SQL Server 2008 Proc fails in 2005

ALTER PROCEDURE [Lending].[uspHMDALarIncomeGet] (@ApplicationId int) AS BEGIN SET NOCOUNT ON SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED -- Total Income Data DECLARE @ApplicantId int = (SELECT AT.ApplicantId FROM Lending.Applicant AT WHERE AT.ApplicationId = @ApplicationId) SELECT I.Amount FROM Lending....

Error: SubQuery Returned More than One Value

I've got the following piece of SQL Code that is giving me a titular error. WHERE (SELECT Tokens FROM StringSplitter(@DocumentValue, '|', 1)) IN (SELECT Tokens FROM StringSplitter(@sortValue, '|', 1)) Where @DocumentValue and @sortValue are both concatenated strings separated by a delimiter (in this case, a '|'). The...

Migrating Maintenance Plan from One Sql Server 2008 Instance to Another

I have an extensive maintenence plan on one sql server 2008 instance that I wish to move to 4 other instances. What is the best way to do this other than rebuilding it on each server? Thanks ...

save DataTable to database

Hi, I am generating a DataTable from a webservice and i would like to save the whole DataTable into one database table. DataTable ds = //get info from webservice The DataTable is getting generated but What to do next .I am getting stuck .Show me some syntax.I dont really need the select statement there either, i just want to insert al...

SQL Server restorig backup on Developement (Or Test) Server and user mapping

I got 3 server. development (my local development machine) Test purpose (Beta site). Production I got Instances in both SQL server 2005 and 2008. So, When I want updated data, i take the latest backup from our production server and restore it on the Test or development Server. I got a script that make the changes (restore the file ...

PDO and Microsoft SQL: Must declare the table variable "@P1"

I'm trying to use binding in PDO to select some entries from a Microsoft SQL database. The code I'm using looks like it's similar to what I've found in the documentation. However, when I run it, I get the warning below: Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[42000]: Syntax error or access violation: 1087 [M...

how to make a db schema such that its use is supported by all db management systems

is there a windows xp utility to make a database such that its support by sql server, oracle, and other db management systems. the database schema is very huge so i would like to know what to use to make it so its protable from sql server to oracle if future demands that change? ...