sql

Problem casting field when querying spreadsheet

I am trying to query an .xls spreadsheet with VBScript, but I have run into an issue when trying to cast a field. I connect to the spreadsheet like this. Set objConnection = CreateObject("ADODB.Connection") objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataSource & ";Extended Properties=""Excel 8.0;HDR=No;"";" ...

IF/ELSE Stored Procedure

Hi, Can anyone please point out what im doing wrong with this Stored Procedure please. I cant get it to compile and my software isnt giving any useful clues as to what is wrong with it. CREATE PROCEDURE web.createSubscriptions ( @Member_Id BIGINT, @Trans_type VARCHAR(100), @Payment_Status VARCHAR(100), @Payment_Date DATE...

Access AS400/DB2 with SQL 2008 Express

I'm trying to add the AS400 as a linked server in SQL 2008 Express in order to access some tables in a DB on the iSeries. I've tried all of the OLE providers with many different strings and have had no luck establishing a connection. Is this even possible with this version of SQL? Thanks ...

Including not found criteria in the result

I have this query select BUnit, value from myTable where BUnit in (555,556,557,558) and this values for Bunit are constructed dynamicaly, ie. a program builds queries on demand, and not always this will be the selected numbers. A possible query result would be Bunit value 556 10.2 558 5.18 How...

ibatis 3 ispropertyavailable

It doesn't look like ispropertyavailable in the select tag is in ibatis 3. I'm moving a project from 2 to ibatis 3, is there another way to handle this scenario? ...

Return a 'DESC package' in PHP using OCI

Hi I am trying to get information on an Oracle package directly from PHP using OCI8: $sql = 'DESC my_package'; $stmt = oci_parse($conn, $sql); oci_execute($stmt); this returns: Warning: oci_execute() [function.oci-execute]: ORA-00900: invalid SQL statement in /oci8_test.php on line 16 I know the command works as I tried it in SQL...

cakephp retrieving multiple values in a column

I want to retrieve multiples values from a field. the code I am using this this $conditions = array('Tag.name'=>$compare);//$compare = array('value1', 'value2',..); $values = $this->find('all', array('conditions' => $conditions)); But It keeps coming out like this SELECT `Tag`.`id`, `Tag`.`name`, `Tag`.`count` FROM `tags` AS `Tag...

SQL INSERT but avoid duplicates

I want to do some quick inserts but avoid duplicates into a Table. For argument's sake lets call it MarketPrices, I've been experimenting with two ways of doing it but not sure how to benchmark which will be faster. INSERT INTO MarketPrices (SecurityCode, BuyPrice, SellPrice, IsMarketOpen) SELECT @SecurityCode, @BuyPrice, @SellPrice, @...

How to import mysql sql file into microsoft visio 2007 ?

Hello, Does anyone know how to import a mysql sql file into microsoft visio 2007, and then generate a database chart automatically? Thanks a lot. ...

SELECT max(x) is returning null; how can I make it return 0?

How do you return 0 instead of null when running the following command: SELECT MAX(X) AS MaxX FROM tbl WHERE XID = 1 (Assuming there is no row where XID=1) ...

Raising errors in After Triggers Sql Server 2005

If I raise an error in an AFTER UPDATE trigger in Sql Server 2005, will that cause the update which caused the trigger to be fired to roll back, even if the statement was not executed within a transaction? Thanks. ...

Looking for an SQL statement which groups by type

Hi all, first, I was pretty lost giving this question a correct title. I'm working on a system which allows me to find specific networking devices. A network device (called "system" in my example) has a number of ports, where each port can have a specific configuration. An example would be: Return all devices which have at least 2 por...

How to get slowest queries on SQL 2005, without requiring compability change?

I was reading this fabulous list of sql dba scripts at http://www.sqldbtools.com/Scripts.aspx, not affiliated with them. And I want to run this query... select top 10 qs.execution_count, st.dbid, DB_NAME(st.dbid) as DbName, st.text from sys.dm_exec_query_stats as qs cross apply sys.dm_exec_sql_text(sql_handle) st order b...

Create a temporary table like a current table in SQL Server 2005/2008

How do you create a temporary table exactly like a current table in a stored procedure? ...

Generic Command Line SQL Program?

Is there any application/project that provides you with a command line SQL client that will work with multiple databases and/or provides a mechanism for writing your own drivers? Put another way, I'm looking for something like the mysql command line client or SQL*Plus for Oracle, but that's database agnostic. All platforms welcome,...

MySQL command to search CSV (or similar array)

I'm trying to write an SQL query that would search within a CSV (or similar) array in a column. Here's an example: insert into properties set bedrooms = 1,2,3 (or 1-3) title = nice property price = 500 I'd like to then search where bedrooms = 2+. Is this even possible? ...

Using a pointer to a local variable in Dynamic SQL

I am having trouble with dynamic SQL. Early in my code I assign data to a bunch of local variables. I want to access these later in my code and use the data values. The code example below shows a simplified example to explain what I am trying to do. -- ---------------------------------------------- -- Declare and set the data into a ...

Web services and SQL Server 2005

Is it possible to set up SQL Server with a web service to receive and store data bypassing the IIS/ASP.NET layer altogether? I know it's possible to set up a web service via HTTP End Points and such to return requested data but I can't seem to find examples to show the opposite process. ...

Returning Output Param from SQL Connection

Is this possible or the right way to go about this (if you're not using a stored proc): conn.CommandText = "set @TotalPts = select SUM (pts) from cars where completedDate is not null and customerID = @customerID"; conn.AddParam("@customerID", customerID); conn.AddOutputParam("@TotalPts", SqlDbType.Int); ...

Deploy a SQL stored procedure in C#

I have a stored proc .sql file on my system. I want to be able to move this file into database as a sp from C# code. i could open the file, read it in as a string, and execute it but I feel like there should be a better way. ...