sql-server

Is SQL Server DRI (ON DELETE CASCADE) slow?

I've been analyzing a recurring "bug report" (perf issue) in one of our systems related to a particularly slow delete operation. Long story short: It seems that the CASCADE DELETE keys were largely responsible, and I'd like to know (a) if this makes sense, and (b) why it's the case. We have a schema of, let's say, widgets, those being ...

Random Function from SQL Server database in ASP .NET

I am creating a webpage which is using asp .net as its backend. I need to grab categories from my database which is SQL Server. I am using this code right now For Each row00 As DataRow In f_oDatatable(7).Rows sCategories += row00.Item("Category").ToString & " / " Next If sCategories.Length > 0 Then sCategories = sCategories.Su...

Conditional Update stored proc is firing a trigger always

I have a stored procedure that says update table1 set value1 = 1 where value1 = 0 and date < getdate() I have a trigger that goes like CREATE TRIGGER NAME ON TABLENAME FOR UPDATE ... if UPDATE(value1) BEGIN --Some code to figure out that this trigger has been called -- the value is always null END Any idea why this trigger is ca...

In SQL Server 2008 is there a way to generate a report as to how much space on disk each table takes?

IN SQL Server 2008 is there a way to generate a report as to how much space on disk each table takes? I can do it one by one by checking the storage properties, but I was wondering if there was a way, maybe even a query to generate such a report. ...

Save a binary file in SQL Server as BLOB and text (or get the text from Full-Text index)

Currently we are saving files (PDF, DOC) into the database as BLOB fields. I would like to be able to retrieve the raw text of the file to be able to manipulate it for hit-highlighting and other functions. Does anyone know of a simple way to either parse out the files and save the raw text on save, either via SQL or .net code. I have f...

In sql server, is there any way to check whether the schema change will impact on the stored procs?

In SQL Server, is there any way to check whether the changes in the schema will impact Stored Procedures (and/or Views)? For example a change of the column name in one table, may break some Stored Procedures; how to check the impacted stored procs? ...

OpenDataSource fails pls help

I'm trying export records from SQL Server 2008 to mdb file using OpenDataSource. It works when I log in using Windows authentication. But it fails when I use SQL Server authentication. This is the error i get OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Could not delete from specified ...

Using memtables in sql. When is it reasonable and is it safe?

I was just reading an update from a friend's project, mentioning the use of memtables to store data temporatily and then flush to a table on disk. Up to now, I have never faced a situation where I would use a memtable, or a situation where I would think the use of a mem table would be beneficial; so I wonder, when would someone use mem t...

Exporting SQL Server Databases for offline use

I have a desktop application (C# .NET 3.5) that uses a SQL server for it's database. I have had a request from the client, however, to make it possible to export the database as it stands, and be able to use it on a laptop without connectivity. They understand that updates to the parent server will not be reflected in these offline clien...

Selecting a user-defined scalar function that takes as a parameter another field

I have a table a with a list of id's, and a user-defined function foo(id) that takes the id and returns a VARCHAR(20). What I am trying to do is: SELECT id, foo(id) AS 'text field' FROM a However, instead of calling the function for each ID number, like I desired, the text comes back the same for every row. I have tested the foo() f...

Automation Error upon running VBA script in Excel

Hi guys, I'm getting an Automation error upon running VBA code in Excel 2007. I'm attempting to connect to a remote SQL Server DB and load data to from Excel to SQL Server. The error I get is, "Run-time error '-2147217843(80040e4d)': Automation error". I checked out the MSDN site and it suggested that this may be due to a bug assoc...

How can I improve my select query for storing large versioned data sets?

At work, we build large multi-page web applications, consisting mostly of radio and check boxes. The primary purpose of each application is to gather data, but as users return to a page they have previously visited, we report back to them their previous responses. Worst-case scenario, we might have up to 900 distinct variables and around...

How to make a table Read Only in SQL Server?

Hi, i am updating some set of records in that table , after that i need to make this table read only. So How to make a table Read Only in SQL Server? Regards, Jeyavel N ...

how to enforce multiple unique fields in database table

i have a table called Cars and the primary key of the table is 'id'. I also have a field called 'name'. I would like to make sure no one enters the same name twice even though it wont break my db integrity. what is the best way of doing this? ...

Why can’t I create a database in an empty ASP MVC 2 project using Project->Add->New Item->SQL Server Database?

I'm diving head first into ASP MVC and am playing around with creating and manipulating a database. I did a search and found this tutorial for creating a database, however when I follow it, I get this error right at the start when trying to add a new database to my fresh, empty ASP MVC 2 project... A network-related or instance-speci...

Different EF Property DataType than Storage Layer Possible?

Hi, I am putting together a WCF Data Service for PatientEntities using Entity Framework. My solution needs to address these requirements: Property DateOfBirth of entity Patient is stored in SQL Server as string. It would be ideal if the entity class did not also use the "string" type but rather a DateTime type. (I would expect this t...

sql server 2008 export to mdb issue

Hi i'm trying to import records from a mdb file to sql server 2008. i have a separate db server and application server. wrote a stored proc to import data from mdb. But it fails as the mdb is on a network. It works if it's on the db server itself. i'm using sql server account. if i login using windows account and try the same sp it w...

INNER JOIN Returns Too Many Results

I have the following SQL: SELECT * FROM [Database].dbo.[TagsPerItem] INNER JOIN [Database].dbo.[Tag] ON [Tag].Id = [TagsPerItem].TagId WHERE [Tag].Name IN ('home', 'car') and it returns: Id TagId ItemId ItemTable Id Name SiteId ------------------------------------------ 1 1 1 Content 1 home 1 2 1 2 Cont...

Convert a SQL Server database to MYSQL database

Alright so I want to convert an already exist SQL Server database (2005) to a MYSQL database. There is nothing extraordinary to be done The only things I need to achieve is Recreate the tables Transfer data Relationships would be nice but not necessary No views, no sprocs, no functions. Any easy way to do this. Also do you know o...

Is there a way to make Identity Specification show up in the table designer next to the Allow Nulls column?

I would like to be able to see the Identity Specification (not as worried about seed/increment) and hate having to scroll around on the column properties panel. Is it possible to add a column next to Allow Nulls in the table designer for Identity Specification? Specifically I am concerned with MS SQL Management Studio 2008. ...