sql

dynamically adding columns into SQL Reporting services

The stored procedure mapped to a report query builder returns values dynamically mean to say once 8 columns and sometimes 6 columns. My question is how to name the header for the extra added columns? ...

jQuery autocomplete: change SQL query depending on selected checkbox

Hi, imagine i have one textbox (with autocomplete 1.1, not the latest UI version) and a checkbox. The textbox triggers an asp.net .ashx page that will execute a stored procedure at the sql-server and return the results. It's all working, but i want to add another feature. When the checkbox is checked i want stored_procedure_1 to be exe...

Sql query to populate iPhone quick-access-bar (count rows by first letter)

I have a sqlite database, with potentially tens of thousands of rows, which is exposed as a UITableView on the iPhone. There's many columns in the relevant table, but for now I only care about a 'name' column. (The database is in a server app, the iPhone app is a client, talking over a socket) Naturally to make this usable, I want to sup...

PHP: Conversion failed when converting date and/or time from character string

I'm having trouble with this query. I have 2 date coming from textboxes (don't worry I've taken the necessary sql injection steps). They are used to query a MS SQL Server DATETIME field. I'm getting this error: Conversion failed when converting date and/or time from character string Here my code: //formatting my strings $from = str...

Why can't I can't I use my Oracle user defined type like this?

In an Oracle package I have defined a type type setTable is table of my_sets.pkey%type; in the package declaration (the non-body part). The pkey column referenced is a number(38). Then in a function in the package body I have ... with d as (select column_value from table(sets)), ... where sets is a parameter to the function of t...

Prevent inserting overlapping date ranges using a SQL trigger

I have a table that simplified looks like this: create table Test ( ValidFrom date not null, ValidTo date not null, check (ValidTo > ValidFrom) ) I would like to write a trigger that prevents inserting values that overlap an existing date range. I've written a trigger that looks like this: create trigger Trigger_Test on Test for i...

How to enable only Standard Edition features in SQL Server 2005 Dev Edition?

I've got the following problem. We have Development, Testing and Production environments for our system. All these environments will contain SQL Server 2005, but different editions. The Production will work with Standard Edition. Now we would like to install Dev Edition on other servers (to save our money), but as far as I know, Dev Ed...

iPhone Online DB Question

Hello, My question deals delivering information to iPhone devices via an online DB. (Essentially, I want to do something like the NYTimes App, which provides the latest news for each device containing the app). I know I need to use a SQL lite database to accomplish this. What is the best way to approach this problem? I am a newbie a...

Select query in MySQL

Two tables Table1 ID FileName 1 abc 2 abc 3 abc 4 xyz Table2 ID Table1_ID isDeleted 1 1 1 2 2 1 3 3 0 4 4 0 I need to get the count of filename for the isDeleted=1 by passing any ID of table1, i.e for all the values(1,2,3) of ID, i need the count as 2 I tried with the following query S...

getting problem in group by clause

hi friends, i want to get the sum of quantity from the below query. how i write the group by clause in below mention query. select top 1 EvrId, TimeStamp, Date, BnhTnkMik1 as Quantity, (select TnkCode from Tanklar where TnkId=BnhTnkId) as Tank, FuelCode, InvoiceNo from Evrak join Hareket on (BnhEvrId=EvrId) join Stoklar on (StokId=Bn...

Dynamic "SELECT TOP :paramter" in Teradata Macro

Hi there, I need to alter a macro the way that a parameter can be passed to control the max size of the result set. My idea was this SQL: REPLACE MACRO myMacro ( maxRows INTEGER DEFAULT 100 ) AS ( SELECT TOP :maxRows FROM myTable; ); But all I get is the message: [SQLState 42000] Syntax error,Expected something like an I...

Extract number from the date in pl sql

Does anyone know if it is possible to take the date from a random date in pl sql. example. SELECT SYSDATE FROM DUAL and here the output would be say : 26-10-2010 13:30:34 Now I want to have just the date as a number. In this case that would be 26. Or is there some sort of function like IsNum that can recognize it for me. So I ...

Pattern match within the IN operator (MySQL)

I would like to match patterns inside an IN expression like this: ... WHERE ... IN ('%alma%','%sajt%') Is it possible somehow and if not, how could I achieve this some other way? ...

Null value column and NOT EXISTS T-sql

Hi, I'm trying to do the following: IF NOT EXISTS ( SELECT * FROM [tbl_web_company] WHERE [name] = @name AND [address1] = @address1 AND [address2] = @address2 AND [city] = @city ...

SQL Server Reporting Services - Functions Problem

Hi. I´m developing a app in ASPX .NET2008. And I have a big problem with the SQL Server Reporting Services. The button "Print" and the zoom option only is showed in IE browser but I need it showing in Chrome and FireFox too. I think it is a ACTIVEX problem, but I´m not correctly this. ...

Select's Where Clause - Non Ascii Characters?

Hi, I'm having a problem with non-ASCII characters in a where clause Say for example a record in my table has : column_a Bom D� Street And I want to see if this will find the record: SELECT * FROM [tbl_test] where column_a = 'Bom D� Street' This always returns no records. Is there something you have to do to handle non-ASCII char...

SQL Server Max statement returns multiple results

When querying two tables (t1, t2) and using a MAX statement for a column in t2, SQL returns multiple entries. This seems to be because I also query other info from t2 which consists of unique entries. Simplified table example t1.number t2.number_id t2.sync_id t2.text 1 1 1 ...

Why does this query ask me to declare the table when I already have?

My Issue is that the last query in this sproc is saying that I need to declare @N but I already have any ideas? DECLARE @t TABLE (Smpinstanceid UNIQUEIDENTIFIER) INSERT INTO @t (Smpinstanceid) SELECT t.SmpInstanceid FROM Tasks t WHERE t.Completed IS NOT NULL and t.SmpInstanceID is not null DECLARE @N TABLE (...

What advantages does one big database query have over many small ones

I inherited the app and what it does is get data from 4 views with an (xml file in it) in chunks of 1000 records then writes them down in an xml file all this split up by a type parameter that has 9 different possibilities. That means in a worst case there will be 36 connections to the database for each 1000 of that type/view combination...

Delete All / Bulk Insert

First off let me say I am running on SQL Server 2005 so I don't have access to MERGE. I have a table with ~150k rows that I am updating daily from a text file. As rows fall out of the text file I need to delete them from the database and if they change or are new I need to update/insert accordingly. After some testing I've found that ...