sql

SQL 2008 Change Data Capture Query Performance Issue (SP vs. straight query)

Before I open a ticket with Microsoft Support, I thought I'd try the community! I have an application in development for which we are using Change Data Capture in SQL 2008 R2 (developer edition, currently). For some particularly complex queries, we wanted to wrap the queries into stored procedures, exposing common parameters, to avoid c...

Migrate MySQL database to Sql Server

I recently encountered a problem in my production database due to MySQL bug. The bug is in the TimeStamp column. To avoid any inconvenience, I want to migrate the database to either Sql Server. Is there any FREE tool to easily and reliably migrate data and table structures? ...

Get latest record from second table left joined to first table

I have a candidate table say candidates having only id field and i left joined profiles table to it. Table profiles has 2 fields namely, candidate_id & name. e.g. Table candidates: id ---- 1 2 and Table profiles: candidate_id name ---------------------------- 1 Foobar 1 Foobar2 2 ...

MySQL VIEW vs. embedded query, which one is faster?

I'm going to optimize a MySQL embedded query with a view, but I'm not sure whether it will give an effect: SELECT id FROM (SELECT * FROM t); I want to convert it to: CREATE VIEW v AS SELECT * FROM t; SELECT id FROM v; I've heard about "indexed views" in SQL Server, but I'm not sure about MySQL. Any help would be appreciated. Thank...

retrieving second most highest value from the table

how do i retrieve the second highest value from the table ...

update two or more tables with the single statement

How do i update two or more two tables without the help of where clause. Thanks... ...

How to query for Double with Spring JDBC template query

How do one query for a double with the Spring JDBC temple? For example: public double getAverageScore() { return jdbctemplate.queryFor???("select avg(score) from test"); } There are queryForInt and queryForLong, but no queryForDouble ...

How to remove all data about some Web Application from aspnet tables ?

Is there some way to remove data about all users , roles e t c from some Web application into aspnet database tables ? tables like dbo.aspnet_Applications (here is this application that I want to remove) but also I need to remove all data with this application in other tables... ...

SQLAlchemy: How to group by two fields and filter by date

So I have a table with a datestamp and two fields that I want to make sure that they are unique in the last month. table.id table.datestamp table.field1 table.field2 There should be no duplicate record with the same field1 + 2 compound value in the last month. The steps in my head are: Group by the two fields Look back over the las...

Update a field thanks to a subquery based on another field

Hi, I use a MySQL DB, and I would like to update a field in a table based on another. Something like: UPDATE table1 SET field1 = table2.id WHERE field2 IN ( SELECT table2.name FROM table2 ); I know that this query wouldn't work, but here is the idea. Is that even possible to do? Cheers, Nicolas. ...

MYSQL Download Links.....

I want to download MySQL Database..... Any one can suggest me for best link to download the MYSQL ...

DataGridView population+modificaion by SQL Server DB View

I searched StackOverFlow.com for my issue, but could not find any similar/related solution. I have few tables in SQL Server 2005, and have to make use of those tables in my Winform/C# application which is supposed to be an Admin Application where the Administrator will:- 1.Add/Edit users 2.Assign Roles 3.Assign Privileges 4.Zone As...

Finding simultaneous events in a database between times

I have a database that stores phone call records. Each phone call record has a start time and an end time. I want to find out what is the maximum amount of phone calls that are simultaneously happening in order to know if we have exceed the amount of available phone lines in our phone bank. How could I go about solving this problem? ...

Dynamic order by without using dynamic sql ?

I have the following stored procedure which can be sorted ascending and descending on TemplateName,CreatedOn and UploadedBy. The following SP when runs doesnot sort records.if i replace 2,3,4 by columnname, i got an error message "Conversion failed when converting the nvarchar value 'Test Template' to data type int.".Please suggest how t...

how does sql count work?

I would like to understand how exactly does sql count work. Is it a whole table scan that happens or is it some property of the table that is read. However I feel a table scan would be an overhead in case of huge tables with lots of records. ...

What's the Correct name for a Association table (many to many relationship)

What's the Correct or most popular name for a Association table? I've heard Lookup,associative,resolving,mapping and junction table so far? Thank you in advance;-) ...

SQL Query Help Part 2 - Add filter to joined tables and get max value from filter

I asked this question on SO. However, I wish to extend it further. I would like to find the max value of the 'Reading' column only where the 'state' is of value 'XX' for example. So if I join the two tables, how do I get the row with max(Reading) value from the result set. Eg. SELECT s.*, g1.* FROM Schools AS s JOIN Grades AS g1 ON g1....

Data Reader formatting output

I'm using the following function to generate a list of users connected to a selected database. How would I change this to a single line for multiple identical results? For example: "sa (3) - MYCOMPUTER" rather than listing "sa - MYCOMPUTER" three times? Function ConnectedUsers(ByVal SelectedDatabase As String, ByVal SelectedInstance As ...

My tricky SQL Update query not working so well.

I am trying to update a table in my database with another row from another table. I have two parameters one being the ID and another being the row number (as you can select which row you want from the GUI) this part of the code works fine, this returns one column of a single row. (select txtPageContent FROM (select *, Row_Number()...

Set of Tools to optimize the performance in general of SQL Server

Hi, I know there are things out there to help to optimize queries, ect... but is there anything else, something like a full package that can scan your database and highlight all the performance issues, naming conventions, tables not properly normalized, etc? I know this is the job of a DBA and if the DBA is good, he shouldn't need a t...