sql-server-2005

Can I have an editable computed-column?

Is it possible to edit computed-column values? I have a computed-col in my table, sometimes, I need to enter an individual value that is not the computed value. Is there a way to store it in the computed col, or I have to make an additional col? ...

I want to have a SQL computed column according to rules

Hi all! I want to be able to store a decimal value in one column, and in the other column to store an int that represents the option (will explain): should be base -% should be base -absolute should be base +% should be base +absolute 1 & 2 is a discount 3 & 4 is an upcharge 1 & 3 reduces/raises the amount by percentage (i.e. amount *...

INSTEAD OF UPDATE Trigger and Updating the Primary Key

Hi, I am making changes to an existing database while developing new software. There is also quite a lot of legacy software that uses the database that needs to continue working, i.e. I would like to maintain the existing database tables, procs, etc. Currently I have the table CREATE TABLE dbo.t_station ( tx_station_id VA...

Help with hard sql query to update based on daily totals to summary table

The following are my sql server 2005 table structures: Products (productID INT PK, ...) ProductBids (productID INT, userID INT, Created DATETIME) Users(UserID INT PK, TOTALBIDS INT) Each day a user can bid as many times as they want on all the products. There is a sql job that is run periodically, that counts the total bids a user ha...

Hide relationship from a SQL Server database diagram

I am using SQL Server 2005 database with SQL Server Management Studio. Is there a way to hide a relationship between two tables in the diagram without actually deleting the relationship from the database? Any help will be most appreciated. ...

Splitting out one table to a separate server

Hi all, Background, I am running MS SQL Server 2005. What do you guys think about this. I have an analytics process whereby a stored procedure is fired off on every page of my website and the results logged into my analytics table. Given that I have thousands of users on my site daily, this a very frequent albeit "light" overhead to ...

SQL Server - OPENQUERY

I am using an Openquey which has been working fine on SQL Server 2005, I have 1 server that is SQL Server 2008 which this does not work on. If I run the following: SELECT * FROM OPENQUERY([Manchester], '[Manchester].[PilotWebApp].[DBO].rsp_HandheldPerformance ''10/01/2009'', ''10/10/2009''') I get this error: Cannot ...

Avalability Table/View for Hall Booking

I am doing a hall booking application. There are many halls at an establishment. There is a fixed start time and end time for the all the halls, within which the slots should fall. These are defined in the Hall table with the fields HallID, OpeningTime, ClosingTime. The table HallBooking contains the booking details. The fields are H...

Slow (to none) performance on SQL 2005 after attaching SQL 2000 database

Issue: Using the detach/attach SQL database from a SQL 2000 SP4 instance to a much beefier SQL 2005 SP2 server. Run reindex, reorganize and update statistics a couple of times, but without any success. Queries on SQL 2000 took about 1-2 sec. to complete, now the same queries take 2-3 min on the SQL 2005 (and even 2008 - tested it there...

Error calling remote scalar-valued function

I am making a call from a sql 2005 database to a sql 2000 scalar-valued function and recieve the following error message: Remote table-valued function calls are not allowed. here is my call: select * from [server/instance].[db name].dbo.[function name](param1, param2) not sure why it says table-valued function, but that's the error...

SQLServer Query optimization question

I have a project that was "spiked" using Linq2SQL and is now running into some major query performance issues. Go figure. Linq actually works pretty well in simple query and command scenarios, but there are a couple filter intense queries that need to be rewritten as Sprocs. I'm wondering if someone can give me some high level pointer...

generate database & tables schema (ddl) on Oracle pl-sql

Hi, Anyone have a PL-SQL statement that i can use to generate database & tables schema for specific database on Oracle 10g? I need the schema in .sql file and if possible compatible with ANSI-92/99 sql implementation, so i can use the generated .sql directly on sql server 2005. Already heard about exp/imp, but it seems generated dump f...

How to converting string builder to string without escape sequence in the converted string

Hi, I am writing some XML data to the stringwriter. I want to pass the values in the stringwriter to the database but when I convert it to a string like StringWriter.GetStringBuilder().ToString() it is converting all the " (double quotes) to \" So when I pass that to database as parameter and when I try to read the data using openX...

unable to start sql 2005 on windows 2003 two node cluster

SQL server Agent is not starting...... In the SQLAGENT log i found this error....... 2009-10-24 22:49:36 - ? [393] Waiting for SQL Server to recover databases... 2009-10-24 22:49:40 - ! [298] SQLServer Error: 5845, Address Windowing Extensions (AWE) requires the 'lock pages in memory' privilege which is not currently present in the ac...

Problem in LINQtoSQL with dual schema in Database

I have two tables, both named as say, Employee in two different schema HR and Production [i.e. dbo.HR.Employee and dbo.Production.Employee are my two database objects]. While dragging these two tables in LINQ to SQL design pane its generating two classes named Employee and Employee1. My ques: Is there any way I can create classes with Da...

SQL Update columns passing into the query the column name and value

Hi, I have the following code: UPDATE myTable SET Col1 = @Value However, I have a table that has over a 100 columns and want to be able to specify a column name by passing the name into the query similar to: UPDATE myTable SET @ColName = @Value When I do this I get an error. Is there a good solution to this? Its probably s...

How do you deploy a BLANK copy of your SQL 2005 express database with your ASP.NET project?

Age old question! When you have finished developing and testing your ASP.Net web application, the database you want to deploy is now full of test information and needs to be emptied (and identity fields reseeded to 1) before you deploy. When using a server instance, this isnt difficult (create a SQL script to do the job) but when using ...

DataTable Update Problem

Hello, What is the best method for saving thousands of rows and after doing something, updating them. Currently, I use a datatable, filling it, when done inserting by MyDataAdapter.Update(MyDataTable) After doing some change on MyDataTable, I again use MyDataAdapter.Update(MyDataTable) method. Edit: I am sorry for not providing m...

SQL: "Write Protect" row of data possible?

May be a stupid questions but can I protect a row of data in a SQL Server database from being deleted or updated without setting user permissions? This is for a default row of data that can be referenced for its default values? Thanks ...

SQL Server 2005 - Check for Null DateTime Value

Hello, I'm trying to count the number of records that have a null DateTime value. However, for some reason, my attempts have failed. I have tried the following two queries without any luck: SELECT COUNT(BirthDate) FROM Person p WHERE p.BirthDate IS NULL and SELECT COUNT(BirthDate) FROM Person p WHERE p.BirthDate = NULL What...