sql

trying to export tables from aspnetdb.mdf into another sql server

i have a SQL server database on a server. I have just recently been playing around with asp.net mvc and i am using the membership login control. i see that it creates a default local database called aspnetdb.mdf with teh following tables: aspnet_Applications aspnet_membership aspnet_paths aspnet_profiles aspnet_users aspnet_usersinRol...

ANSI standard of UNIX_TIMESTAMP()

UNIX_TIMESTAMP() isn't an ANSI standard keyword but an addition to the MySQL syntax. However, since I'm supporting multiple DB's, is there an ANSI standard way to write UNIX_TIMESTAMP(); Thanks ...

Syntax for date range SQL query in OpenOffice Base

I'm trying to SELECT based on a date in OpenOffice Base: SELECT * FROM OrderTbl WHERE OrdDate BETWEEN #1/1/2007# AND #1/31/2007# I've tried a number of variations, but nothing is working. What is the correct syntax? ...

Please help me decimal? in SQL

There are three columns of cost, participant, single_cost and wants to write SQL to classify the value that divided cost by participant into single_cost. I work to leave it off when decimal fraction appeared, and I can enter, but I say, and would knowing a method teach a value on this occasion? Each column is int type. Thanking you in ...

Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

Just curious if anyone else has got this particular error and know how to solve it? The scenario is as follow... We have an ASP.NET web application using Enterprise Library running on Windows Server 2008 IIS farm connecting to a SQL Server 2008 cluster back end. MSDTC is turned on. DB connections are pooled. My suspicion is that some...

How to get result from a column with combined data ?

data: id bb 1 14,35 2 5,11,12,125,36 3 3,23,45,15,1 4 651 5 5,1,6 6 1,7 For example, i wan't get id which with value '1'. So id(3,5,6) should return , but not others with '14' or '11'. DB: Mysql ...

How to update an SQLite database with a search and replace query?

My SQL knowledge is very limited, specially about SQLite, although I believe this is will be some sort of generic query... Or maybe not because of the search and replace... I have this music database in SQLite that has various fields of course but the important ones here the "media_item_id" and "content_url". Here's an example of a "co...

Converting MySQL select to Postgresql

Hello, I have this query which works correctly in MySQL. More background on it here. SELECT c.*, SUM(ABS(v.vote)) AS score FROM categories c,items i, votes v WHERE c.id = i.category_id AND i.id = v.voteable_id AND v.created_at > '#{1.week.ago}' GROUP BY c.id ORDER BY score DESC LIMIT 8; I tried running it in Postgresql and it ...

Avoding unnecessary updates In Update Query

Hi, In our application,Many pages includes "update" and when we update a table,we update unnecessary columns,which dont change,too. i want to know that is there a way to avoid unnecessary column updates?We use stored procedures in .net 2003.In Following link,i found a solution but it is not for stored procedures. http://blogs.msdn....

Same query uses different indexes?

Can a select query use different indexes if a change the value of a where condition? The two following queries use different indexes and the only difference is the value of the condition and typeenvoi='EXPORT' or and typeenvoi='MAIL' select numenvoi,adrdest,nomdest,etat,nbessais,numappel,description,typeperiode,datedebut,datefin,codeet...

Wordpress dbDelta function fails to execute my query

I have tried escaping all of the characters and that doesn't work. I need to insert this string specifically. Can anyone tell me what I'm missing? The other 4 insert statements work fine. Below is the full code: $user_id = mysql_insert_id(); $sql1 = "INSERT INTO `wp_usermeta` VALUES (NULL, $user_id, 'nickname', '$email'); INSERT INTO ...

Getting MIN Price in Subquery in SQL Server (using DISTINCT)?

Hi there, I am trying to get a Minimun price from a car in a table i have.. I am using DISTINCT SELECT DISTINCT datepart(year,[Registration]) AS YearRegistered, MIN(SalePrice), Model, Make FROM [VehicleSales] But its not working, for example without distinct returns many car makes and models so i use distinct so i get unique ca...

Dictionary table relationships (MS SQL 2005)

I have table named 'Dictionary' with columns as follow: ID bigint TYPE varchar (200) ITEM varchar (200) Table is used by various tables as simple dictionary / lookup. Eg it stores countries, titles, business type lists. TYPE column keeps info about type of dictionary , ITEM is dictionary string value. All works well but I ha...

using MIN on a datepart with Group BY not working, returns different dates

Hi there, Can anyone help with an aggregate function.. MIN. I have a car table that i want to return minimum sale price and minimum year on a tbale that has identical cars but different years and price ... Basically if i removed Registration (contains a YEAR) from the group by and select the query works but if i leave it in then i get...

How do I LIMIT the number of rows in a DELETE with DB2 ?

Hi, I want to add a security on a sensitive table when I delete lines with an SQL request on a DB2 table. I want to mimic the way MySQL allows you to limit the numbers of rows deleted in an SQL request. Basically I want to do this with DB2 : DELETE FROM table WHERE info = '1' LIMIT 1 Is there a way to do that with DB2 ? ...

visual studio pointing to my sql server

in visual studio i have my code point to a sql server mdf file (in the APP_DATA folder). and i keep having to syncronize this local data to my server. is there anyway in visual studio i can just give it the connection string to my real server so i can debug directly against my server. i know this may be a bit slower but it also might ...

How to release possible Postgres row locks?

I ran an update statement on a large PostgreSQL table through the phpPgAdmin interface. This timed out as it ran for too long. I can now update some rows from that table but not all. Trying to update some rows will hang. Are the rows locked? How can I allow these rows to be updated? ...

Idiom for using SqlDataReader as a resource

Following on from this question, I find myself writing the following code over and over again: SqlCommand command = new SqlCommand(); // Code to initialize command with what we want to do using (SqlConnection connection = openConnection()) { command.Connection = connection; using (SqlDataReader dataReader = thisCommand.ExecuteRe...

Select first day of preceding month in (DB2) SQL

I need to check whether a given date is in the preceding month for a monthly query. I can get CURRENT DATE - 1 MONTH to compare the selected date with, but I can't assume the current date will be the first day of each month exactly. Is there a built in way to get the first day of the month without extracting the year and month and glu...

sql query to export row values from one SQL Server database to another

I have a table with columns 'id', 'name', 'value', 'uniqueConst' in both databases. Now i need to export only all 'value' fields from one database to another 'where db1.uniqueConst = db2.uniqueConst'. Other fields are already in db2 and 'id's in both db are identity, so i cant just export the whole table. Can you help me? ...