sql

How to send record(which is a weblink) from a table to the value of the variable in SSIS package and send that weblink through an email?

Hi Folks, I have table called Table1 with columns, col1 and col2 with col1 having weblinks for the report and col2 the name of the report. Now, i have a package with a variables var1 and var2 which should get the col1 and col2 values respectively from table1 and send it through an email. if the weblink gets updated in the table, package...

SQL Antipatterns book

SQL Antipatterns book: may someone give an opinion? See ya. ...

delete specific entries in table

In my table I have many rows with data. One row has seven columns with values. Is it possible to delete from one row values of two columns and rest five leave without changes? Can I to it with SQL delete? cmd.CommandText = @"DELETE ImageData," + " ContentType, " + " FROM Users " ...

axapta table insert / update

hi folks, and once again an axapta-question ( running on ax 2009 and sql-server 2008 r2 ): which is exactly the point of time, when inserted or updated datasets are stored in the regarding database? the aim is to call a stored procedure on the sql-server which transfers data from the ax-tables ( eg inventtable ) to another ( not genera...

MySQL JOIN the most recent row only?

I have a table customer that stores a customer_id, email and reference. There is an additional table customer_data that stores a historical record of the changes made to the customer, i.e. when there's a change made a new row is inserted. In order to display the customer information in a table, the two tables need to be joined, however ...

Howto delete FK and all dependent table entries?

This is the case. There are 3 tables - state, region and city. If I delete a state with the name "France", I want that all regions and cities belonging to this state be deleted as well. How to do this in T-SQL? ...

How does one query a Zend_Db_Table_Row

Is it possible to run an SQL (Zend_Db_Select) query against a Zend_Db_Table_Row object? What about joining two Zend_Db_Table_Row objects? I know it sounds a bit retarded, but I'm processing hundreds and thousands of rows. I already have the row object that I'm manipulating, so I don't want to query the db again. I hope that's clear. If...

Comparing dates in Oracle using the decode function

I need to compare two dates using the Oracle decode function to see if one is <= then the other. I found this article - http://www.techonthenet.com/oracle/functions/decode.php Which states (at the bottom) that the below decode function will return date2 if date1 > date2 : decode((date1 - date2) - abs(date1 - date2), 0, date2, date1) ...

Using a case expression in a where clause

Although I know this isn't very efficient, I need to get this working fast so I try to follow the easiest path, or at least I thought so. I'm trying to get the max data out of an entity and take into consideration only the rows where USER is not null, and in case no rows have USER not set to null, then I will take the null ones into cons...

SQL Server Profiler - View Dynamic Sql

Hi All, I am building and executing some dynamic sql and wanted to use SQL Server profiler to view that execution statement. Do you know what filters /settings I have to use in order to see that? I have looked through them and could be just looking right over the obvious setting. EDIT: The dynamic sql is called within a procedure. T...

Tough SQL Update

2 databases QF AND TK QF has the following: Imagine you have a table called FunctionalGroup with this data: FunctionalGroupID | FunctionalGroup 1 Engineering 2 Purchasing And a table that was a set of login's with a functionalgroupID to reference the group the person is in... LoginID | Functio...

How to do a massive insert

I have an application in which I have to insert in a database, with SQL Server 2008, in groups of N tuples and all the tuples have to be inserted to be a success insert, my question is how I insert these tuples and in the case that someone of this fail, I do a rollback to eliminate all the tuples than was inserted correctly. Thanks ...

sqlite select where empty?

Select in sqlite where some_colum is empty. empty counts as both NULL and "". ...

Deleting a row based on the max value.

How can I structure a mySQL query to delete a row based on the max value. I tried WHERE jobPositonId = max(jobPostionId) but got an error? ...

mysql query not giving correct results

I have a table called records which has several columns, one of which is fromphone which represents a phone number. I can run this query to see the different phone numbers: SELECT DISTINCT fromphone FROM records and it shows the different phone numbers. However, if I run this query: SELECT * FROM records WHERE fromphone = '123-456-...

How to write a SQL query for user selected date range?

I am trying to write a query that will capture calls completed within 24 hours and calls completed > 24 hours, by call rep, based off of user selected from date and to date range in a web form. I have a column for completion_date in the "yyyy-mm-dd 00:00:00" format, reps, type of call, call requested, and call assigned. I really need so...

I get an invalid query error when I add WHERE Name =

public static void Command(string vCommand, string machineName, string username, string password) { ManagementScope Scope = null; ConnectionOptions ConnOptions = null; ObjectQuery ObjQuery = null; ManagementObjectSearcher ObjSearcher = null; try ...

apply best fitted discount package on items automatically

I have created some discount packages: Package1(Item1,Item2,Item5) Discount-5%. Package2(Item2,Item5,Item8) Discount-8% Package3(Item1,Item2) Discount3%. When a Person buy Items Online(for Ex. he buys Item1,Item2,Item5, Item10), while I show him the total price, I need to apply the best fitted discount on the items automatically. I...

Do a DB2 insert with a select and parameters

I want to do something like this: INSERT INTO TABLEA ( COLUMN1, COLUMN2, COLUMN 3 ) SELECT FOOBAR, DOOBAR, ? FROM TABLEB And then send this to JDBC via Spring JDBC to update... simpleJdbcTemplate.update( mySqlFromAbove, someVariableToReplaceQuestionMark ); Is this even possible? It would work fine if I replace the question mark wi...

PHP SQL SELECT where like search item with multiple words

Hi, I have a select where like query for a seach form which is as follows: <?php $bucketsearch = sanitizeone($_POST["bucketsearch"], "plain"); $bucketsearch = strip_word_html($bucketsearch); ?> if(isset($_POST['search'])){ $result=MYSQL_QUERY( "SELECT * FROM buckets where bucketname like '%$bucketsearch%' order by ...