sql-server-2008

C# asp.net cannot open user default database

I pulled an ASPNETDB.MDF off of a server for a ASP site using Forms authentication to my local machine. I added a new user to the database file using the ASP.NET Website Configuration tool. I copied the MDF back to the server and now, i get the following exception whenever I try to log in as any user: Cannot open user default database. ...

Does Entity Framwork round off decimal value to nearest integer?

Hi all, I'm using Entity Framework and MS SQL Server 2008. It seems that Entity Framework always round off decimal entity attribute to nearest integer which is really annoying. Have you seen this problem before and what's your solution? Thanks! ...

Find usage of a function in SQL server

Is there a way to find a usage of a function in SQL server 2008? ...

FreeText COUNT query on multiple tables is super slow

I have two tables: **Product** ID Name SKU **Brand** ID Name Product table has about 120K records Brand table has 30K records I need to find count of all the products with name and brand matching a specific keyword. I use freetext 'contains' like this: SELECT count(*) FROM Product inner join Brand on Product.B...

SQL FTS no results from Containstable query

Quick FTS question. I have a table(Person) with 10 varchar columns (fname, surname, hair colour, etc), I've create a FT Index on it however queries using containstable return nothing for 'AND' queries e.g. FROM CONTAINSTABLE(tablename, *, 'john AND doe', 20) or CONTAINSTABLE(tablename, *, '(FORMSOF(INFLECTIONAL, john) AND FORMSOF(INFLE...

SQL Server, find an arbitrary sequence of values

Let's assume we have a table Maintenance Customer LastLogin ActionType 1 12/1/2007 2 1 12/2/2007 2 etc. We want a list of all customers who at any point during a given year had one or more uninterrupted sequences, 14 days long, of login with action type 2. I can of course easily do this with code, and even have it be fa...

SQL server 2008: How to get the start date and end date of my data?

hi! As a newb, I already know that I will be berated for asking this question, but I did not find the answer on the site here and could use some help... I have a table that lists data by the day, and by type. For example Transaction | Date | Type ----------------------------- Updat | 11/7/2008 | Cash-out Update | 11/10/2008 ...

Looking for a script which will script out all database level persmissions( including xp_cmdshell and sql proxy account)

I need a stored procedure or script which will script out all database level permissions- including permissions to xp_cmdshell for any objects as well as permissions to a sql proxy account. Thanks! ...

Cross Database Unions

My warehouse datamart data is split across 3 databases on the same server. This is Proof-Of-Concept project with three extracts that were loaded into individual databases. While pulling into a cube, I am essentially doing this: SELECT * FROM DB1.dbo.Fact_Pres UNION SELECT * FROM DB2.dbo.Fact_Pres UNION SELECT * FROM DB3.dbo.Fact_Pres ...

The INSERT statement conflicted with the FOREIGN KEY constraint

Error: System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK__Item__order__3AE27131". The conflict occurred in database "pmall", table "dbo.ItemSaved", column 'id'. Here's my table: ItemSavedUnits id ItemID (is set in this table a FK to Item.id) ...etc. Here's my insert stat...

Cannot Specify Foreign Key Tables When Adding New Foreign Keys

I'm trying to use the Relationships dialog in SQL 2008 to add a new foreign key to a table field. When I go to add one, I am not able to change and specify the Foreign Key Base table or any others in the "Tables and Columns Specification" area...they're all greyed out for those values and uneditable and I"m not sure why. ...

SQL Server Management Studio-- widen active files dropdown?

Hi everyone, I'm using SQL Server 2008's management studio and had a question about having multiple query windows etc open. If I have seven or eight going at once obviously their tabs won't all fit on the screen. But when I go to the "active files" drowpdown at the right often times the names are truncated with an ellipsis in the midd...

Data Correlation in large Databases

We're trying to identify the locations of certain information stored across our enterprise in order to bring it into compliance with our data policies. On the file end, we're using Nessus to search through differing files, but I'm wondering about on the database end. Using Nessus would seem largely pointless because it would output the...

I really really want to use an INSERT nested in a SELECT

I know this is a task that can't be unique, but I can't seem to find a way to do what I'm thinking in my searches and reading, so if it's not possible, I'd like to know if I'm choosing the best alternative. Simple case of moving information on people from the old database to the new. The problem is that the old schema has the address on...

How is a spatial index represented

I read the documentation at msdn about spatial indexes but I do not understand two things, what are the keys for the index. how and where are the sets of covered cells represented in the B-tree. ...

Advanced search with distances using NHibernate and SQL Server Geography

I've got an existing advanced search method in a repository that checks a FormCollection for the existence of search criteria, and if present, adds a criterion to the search e.g. public IList<Residence> GetForAdvancedSearch(FormCollection collection) { var criteria = Session.CreateCriteria(typeof(Residence)) .SetResultTransformer(...

SQL Server Select and Update in the same statement?

Hello! I have an SQL Query like this: SELECT TOP (@TopType) AdvertID, IsAdvertImage, AdvertData FROM Adverts WHERE AdvertSize = @AdvertSize ORDER BY NEWID() Each row in the table Adverts also has a column called Views, is it possible to also increase views with 1 for the banners that has been fetched? So I set TopType to 4 and get 4 ...

Can't log in to SQL Server 2008 Management Studio

Hello, I think something happened to an mdf file on disk. When I try to start SQL Server Mgmt Studio (SQL Server 2008, Win 7 x64), I get an error: "Cannot open user default database." Since I can't connect at all, how do I fix this? I have tried connecting to other dbs using osql, but always get an error. Thanks for any workarounds... ...

SQL Server: How to unlock a table / row?

We recently updated our WPF application to perform its data synchronisation (using sync framework) within a single transaction against our SQL Server 2008 database. Almost straight away this has somehow led to a row being locked in of of the tables preventing all other users from syncing. The thing is that the lock does not seem to be...

SQL Server Reporting Services: combine initial rendering level and interactive expansion

I have a report in SSRS 2008 that shows data aggregated from four levels of grouping. I'm using the ASP.NET ReportViewer control to show the report on my webform. If I show all four levels in detail, the report gets very very long (hundreds of pages). So therefore, I'd like to set a default level to show (1-4) when I render the report -...