sql

I Need Help Fixing My Small Time Sheet Table - Relational DB - SQL Server

I have a TimeSheet table as: CREATE TABLE TimeSheet ( timeSheetID employeeID setDate timeIn outToLunch returnFromLunch timeOut ); Employee will set his/her time sheet daily, i want to ensure that he/she doesn't cheat. What should i do? Should i create a column that gets date/time of the system when in...

Access 2007 file picker, replaces all rows with the same choice.

This code is from an Access 2007 project I've been struggling with. The actual mean part is the part where I should put something like "update only current form" DoCmd.RunSQL "Update Korut Set [PikkuKuva]=('" & varFile & "') ;" Could someone please help me with this?` If I use it now, it updates all the tables with the same file pick...

EXPORT AS INSERT STATEMENTS: But in SQL Plus the line overrides 2500 characters!

Hello, I have to export an Oracle table as INSERT STATEMENTS. But the INSERT STATEMENTS so generated, override 2500 characters. I am obliged to execute them in SQL Plus, so I receive an error message. This is my Oracle table: CREATE TABLE SAMPLE_TABLE ( C01 VARCHAR2 (5 BYTE) NOT NULL, C02 NUMBER (10) NOT NULL, C03 NUMB...

How can we check that table have index or not ?

Hi, How can we check that table have index or not ? if have how to find that index for a particular column for a table? Regards, kumar ...

CakePHP: how to get recently created auto-incremented field

I have a user submit a field to the database, it validates, and makes the entry. The primary key of this new row is auto-incremented. The user then gets to another form where that newly created field is required. Can anyone shed any light on this problem? Thanks in advance! ...

SQL: Need help with query construction.

Hi Guys, I am relatively new with sql and I need some help with some basic query construction. Problem: To retrieve the number of orders and the customer id from a table based on a set of parameters. I want to write a query to figure out the number of orders under each customer (Column: Customerid) along with the CustomerID where the...

How to check group for containing certain elements in SQL?

I have a simple table: id num 1 7 1 5 1 4 2 5 2 4 2 7 3 4 3 7 How to select ids having num 5 as well as 7 and 4 For this example ids: 1, 2 ...

order by clause in cursor

How can I order data in a cursor? Can we use the order by clause? Because I need to sort the data first. thanks ...

Strange problem with SQL 2005 server Stored Procedure executing the same SELECT many, many times

Hello, I got a strange problem. Let me give you some information. There is a stored procedure having one select returning the set of data and the return value of 0. Before the "main" select in the sp, there's also fake select (because of SSIS and codegen tools) looking like this : IF (1=0) BEGIN CONVERT(INT, NULL) AS Id ,CONVERT...

Creating an insert query (error of foreign key constrant)

I want to move data from one database's table to another database's table. It is giving me a foreign key error. Please tell me how I can insert all those data which is valid except those rows who don't have a foreign key. I am using SQL Server 2005 My query is : SET IDENTITY_INSERT City ON INSERT INTO City ([cityid],[city],[countr...

Zend_Db_Select: regrouping conditions in where clause

Hi, I would like to do something like this: $select = $myTbl->select() ->from('download_log') ->joinLeft(...... etc........ ->joinLeft(...... etc........ ->joinLeft(...... etc........); //Filter all configured bots (Google, Yahoo, etc.) if(isset($this->_config->statistics->bots)){ $bots = explode(',',$this->_config->statistics->bots)...

How to track number of changes occured in a column? T-SQL - SQL Server

For example, i have a column named EmployeeName. Every time a user changes/fix his name, i need to keep a count. If he changes his name twice, then count is 2. Also, i need to store the time of every change employee makes on EmployeeName e.g. if the name essentially is James and time created is 9:00 AM and then employee changes to John ...

wm_concat function and small characer buffer

Hi, i have select like: select substr(account,1,4), currency, amount, module,count(*) quan, wm_concat(id) ids from all_transactions group by substr(account,1,4), currency, amount, module But sometimes COUNT(*) is more then 600. In that case i get: 'ORA-06502: PL/SQL: : character string buffer too small' Is there any way out to keep w...

SQL SERVER SSAS: How do I handle a NULL date value in my fact table, so I can process my time dimension without errors?

Hello! I have a fact table that has a column with dates loaded from an MS Access source. The thing is, some of the values are NULL and the SSAS won't let me refer my DATE dimension to it. Is it better to solve it at the SSIS stage or is there some solution at the SSAS? Thank you very much for you help. ...

Exporting collections

Hi, have select like select trn_dt,collect(ac_no) from transactions where rownum < 1000 group by trn_dt i'm doing it in SQL Navigator. But i can't export results! Table collect(ac_no) is not exported. Is there any way out? ...

Creation date column in SQL table

What is the easiest way to automatically fill a datetime column in an SQL data table with the date the row was created? Using SQL Server 2005 if that matters. EDIT: I've tried using GETDATE() for default and that works for an INSERT Query but not when the TableAdapter adds the row. ...

how to restore a database from different computers into one

I have 3 computers having the same sql server 2005 database, i would like to gather the data from the 3 computers to another computer which has the same database. pls help me tnx in advance ...

SQL: Recursive Path

Is it possible to create a "tree resolver" in SQL? I have a table: ID Name Parent 1 a 2 b 1 3 c 1 4 d 3 Now I want a SQL query that returns: ID PATH 1 /a 2 /a/b 3 /a/c 4 /a/c/d Is this possible with SQL? It would make many things easier for me. Any help would really be appreciated! ...

Create a view in database to fetch username and password of all users having a particular roie (Forms Authentication)

Hi Guys, Background ========== I am using ASP.NET Forms Authentication for my application. I have made my Password Format "Clear", so no problems with the password encryption. Requirement =========== I need to create a view(in SQL server) to display all Administrators in my System. ie aspnet_Roles.LoweredRoleName='administrator' The ...

Fill in missing values in a SELECT statement

I have a table with two columns, customer id and order. Let's say I have in total order IDs 1,2,3,4 All the customer can have all the four orders, like below: 1234 1 1234 2 1234 3 1234 4 3245 3 3245 4 5436 2 5436 4 You can see above that 3245 customer doesn't have order id 1 or 2. How could I print in ...