sql

Oracle Stored Procedure/Function Load Ordering

I have many stored procedures and functions in a folder. I have a batch file that loops over the .sql files in the folder and writes the file names to a single SQL file for execution. After this, the batch file executes the single file in SQLPlus. The problem that I am running into is the ordering of the creation of the stored procedures...

Inserting a GUID to each existing row.

Hi, question concerning MS-SQL: I have added a column with type uid to a table with already existing data. How can I insert a guid in each row of this existing table? (I mean without reading out the data with a dataadapter, adding a guid for each row and the updating the table [unless there is a method to automatically generate the u...

Can I have negative tinyint in SQLite?

Hi, I need to create a table (in SQLite) with a column which contains either "-1" or "+1". To save memory it is better not to use "int" as a type of the column. So, I thought about "smallint" and "tinyint". But smallint is not so small (from -32,768 to 32,767) and tinyint can be only positive (from 0 to 255). Are there any other options ...

SQL - What type of join is it and the best way to rewrite?

Our 3rd Party app has a custom View with the following: FROM dbo.vwPositionAssetSubWeight INNER JOIN dbo.vwPositionAssetSubTotal ON dbo.vwPositionAssetSubWeight.AssetID = dbo.vwPositionAssetSubTotal.AssetID FULL OUTER JOIN dbo.vwPositionAssetPendingTrades ON dbo.vwPositionAssetSubWeight.AssetID = dbo.vwPositionAssetPendingTr...

How to make total?

Using SQLSERVER 2000 How to make a total of intime value Table 1 InTime 02:00:48 22:00:22 ....., Intime Datatype is varchar 02:00:12 - (HH:MM:SS) Before I tried in access 2003 select format( Int(24*sum(Intime)), '0') & format( sum(Intime) , ':ss' ) AS totaltime from table1 Above Query is working perfectly in Access 2003 How to...

SQL query slow from .NET code, but not interactively

We are using an ORM that is executing a call from .NET to SQL Server's sp_executesql stored procedure. When the stored proc is called from .NET, we receive a timeout exception. Looking at Profiler, I can see that the query is indeed taking a long time to execute. The query is essentially: exec sp_executesql N'SELECT DISTINCT FROM [Ou...

Why am I getting multiple entries in my SQL database?

I am looking at two builds of the same app that are supposed to be exactly the same. The app is ASP.NET written in VB.NET. The issue is that on the local build of the app, a simple insert call to the database is adding an entry as it should, yet on a remote deployment of the same build, the same insert is somehow happening twice. I know...

Which dataset row is violating the DB unique constraint?

Hi, I'm writing an application using c# 2005 and Sql Server 2000. I have a table, with a unique constraint and, in the case I am concerned with, I have two users using a form which will (when Save is pressed) update the table. If the table is, say, NAMES( ID int, NAME varchar(20)) and the unique constraint is on NAME, if the first use...

error :Data-Truncation while inserting in table

i am trying to insert the value in the table by passing the value in a function like this: public void insert(long r,String s_n,char sex,String sf_n,String sm_n,int c,char sec,long tel,long amount,String add,int age,String house) { try{ this.ps=this.con.prepareStatement("insert into s_table values(?,?,?,?,?,?,?,?,?,?,?,?)...

Select Only Max 3 Rows From The Same User - MySQL

Let's say there are two tables: Table "photos" with columns: id, title, path, user_id And table "users" with columns: id username What I want to do is select let's say 30 photos from the "photos" table but with condition that there are at most 3 photos from the same user in the fetched result set. So far I have this query: SELECT...

sql server 4 byte unsigned int

Does anyone know of any work around by which i can save unsigned integers (0 to 4294967295) simply using 4 bytes instead of using 8 bytes and bigint? I know we can create user defined datatypes and create a constraint on them to not allow negative values but that still does not allow me to enter values over 2147483647. I only want to u...

Mysql Multiple Concat Inner Join, only give one Name

I have three Tables. table1 = anlass table2 = stammdaten_beziehungen table3 = parameter_zuweisungen_anl It gaves me this ERROR: Subquery returns more than 1 row But what i need, is all 'BeziehKuBez' Comma separated in one column. eg. Beziehname1, Beziehname2, ... If have test it with, CONCAT_WS(',', BeziehKuBez). But give me the ...

SQL Server - SCOPE_IDENTITY() for GUIDs?

Can anyone tell me if there is an equivalent of SCOPE_IDENTITY() when using GUIDs as a primary key in SQL Server? I don't want to create the GUID first and save as a variable as we're using sequential GUIDs as our primary keys. Any idea on what the best way to retrieve the last inserted GUID primary key. Thanks in advance! ...

convert varchar into datetime in sql server

How do i convert a string of format -> mmddyyyy into datetime in sql server 2008? My target column in 'DateTime' I have tried with Convert and most of the Date style values - I get a 'The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.' error message ...

Minus of time value problem?

Using SQL Server 2000 query Select id, CONVERT(char(8), CASE WHEN DateAdd(Day, - DateDiff(Day, 0, OutTime), OutTime) > Normal_Outtime THEN Cast(Normal_Outtime AS datetime) ELSE DateAdd(Day, - DateDiff(Day, 0, OutTime), OutTime) END - CASE WHEN DateAdd(Day, - DateDiff(Day, 0, InTime), InTime) < Normal_Intime THEN Cast(Normal_Intime AS d...

Excluding some columns in a SELECT statement

In the result for SELECT * from myTable WHERE some-condition; I'm interested in 9 of all the 10 columns that exist. The only way out is to specify the 9 columns explicitly ? I cannot somehow specify just the column I don't want to see? ...

DotNetNuke 'Run As Script' sql option

What does the 'Run as Script' option do in the Host->Sql page in DotNetNuke? ...

MySql Count Query

I have this query that I am working on for a one time report. Basically what I am trying to do is find all the records where there are more than two transactions by a single account ID last month. I know it is probably something easy, my mind is just blanking. SELECT streaming_transactions.account_id, streaming_transactions_detail....

where can I find list of countries and states for mysql

I am a php developer, I was searching for countries and states list of world in a mysql data format. Can one help me, where can I find and download it. ...

Need Latest Event Of Certain Type Where Several Events May Exist For That Date

First of all, I'm working in SQL Server 2000 (although prayers have been made to the Federal Stimulus Money gods for an upgrade to 2008.) I have a listing of students and educational events. I can successfully get the most recent event, except that it may be a combination of events: StudentID Event Date 1 Triennia...