sql

How to update multiple rows in the same table of MySQL with PHP?

If only one row with a distinct field is to be updated,I can use: insert into tab(..) value(..) on duplicate key update ... But now it's not the case,I need to update 4 rows inside the same table,which have its field "accountId" equal to $_SESSION['accountId']. What I can get out of my mind at the moment is: delete from tab where ac...

SQL Server FILESTREAM limitation.

I am looking at FILESTREAM attribute in SQL Server to store files in it. I understand it stores the files on hard drive and stores the file pointer/path information in DB. Also, maintains transactional consistency in the process. There also seems to be a limitation "FILESTREAM data can be stored only on local disk volumes" for the FILES...

Quickest way to roll back SQL data Was: Best way to develop a data-mangling stored procedure

Edit: OK I asked the wrong question here. I'm going to be coding a stored proc that affects a lot of data, so I need to know the quickest, easiest way to roll back the data to the original state after I run a test. Old question: I have a development database holding live data. This needs to be obfuscated for privacy, particularly com...

How can I get the last inserted primary key?

I'm using SQL Server 2005 with a table with a primary key field with the type varchar(40). I have to get the last inserted record's primary key value. I have tried scope_identity but it is not working. How can I get this? ...

Oracle PL/SQL REGEXP_LIKE / REGEXP_INSTR

Hi, I require a means of checking to see if a string has the following exact pattern within it, i.e.: (P) Examples where this would be true is: 'Test System (P)' Unsure though how to check for cases when the string that doesn't have '(P)', i.e: 'Test System (GUI for Prof)' - in this case, this would be false but I am using REGEXP_...

SQL query that throws away rows that are older & satisfy a condition ?

Issuing the following query: SELECT t.seq, t.buddyId, t.mode, t.type, t.dtCreated FROM MIM t WHERE t.userId = 'ali' ORDER BY t.dtCreated DESC; ...returns me 6 rows. +-------------+------------------------+------+------+---------------------+ | seq | buddyId |...

Tracing and diagnostics for System.Data.SQLConnection

Hi i was wondering if there is away to allow tracing / diagnostics on a SQLConnection via the app.config file much like you can with WCF when you need tracing support (as below)? <system.diagnostics> <switches> <add name="DataMessagesSwitch" value="0" /> <add name="TraceLevelSwitch" value="0" /> </switches> </system.di...

Add account to SQL Server in .net

Hi, Is there any API SQL Server 2008 offers for .net application to create and grant access authorities? Thanks! ...

Set Users to not be Challenged for Credentials?

How can I restrict my users to stop getting Log in / accessed into my Database by Enterprise Manager or by any other way in SQL Server 2000? ...

How to merge rows in MS access?

I am having a table with records like this in MS Access: ID field2 field3 field4 field5 1 345 asr 2 ase 567 788 3 456 ghy 4 jki 568 899 5 235 yui 6 hju 456 456 I want to merge it to get a table like this: ID field2 field3 field4 field5 1 345 asrase 567 ...

Mysql error on debian server

Hi i have a debian server. Today my site was showing Error establishing a database connection. When i tried to restart mysql i am getting this error: ERROR: The partition with is too full! failed! I have run apt-get clean command also but still i am getting this error. Please help ...

Looping Rows in SQL Server

I have a SQL Server table with 2 columns, Code and CodeDesc. I want to use T-SQL to loop through the rows and print each character of CodeDesc. How to do it? ...

Strange Behaviour: SQL And operator with multiple IN operators

I am using multiple IN operators with AND in my sql query where clause as given below... --- where ID in (1, 3, 234, 2332, 2123, 989) AND tag in ('wow', 'wonderful') But surprisingly behaviour of result seems to be of OR type rather then AND type. What I mean is it is ignoring AND operator... Can you please explain me why? ...

Is this the correct way to sort rows which have the same insert datetime ?

When I execute a query from my application (Java JDBC), it is returning the row with seq 83 first. But I want the row with seq 84. seq | dtCreated | 84 | 2009-09-14 16:16:23 | 83 | 2009-09-14 16:16:23 | 82 | 2009-09-14 16:15:01 | Is this query correct ? I'm interpreting this to mean that if there are ties in dtCre...

sql statement with group by

hi, after a very long sql query a have a result that is in this form: ---col1---col2---col3---col4 ---1234---1------aaaa---bbbb ---2378---0------aaaa---bbbb ---9753---1------cccc---uuuu ---1234---0------iiii---yyyy ---2378---1------iiii---yyyy ---9753---1------tttt---mmmm but i don't need it this way. i have to do another sql-statemen...

SQLite update field with count from another table

Hello, I am trying prepare a table before exporting to CSV however the Sqlite administrator software I am using is reporting invalid syntax. Anybody see whats gone wrong? UPDATE 'tblTags' SET 'tagUsageCount' = (SELECT COUNT(*) FROM 'tblTagLinks' WHERE 'tblTagLinks'.'TLTagId' = 'tblTags'.'tagId') ...

SQL Server: "Conversion failed when converting datetime from character string."

I'm trying to copy the results from a view to a table using: insert into tableA select * from viewB order by id; I get the error message - Msg 241, Level 16, State 1, Line 1 Conversion failed when converting datetime from character string. TableA and ViewB have about 80 fields. Trying to figure out which one's might have a type ...

How do I make an SQL statement to return all rows when a variable is blank, otherwise return only matches

How do I use an SQL statement to return all rows if the input parameter is empty, otherwise only return rows that match? My SQL looks like this where person.personstatusuid = @StatusUID AND person.forename != '' AND person.location = @Location but I want basically, person.location = @Location OR @Location is b...

SQL checking if a value is an empty string?

This is the where clause of my query: WHERE person.personstatusuid = @StatusUID AND person.forename != '' this works fine - @StatusUID is coming from a drop down box. However, I also have a location field. This code works fine too: WHERE person.personstatusuid = @StatusUID AND person.forename != '' A...

SQL - WHERE clause on each SET command in UPDATE?

Hi, I'm trying to create an SQL query in PHP to update a table. Is it possible to have a different WHERE clause for each affected row? eg something like: UPDATE table SET val=X WHERE someproperty = 1, SET val=Y WHERE someproperty = 2 etc? Any help appreciated. Thanks ...