sql

using try catch for update

Because I am a newbie I am trying to log out any errors that may occur with stored procedures I write. I understand Try/Catch in SQL 2005 and error_procedure(), ERROR_MESSAGE() and the other built in functions. What I can figure out how to do is capture what record caused the error on an update. I could probably use a cursor and loop ...

Using ASP and INSERT INTO -

Hey, I am trying to create a simple page that enters data in to a database and my code is below. <%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit %> <!--#include FILE=dbcano.inc--> <% dim username,password,f_name,l_name,objConn,objs,query username = Request.Form("user") password = Request.Form("pass") f_name = Request.Form("fname...

What is wrong with this query? Can't get ROW_NUMBER() to work.

SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY hrl.Frn) as Row, hrl.unq, hrl.LcnsId, hc.Business,hc.Name,hc.Phone, hrl.Frn,hrl.CallSign, hrl.gsamarkettypeid, gmt.[Market Type Code] + ' - ' + gmt.gsamarkettype, hrl.gsalatitude,hrl.gsalongitude, rsc.RadioServiceCode + ' - ' + rsc.RadioService, GrantDt, Ex...

SQL CASE Statement

Hi, Is the following possible in SQL Server 2000? CREATE FUNCTION getItemType (@code varchar(18)) RETURNS int AS BEGIN Declare @Type tinyint Select @Type = case len(@code) WHEN 12,14,17 THEN 1 WHEN 13,15,18 THEN 2 WHEN 8,10 THEN 3 ELSE 0 END RETURN (@Type) END Thanks ...

Moving tables with a certain prefix to a new database

I have a bunch of tables in a sql server database (all with a certain prefix, e.g. ABC_table1), and I want to move ALL tables with this prefix to another database. Is there a way in which this can be done? I am using SQL Server 2k5. Thanks ...

Where did Open Table go in SQL Server 2008?

As of SQL Server 2005, you used to be able to open a flat file in SQL Management Studio off the right click menu for any database table. Once opened, you could add or update records right there in the grid. Now that SQL Server 2008 is out, Microsoft has hidden that feature, at least from the right-click menu. Where did it go? ...

How to find fifth highest salary in a single query in MS Sql Server

How to find fifth highest salary in a single query in MS Sql Server ...

How to Search date in SQL?

Hi, I am having an Event Management System in which i want, If an event is registered for 5 days (21 jan 2009 to 26 Jan 2009) Then if another person wants to register an event between 22 jan 2009 to 24 jan 2009 then it will not allow to register. I want to check this using SQL query, so please tell me how can i do this. ...

Should I use SQL triggers?

Hello, I am implementing a data base design that has a vehicle table, vehicle engine and vehicle gear table with SQL 2005. Each table has an ID that is a SQL identity number, and each engine and gear has a relation with the vehicle ID. So before I create a vehicle I must create an engine and gear. How could I know the vehicle identity...

Linq to sql error with identitiy increment field

I've just started to use linq to sql and have run into a problem with inserting a record with an auto incrementing field. I have created a new instance of a company object defined by linq. it has initialised an auto incrementing field 'companyID' to 0. InsertOnSubmit() fails with the following invalidOperationException. Incorrect au...

Very strange SQL update issue

I have a table called ApprovalTasks... Approvals has a status column I also have a view called ApprovalsView When I try a straight update : update ApprovalTasks set Status = 2 where ApprovalTaskID = 48 I'm getting this error message: Msg 2601, Level 14, State 1, Line 1 Cannot insert duplicate key row in object 'dbo.ApprovalsView' ...

Mapping existing tables to Domain classes in C#

Hi, I don't even know if I'm using the correct terms but here goes: Is there a way to map the tables and their relations in a SQL Server to domain (C# code) automatically, by means of a tool or something? I've used the nhibernate plugin, but it creates a file in .cs and another in xml, that has the mapping, but I want that mapping to b...

Why is the default length for VARCHAR 30 when using CAST?

In SQL server 2005 this query select len(cast('the quick brown fox jumped over the lazy dog' as varchar)) returns 30 as length while the supplied string has more characters. This seems to be the default. Why 30, and not 32 or any other power of 2? ...

Classic ASP Database error

Well I am querying my DB, a table called bookBilling, to get a value under the column of billingID. In my first query I get the customer ID from a table based on what value the cookie holds. In my second query I take that custID value and am looking to get the billingID associated with it. query = "SELECT custID FROM bookSession WHER...

sql reporting serices not showing anything when go to web interface

Hi, A client has installed Sql server 2005 reporting services. When we go to the web bit at http://servername/reports/ we just see a blank screen like: http://img91.imageshack.us/img91/3787/rsblankqx4.jpg We are using windows authentication and I think it has authenticated us as the "site settings" button is appearing and we can alter ...

master detail binding using wpf/linq to sql

I'm trying to create a master detail view of a linq to sql relationship in wpf. The view will have two comboboxes. One for selecting the master item and another for selecting the detail item. I have achieved this using an ADO.Net Dataset containing two tables and a relationship between the tables. where the first combobox binds to the ...

Windows Workflow Foundation persistence schema explanation?

I'm trying to debug a workflow project that's using the default WF SQL persistence schema. Does anyone know of a good explanation for what the data in each table represents? ...

Oracle record history using as of timestamp within a range

Hi all, I recently learnt that oracle has a feature which was pretty useful to me - as the designer/implementator didn't care much about data history - I can query the historical state of a record if it's available yet in the oracle cache, like this: select * from ( select * from sometable where some_condition ) as of t...

Best way to update table schema for huge tables (SQL Server)

I have a few huge tables on a production SQL 2005 DB that need a schema update. This is mostly an addition of columns with default values, and some column type change that require some simple transformation. The whole thing can be done with a simple "SELECT INTO" where the target is a table with the new schema. Our tests so far show tha...

Native C++ SQL Framework

I need a high performance framework in native C++ for SQL. I need it to be able to use MySQL, Oracle and Microsoft SQL Server and provide abstraction from the lower level problems/idiosyncrasies found in every different syntax required for by DBMS from different vendors. Something like LINQ for C# and VB .Net. ...