sql

Running an SQL Script with Oracle Application Express

Greetings, I am trying to run an SQL Script uploaded using Application Express (APEX), the web based interface for Oracle DBMS. However, upon clicking the Run button, it does nothing, suspecting any javascript error, I pulled out firebug and there appears to be an error on the js. this.endLine.isPreceding is not a function http://loca...

MS Access - Query Refactoring Assistance

I have a page in one of my client's websites that generates an extensive report pulling data from numerous tables throughout the website's MS Access database. One of the unfortunate architectural issues of the website is the existence of two nearly identical tables that represent the same "type" of data, but one is an "old" version and t...

insert into sql server table and get back primary key

i have a primary key set up to auto increment. i am doing multiple queries and i need to retrieve that primary key to use as a foreign key in another table (is identity = true) is there any elegant way to get back the primary key when i do an insert query. right now i am requerying and getting the highest value in that column which se...

Is Nhibernate Vulnerable to SQL Injection?

Just wanted to know if there is a big chance to inject SQL While using nhibernate? ...

what would be the primary key of the Table "Pictures" in this example

Table: PhotoAlbum Columns: AlbumID AlbumName AlbumDate AlbumDescription Table: Pictures Columns: PictureID AlbumID The issue is that i am using picture ID as a reference to a pic within an album so the data is duplicated for each album for that field. ...

How do you backup and restore a database as a copy on the same server?

I have a SQL2005 Express database that I would like to create a copy of on the same instance. How do you go about doing this with a script? I already have a script for generating the backup, but the restore is failing... THE ERROR: Msg 3234, Level 16, State 2, Line 2 Logical file 'MyDB_data' is not part of database 'MyDB_Test'...

What is the purpose of BOUND COLUMN property of listbox in MS Access?

What is the purpose of BOUND COLUMN property of listbox? ...

Finding the Latest Post by Author

I'm building an "authors" page for my Wordpress blog that lists all the current site contributors along with various other information such as their number of published posts, the date of their last post, etc. Google and the Wordpress Codex has pointed me toward using subqueries in MySQL to pull all the data I need in one query, and it'...

MySQL Selecting Linked Rows

I have two tables: Table "A": +----------+ | item_id | +----------+ | 10 | | 20 | | 30 | | 40 | +----------+ and table "B": +----------+-------------+ | item_id | user_id | +----------+-------------+ | 10 | 1 | | 10 | 2 | | 20 | 1 | | 30 | 2 ...

Upsert with .net sqladapter

Dim sSelect As String = _ "SELECT * FROM Contacts" & _ " WHERE DataSetID = @DataSetID AND ID >= @FirstID AND ID <= @LastID ORDER BY ID" Dim dsDBFiles As New DataSet() Dim cmd As New SqlClient.SqlCommand(sSelect, m_connection) cmd.Parameters.Add("@FirstID", SqlDbType.Int).Value = nFirstID ...

cursor giving error

hi we are trying to execute following script we are getting errors as ERROR at line 1: ORA-20000: Unknown Exception Raised: -933 ORA-00933: SQL command not properly ended ORA-06512: at line 23 DECLARE l_cursor INTEGER; l_output VARCHAR2(20); l_rows INTEGER; l_sql VARCHAR2(1000); BEGIN ...

How to 'insert if not exists' in MySQL?

I started by googling, and found this article which talks about mutex tables. I have a table with ~14 million records. If I want to add more data in the same format, is there a way to ensure the record I want to insert does not already exist without using a pair of queries (ie, one query to check and one to insert is the result set is e...

what is the issue with following sql query

i get error insert into dmi_user.fct_sales_summary_cmp values SELECT A.bio_id * ERROR at line 1: ORA-00936: missing expression on running following query insert into dmi_user.fct_sales_summary_cmp values SELECT A.bio_id ,decode(A.wk_units2 - B.wk_units1,0,NULL,A.wk_units2), decode(A...

SQL Joining 2 similar tables

Hi, I have two tables which are used to store details of different types of events. The tables are almost identical, with fields such as date, duration etc. I'm trying to perform a join on the two tables and sort them by the mutual field 'date'. I know it would be simpler to simply add a 'type' field to a single table and store it all...

Passing many parameters into SQL and SSRS

hi, i am trying to create a report from a row of data with about 60 columns. The workflow is as follows. 1] user selects the fields they want to view in the report from within c# 2] c# calls a sp in sql and passes the fields (expecting between 1 and 5 fields per report) 3] ssrs displays these fields on a pie chart in reporting services....

How to insert into a table with just one IDENTITY column (SQL Express)

Pretty much the same as this question. But I can't seem to get this to work with SQL Server Express in Visual Studio 2008. Same Table layout, One column with identity and primary key. ...

how can I store date values partially?

hello, every one i'm using ms sql server 2005 and i need to store date values partially for example, the day part of a date may stay unknown in fact but mssql constrains to specify the full date like the follow: INSERT foo(dt) VALUES('2001-10-31'); though i would like to use something like this: INSERT foo(dt) VALUES ('2001-10-??');...

combine join with String.Contains in Linq query

i have the following linq query that create a left join between two tables: var joinResultRows = from leftTable in dataSet.Tables[leftTableName].AsEnumerable() join rightTable in dataSet.Tables[rightTableName].AsEnumerable() on...

Code Length vs Organization

I have several nested insert commands. Some of the nested loops share redundant code. Should I make the redundant code its own loop, or create separate instances of the same code within each loop? EXAMPLE (edited for clarification): --Questions 32<->37 SET @index=0 SET @values = 'at your primary grocery store^at WalMart or Sam''s Clu...

need to implement the following query in such a way that we should not have to write such a big query

we need to implement the following query in such a way that we should not have to write such a big query instead we should implement it through procedure,function or anonymous block (what ever way we can) wk_units1-105 are column names cnt_sls_dm.fct_sales_summary table name. we are comparing the data in the same table but week 2 of a....