sql

sql trigger on specific data with column

Hi I am trying to create a trigger on a database called dbo.DHCPReport, which has a column called "returneduserclass nvarChar(128)". I want to have the trigger send a email when the returneduserclass column is populated with the following "NACDeny". the trigger I have is below, currently all this does is email when any "insert" occurs ...

Getting random and last value from group in SQL

I have a SQL table containing train schedules. The table looks something like this: Schedule TrainNumber LegID DepartureTime DepartureStation ArrivalTime ArrivalStation My real database contain several tables, but for this question only the one above is relevant. Different trainNumber can have different amount of legs. Based on a dep...

SQL join using CSV values ? Using Xml maybe ?

Hi, I'm trying to join two SQL tables, parent (which I have complete design control over) and child (which I cannot change). I have changed the parent table so that it has a varchar column, containing a CSV list of the ids of the child records. I would now like to do a select returning one row per parent, and some counters re. the child...

Using NULL in MySQL

The data in my dabatase comes from an external source and where ever there is no data passed, I keep NULL in those places. Can anyone tell me if there are any implications in using NULL to represent empty value? Should I follow some other convention like 'data_not_available'? or something like that? Can anyone suggest? ...

How do I create a nested has_many or belongs_to relationship with DBIx::Class?

In my code I have three classes as follows: Forum, Forum::Thread and Forum::Post What I want to do is create a belongs_to-relationship from the Forum::Post class to the Forum class and vice versa with a has_many, preferably without creating a custom function for it. (This is admittedly more of an intellectual exercise than a technical l...

whether the 'identity' used in sql server has been used twice inside same table.

whether the 'identity' used in sql server has been used twice inside same table. ex: i need to insert some set of records with the identity column starting from 0,1,2.... and when i insert some another set of records again the identity must start with 0,1,2.. is there is any possiblity to achieve that using the identity seed. ...

Mapping complex result set with Dom4j

I'm trying to create an XML document from a complex result set, i.e. a result set with multiple joins, so a competition has a bunch of questions, and a question has a bunch of answers. So the document would end up looking something like: <competitions> <competition id="12"> <question id="3"> <answer id="34"> The ans...

How to find unused tables in SQL Server

Is there a way of finding out when the data was last entered into a table? I'm trying to find obsolete tables within my database and would like to know if there is a simple script(s) that I can run? ...

Help with generating a report from data in a parent-children model

Hi, I need help with a problem regarding data saved in a parent-children model table and a report I need to build upon it. I've already tried searching for topics about parent-children issues, but I couldn't find anything useful in my scenario. What I have A Microsoft SQL Server 2000 database server. A categories table, which has four...

Linq2Sql vs Stored Procedures

Apologies if this is a duplicate question, but is there a real difference between executing a SQL statement in Linq2Sql compared to executing a Stored Procedure? What are the benefits? (if any) ...

stored procedure : to sort or not to sort : option

...@Sort bit) AS SELECT .............. and I want to Order only if Sort = true How can I realize it ? Thank you. ...

date format and regional settings

Hi all, I'm using MS SQL 2000, VS2008, MVC and C#. I'm trying to insert and update some data using stored procedures. Some columns are of type datetime. Regional settings on both server and client are set to Dutch (Belgium) This means the default date format is dd/mm/yyyy. When i try to insert or update with a date of eg. 28/03/2009,...

Update single data row from table to another

How can I update a complete data row by using a data row from another table. Example: Table A ID | NAME | ... | ---------------------------- 1 | Test | ... | 2 | Test2 | ... | Table B ID | NAME | ... | ---------------------------- 1 | Test97 | ... | So I want to copy the con...

Is there a risk to having SqlConnection object as a property for a single executable?

I've got the design habit to have a SqlConnection object populated by a child form, showing the child form, establishing the SqlConnection object and having the populated object passed back to the parent form where execution continues. .NET 2.0 and up 0 as follows: Parent form: public SqlConnection sqlcon; //should be property but mad...

BCP data export vs SSIS data export

I'm in the middle of amending our data export process and was wondering whether to create an SSIS package in order to export the data, or whether BCP is the "preferred" method? ...

Automatically create Entities from database

Is there a way to automatically create javax.persistence.Entity classes from an existing database (or from the SQL statements that created them)? I am just reading through the persistence part of The Java EE 5 Tutorial and creating all these annotations by hand seems rather wasteful considering that all (or most) of the necessary knowle...

Dos command to execute all sql script in a directory and subdirectories

Hi, I need a DOS command or a batch (.bat) file I can execute to run all the *.sql script in a directory and it's subdirectories. Any ideas? ...

How can i rollback my last delete command in mysql?

i accidentally deleted some huge rows from a table.. How can i rollback it? I executed the query using the putty ... I'll greatful if any of me guide me safe out this hole.. ...

ASP.NET / JavaScript - Ajax call, how to?

Please be gentle, as I'm still new to web programming and -very- new to Ajax! I've created a C# function which extracts data from an mssql database, formats it to a json string and returns that. Now I need to make a call from my javascript (jQuery) slider through an aspx page that is related to the C# code file. I have actually never d...

Sql Outer Join: Extracting values from multible tables.

I am extracting data from multiple tables. mt query is as follows: SELECT p.Record_Num as RecordNum ,p.GCD_ID as GCDID ,p.Project_Desc as ProjectDesc ,p.Proponent_Name as ProponentName ,st.Station_Name as StationName ,p.OpCentre as OpCentre ,s.Sector_Name as SectorName ,p.PLZone as PLZone ,f.Feeder_Desc as FeederDesc ,d.DxTx_Desc as DxT...