sql

describe table structure

Which query will give the table structure with column definitions in SQL? ...

NHibernate sorting (SQL as a second option)

I'm using NHibernate as my ORM and I'm trying to sort some data. The data needs to be retrieved paged. Two of the columns in my Request table are UrgencyID and CreateDate. UrgencyID is a FK to the Urgency table with static data: 1 = Low, 2 = Normal, 3 = High, 4 = Critical. I need to order my Requests in the following manner. Critica...

Is Entity Inheritance better done thru a single table or multiple?

I have a table that holds agreement information. It works well for 95% of the agreements we record. But there is a certain type of agreement that would require another 6 or so fields to capture info specific to that type of agreement. My question is if its better to just add those 6 fields to the existing agreement table knowing that t...

how to use between in sql server

ID NAME TIME --------------------------------------------- 1 United Arab Emirates 3:00 2 Sri Lanka 2:00 3 Turkey 4:00 4 Yemen 4:00 5 Us 11:00 6 Sweden 5:00 7 England 6:00 8 Sin...

Updating a db table based on 2 separate conditions

I need to update my table (dependency) and set a new column (vid) to the nextval of a sequence. I can't change the way data is in the table so please don't mention removing redundant data. However, the where condition is the issue as 2 conditions need to be met (the cols provid and origid). There is a separate primary key (prikey). The ...

SELECT TOP Scan the whole table

If I did a command like: SELECT TOP(10000) ProductId from ProductInfo WHERE ProductId IN ( SELECT ProductId from DeletedProduct ) Will it scan the whole table or break out as soon as it finds 10000? ...

Block a row from reads whilst sp executes

Hi, I have many .NET processes reading messages from an SQL Server 2008 DB table and processing them one at a time. I implement a simple SP to 'lock' the row that is being read by any one process, to avoid any two processes processing the same row. BEGIN TRAN SELECT @status = status FROM t WHERE t.id = @id IF @status = 'L' BEGIN ...

SQL Programming

I have this select sql query: $sql = "SELECT `smth`,`smths`,`smthss` FROM sometbl WHERE `smt`='$smt' AND `smts`='$smts'"; How to substract the smth field from $smt ? ...

SQL full-text thesaurus

Is there somewhere one can get the xml for the english thesaurus from the web (for mssql that is)? I'd really hate to populate it by hand... ...

How do i manage M:N Post-Tag relationship (eg. Edit/Delete)

its when i starting trying implementing this that i got quite stuck. some business rules 1 Post can have many Tags. 1 Tag can have many Posts the database will look like. Posts (id, title, body, ...) Posts_Tags (post, tag) Tags (id, tag, ...) when i insert - straightforward tags will come from user input as comma separated val...

SQL Server Management Studio 2008 -- Differences between what is seen and what is really in DB?

I altered a stored procedure in SQL Server Management Studio database and everything appeared as expected. When my ASP.NET website called that stored procedure, it complained of invalid arguments. After running the alter procedure and then drop/create procedure the website continued to complain of invalid arguments. Furthermore, after re...

How can I insert a set of child records while updating the parent?

I'm using SQL 2005 and wish to create a number address records, updating the contact records with the new Id's: Take the following tables create table contact(id int primary key identity, home_address_id int, work_address_id int) create table address(id int primary key identity, street varchar(25), number int) And foreign keys: ALT...

ANT sql task: How to run SQL and PL/SQL and notice execution failure?

Hi, to execute an .sql script file from ANT it works fine using the following task: <sql classpath="${oracle.jar}" driver="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@@@{db.hostname}:@{db.port}:@{db.sid}" userid="@{db.user}" password="@{db.password}" src="@{db.sql.script}" /> But if the .sql file not only c...

How to get a real time within PostgreSQL transaction?

As far as I understand now() returns the same time during the whole PostgreSQL transaction? But how to get real time? Also, I am interested if there any configuration parameter to limit duration of transaction, so that after this period expiration transaction would immediately fail or somehow else prohibit following queries? ...

using different data connection in visual studio

It's possible to use 2 or more data connections in visual studio and using them in a single query, like we can do in sql server management (while we use mysql and mssql dbms same time): SELECT * INTO testMySQL.dbo.shoutbox FROM openquery(MYSQL, 'SELECT * FROM tigerdb.shoutbox')...etc ... etc... ...

howto use ole db to execute universal sql query

Hi, is it possible to use OLE DB in MFC C++ to execute universal query? I want to create function, one of parameters is sql query and I want to return something like two dimensional array with rows and columns returned by query. The problem is, I don't know the structure of the query (of returned data), so I can't use CAccessor. Thanks...

SQL Syntax Error

Hi, I am trying to upload a members database with login and create user facilities. Whenever I upload the .sql file to the host i am getting an error at the bottom of the page saying: MySQL said: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ÿþ/' ...

Incorrect syntax near the keyword 'with' (SQL)

Hi Guys, I have a little bit of an odd issue. When I run this SQL: with ID_Table as ( select row_number() over (order By SS_ID) As row_id, ss_id from slide_show ) select t0.* from ID_Table as t1 inner Join slide_show as t0 on t1.ss_id = t0.ss_id where t1.row_id between 0 and 1 order by t...

Populate iphone tableview from an SQLite database

Hello, I am trying to populate an iphone table view with values from an SQLite database. Lets say the table is as follows: Name      description     picture poodle    likes to growl      poodle.jpg cat          likes to meow     cat.jpg ...                   ...                   ... How would I ...

MYSQL ERROR 1248 (42000): Every derived table must have its own alias

I cant for the life of me figure out why this is erroring ...