sql

put query results into an object

I am using php and postgresql. I need a function that: connects to a db if not already connected run the query safely put the results into an object For example: I do a query that is 'select * from test'. I get back 2 rows...There are three columns in 'test' (id,fname,lname). I have an object named $ep. I want to be able to put the ...

Can you replicate data from MS SQL Server 2005 to MySQL 5.1 one-way?

I need to set up a one-way transactional replication from a SQL Server 2005 database to MySQL 5.1 Database. I have installed the ODBC driver and started to work on creating the publication, but I am getting an error that I have not found a solution for. The error is Failed to set publication parameter @enabled_for_het_sub because...

Strategies for checking ISNULL on varbinary fields?

In the past I've noted terrible performance when querying a varbinary(max) column. Understandable, but it also seems to happen when checking if it's null or not, and I was hoping the engine would instead take some shortcuts. select top 100 * from Files where Content is null I would suspect that it's slow because it's Needing to pul...

Get all Unique charactres from a column in table - SQL

i have a reqiurement to find out all unique characters avialable in a given column from table following is the content in a coulmn SNO NOTE_TEXT (column Name) ------------------------ 1 Recovery for 1125.00 voided due to incorrect re-insurance allocation. Now booked to 2 FR3270. 2 salvage cheque awaited 3 you. cdm_char_...

Convert string time like '18:15' to DateTime like 23/09/2010 18:15:00

How to convert VARCHAR time like '18:15' to DateTime like 23/09/2010 18:15:00. There can be any date format I just want to have date and time. The reason is I have a column in db time of VARCHAR(5) type. I have input, time in string, from user. Which I want to compare like this WHERE MyTable.Time < @userProvidedTime ...

I got error "The DELETE statement conflicted with the REFERENCE constraint"

Hello, I have a big problem :) I try to truncate table with foreign keys and I got the message "Cannot truncate table because it is being referenced by a FOREIGN KEY constraint". I read a lot literature about the problem and thought that I found the solution by using delete (e.g. DELETE FROM table_name DBCC CHECKIDENT (table_name, RESEE...

join two tables with different number of rows(in sql server)

Hello, I have two tables: A(col1,col2,col3,col4) B(col1,col2,col3,col4) Table A has 4 records(rows) and B has 6 rows.I want to join them like this,for example join them in C table C(B.col1,B.col2,A.col3,A.col4,B.col3,B.col4) (tables have different values in records just col1 and col2 contains the same values) when i join them on A.c...

SQL: Need help creating a one-to-many Set comparing query

The parameters are thus: I have a table called Tasks with columns ID (primary key) and label (text). I have another table called Locations with a foreign key referencing Tasks' ID and a name for a location (text). In my code I have a set of locations. UPDATED: I need a query to return all tasks that have associated locations found with...

Convert Binary Id Field to Text

I need the text (representation) of a id field in SQL Server 2005. Is there a way, we can generate the textual representation of the id field? For instance, if the id field reads as 0x00000000000002F0, I need the text value of 0x00000000000002F0 so that I can run SUBSTR operations on the same. Constraints I am not allowed to create ...

PL/SQL cannot add more than 2 arguments in add operator?

I have this procedure: PROCEDURE P_SUMMARIZE_ACTIVATED ( pStartDate IN DATE, pEndDate IN DATE, SummaryCur OUT MEGAGREEN_CUR ) IS BEGIN OPEN SummaryCur FOR SELECT USER_ID, sum(case SERVICETYPE_ID WHEN 1 THEN 1 ELSE 0 END) AS Package1, SUM(CASE SERVICETYPE_ID WHEN 2 THEN 1 ELSE 0 END) AS Pack...

Is there any difference between IS NULL and =NULL

I am surprised to see that IS NULL and =NULL are yielding different results in a select query. What is difference between them? When to use what. I would be glad if you can explain me in detail. ...

How to pull out the name of the primary key column(s) of a MS SQL Server table?

I have a MS SQL Server Database with about 75 tables on it, and I am trying to insert records into tables if a record with the same primary key doesn't exist, or update if they do. I could hard code the primary keys for every table into my vb.net code, but I'd rather not as more tables are to be added at a later date and my code needs to...

Delete duplicate rows (don't delete all duplicate)

I am using postgres. I want to delete Duplicate rows. The condition is that , 1 copy from the set of duplicate rows would not be deleted. i.e : if there are 5 duplicate records then 4 of them will be deleted. ...

open forums for trainers (professional IT courses fro developers)

I googled. I asked in forums but I could not find any forum, newsgroup or discussion boards for "trainers" (teachers, coachers) and supporters (writers of courses, sysadmins of labs, et al) of professional courses for IT developers Might be the certified by major vendors trainers have the sites with forums but they are closed to non-...

Changing Column Ordinal_position Positions

My scenario: I can change the ordinal position of a column in a table.Is there a way to change the ordinal position of a column in a table without recreating the table? ...

how to update datatable in c# with code?

i want move data from database to another database. i write 2 function. fuction 1 :i fill table from database1 into a datatable and named this DT in function 2 i fill table in database2 with Dt and named it's dtnull i updat dtnull in database 2 function 2: { SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand...

is view in the database updatable ?

is view in database updatable ? if yes , how ? if no, why ? ...

How to use the database that is updating by transactions log shipping service

Hi. Not so far ago I was faced with the trouble of dynamically transferring data from one database to another. The only reason to do that for me is when first database server go down, the system can use second server. For this purpose i used Transaction Log Shipping service. As far as i can see, it working fine now and copying logs from...

Read only commited data

Hi. I have a table called [Test], which has a single column [Id] int. I open a transaction, insert one row to the table and NOT commit it. begin tran insert into [Test]([Id]) values(1) In another request I want to select data from table [Test]. How can I read only commited data immediately? Readcommited table hint holds a lock. sel...

How to count the occurrences of a string inside TEXT datatype in sql server 2005

There is a column of datatype TEXT in my table. Now, I need to find the number of occurrences of a string in that TEXT field. I have already created a Full-text index on that table. But I don't know how to proceed further. I already found ways to count string occurrences for VARCHAR. But they cannot be applied AS IS to TEXT field. Any s...