sql

SQL - Update table changing one column value based on another table

Hi. Sorry if the title is not as descriptive as it should be but it is kind of difficult to explain in one sentence what I am trying to do ;). I have one table that links parent objects with its respective childs. And I have another table with all the objects (parents and childs) with its respectives images. However, the image is just s...

Quickest way to delete all content in a database and rebuild from scratch?

I am designing a standard ASP.Net site with a SQL database. I have a database schema and During the tests I am changing data types amongst other tasks and the data contained inside really is not that important. I keep getting errors as the old data does not match the new rules. This is not important and I am happy to clear everything b...

PHP - Remove part of string from another string

Hi, I have the following function to create the SQL for an insert query: function insertQuery($data, $table) { $key = array_keys($data); $sql = "INSERT INTO " . $table . " (" . implode(', ', $key) . ") VALUES " ; $val = array_values($data); $sql .= "('" . implode("', '", $val) . "');"; return $sql; } Normal...

Keeping database structure compatible between MS-Access and SQL Server...

I'm working on a legacy project, written for the most part in Delphi 5 before it was upgraded to Delphi 2007. A lot has changed after this upgrade, except the database that's underneath. It still uses MS-Access for data storage. Now we want to support SQL Server as an alternate database. Still just for single-user situations, although m...

Big performance difference (1hr to 1 minute ) found in SQL. Can you explain why?

The following queries are taking 70 minutes and 1 minute respectively on a standard machine for 1 million records. What could be the possible reasons? Query [01:10:00] SELECT * FROM cdc.fn_cdc_get_net_changes_dbo_PartitionTest( CASE WHEN sys.fn_cdc_increment_lsn(0x00)<sys.fn_cdc_get_min_lsn('dbo_PartitionTest') THEN sys.fn_...

mysql select in two tables

hi to all I have two tables and one reference table for the query. Any suggestion or help would greatly appreciated. table1 user_id username firstname lastname address 1 john867 John Smith caloocan 2 bill96 Bill Jones manila table2 user_name_id userna...

Combining 2 TSQL statements into 1

Hi, I need to combine the following two SQL statements into one. Any help is greatly appreciated. Thanks. SELECT C.*, M.members_Email FROM tbl_Campaigns C JOIN tbl_Members M ON C.campaign_MemberId = M.members_Id WHERE C.campaign_MemberId = @userID ORDER BY C.campaign_Key DESC SELECT COUNT(*) FROM tbl_CampaignRecipients WHERE reci...

Users have open files on BackupSharedFolder. Continuing the operation will force the files closed.

I am using below sql statement to create shared folder with permission EXEC xp_cmdshell 'net share BackupSharedFolder=D:\testshared /REMARK:"test shared"' It is working fine with create shed folder. then i will use below sql command to remove shared EXEC xp_cmdshell ' net share BackupSharedFolder /delete"' Above is also working fine ...

need help on insert new contact into access mdb from delphi

hi all I want to write an app that is an address book and uses a access .mdb file. I know how to insert a new contact into the database, but i do't know how to edit a contact. I put my test project in here AddressBookTest.zip. Any help is welcomed ...

SQL Server Service Broker to insert data on a SQL Server 2000

Hi all, I have two servers, the first one with SQL Server 2005 and the second one with SQL Server 2000. I want to insert data from the 2005 to the 2000 and I want to do it unsync (without distributed transactions because "save transaction" are used). Once the information is inserted in the tables of the 2000 server, some instead-of tri...

SQL script to create insert script

A bit of a vague title, I will explain. I am writing an SQL script to create an insert statement for each row of a table in my database, purely to be able to apply that data back to another database. Here is what I have at the moment: SELECT 'INSERT INTO products (id,name,description) VALUES ('||ID||','''||name||''','''||description||...

Pulling the WHERE clause out of LINQ to SQL

I'm working with a client who wants to mix LINQ to SQL with their in-house DAL. Ultimately they want to be able to query their layer using typical LINQ syntax. The point where this gets tricky is that they build their queries dynamically. So ultimately what I want is to be able to take a LINQ query, pull it apart and be able to inspec...

SQL Server, find an arbitrary sequence of values

Let's assume we have a table Maintenance Customer LastLogin ActionType 1 12/1/2007 2 1 12/2/2007 2 etc. We want a list of all customers who at any point during a given year had one or more uninterrupted sequences, 14 days long, of login with action type 2. I can of course easily do this with code, and even have it be fa...

Atomically mark and return a group of rows in database

I'm writing a background service that needs to process a series of jobs, stored as records in a sqlserver table. The service needs to find the oldest 20 jobs that need to be worked (where status = 'new'), mark them (set status = 'processing'), run them, and update the jobs afterward. It's the first part I need help with. There could be ...

VB6 OpenRecordSet has too few parameters?

I'm debugging an app with the following code: sql = myTable Set datTable.Recordset = myDB.openRecordset(sql, dbOpenDynaset, dbSeeChanges) where sql = "select * from table Order by Precipition,Date/Time" An error occurs on the second line saying "Run-time error '3061': Too few parameters. Expected 2". I believe the issue is the wit...

What is table partitioning?

In which case we should use table partitioning? ...

SQL 2005 Express - New SP ?

When clicking New Stored Procedure I get a template with some lines of comments . Can this template be changed so that it does not give each time these comment line? ...

How can I select none duplicate rows with inner join?

My MS SQL Server stored procedure is: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_close] @DATE NVARCHAR(8) AS BEGIN SELECT appointment_datas.appointment_date ,appointment_datas.appointment_no ,costumer_datas.costumer_name ,appointment_datas.appointment_type ,personel_datas.personel_ADI FRO...

Attaching mdf file into sql server

Earlier mdf file was in app_Data folder, and application was working fine. When I attached mdf file into sql server. I can execute queries. But when I try to use it from asp.net application it give following exception. Cannot open user default database. Login failed. Login failed for user 'domain\username' ...

SQL server 2008: How to get the start date and end date of my data?

hi! As a newb, I already know that I will be berated for asking this question, but I did not find the answer on the site here and could use some help... I have a table that lists data by the day, and by type. For example Transaction | Date | Type ----------------------------- Updat | 11/7/2008 | Cash-out Update | 11/10/2008 ...