Search Results

Search found 37012 results on 1481 pages for 'sql query'.

Page 92/1481 | < Previous Page | 88 89 90 91 92 93 94 95 96 97 98 99  | Next Page >

  • Why better isolation level means better performance in SQL Server

    - by Oleg Zhylin
    When measuring performance on my query I came up with a dependency between isolation level and elapsed time that was surprising to me READUNCOMMITTED - 409024 READCOMMITTED - 368021 REPEATABLEREAD - 358019 SERIALIZABLE - 348019 Left column is table hint, and the right column is elapsed time in microseconds (sys.dm_exec_query_stats.total_elapsed_time). Why better isolation level gives better performance? This is a development machine and no concurrency whatsoever happens. I would expect READUNCOMMITTED to be the fasted due to less locking overhead. Update: I did measure this with DBCC DROPCLEANBUFFERS DBCC FREEPROCCACHE issued and Profiler confirms there're no cache hits happening. Update2: The query in question is an OLAP one and we need to run it as fast as possible. Closing the production server from outside world to get the computation done is not out of question if this gives performance benefits.

    Read the article

  • I could use some help with my SQL command

    - by SuperSpy
    I've got a database table called 'mesg' with the following structure: receiver_id | sender_id | message | timestamp | read Example: 2 *(«me)* | 6 *(«nice girl)* | 'I like you, more than ghoti' | yearsago | 1 *(«seen it)* 2 *(«me)* | 6 *(«nice girl)* | 'I like you, more than fish' | now | 1 *(«seen it)* 6 *(«nice girl)* | 2 *(«me)* | 'Hey, wanna go fish?' | yearsago+1sec | 0 *(«she hasn't seen it)* It's quite a tricky thing that I want to achieve. I want to get: the most recent message(=ORDER BY time DESC) + 'contact name' + time for each 'conversation'. Contact name = uname WHERE uid = 'contact ID' (the username is in another table) Contact ID = if(sessionID*(«me)*=sender_id){receiver_id}else{sender_id} Conversation is me = receiver OR me = sender For example: From: **Bas Kreuntjes** *(« The message from bas is the most recent)* Hey $py, How are you doing... From: **Sophie Naarden** *(« Second recent)* Well hello, would you like to buy my spam? ... *(«I'll work on that later >p)* To: **Melanie van Deijk** *(« My message to Melanie is 3th)* And? Did you kiss him? ... That is a rough output. QUESTION: Could someone please help me setup a good SQL command. This will be the while loup <?php $sql = "????"; $result = mysql_query($sql); while($fetch = mysql_fetch_assoc($result)){ ?> <div class="message-block"> <h1><?php echo($fetch['uname']); ?></h1> <p><?php echo($fetch['message']); ?></p> <p><?php echo($fetch['time']); ?></p> </div> <?php } ?> I hope my explanation is good enough, if not, please tell me. Please don't mind my English, and the Dutch names (I am Dutch myself) Feel free to correct my English UPDATE1: Best I've got until now: But I do not want more than one conversation to show up... u=user table m=message table SELECT u.uname, m.message, m.receiver_uid, m.sender_uid, m.time FROM m, u WHERE (m.receiver_uid = '$myID' AND u.uid = m.sender_uid) OR (m.sender_uid = '$myID' AND u.uid = m.receiver_uid) ORDER BY time DESC;

    Read the article

  • SQL SELECT across two tables

    - by Brett Spurrier
    Hi there, I am a little confused as to how to approach this SQL query. I have two takes (equal number of records), and I would like to return a column with which is the division between the two. In other words, here is my not-working-correctly query: SELECT( (SELECT v FROM Table1) / (SELECT DotProduct FROM Table2) ); How would I do this? All I want it a column where each row equals the same row in Table1 divided by the same row in Table2. The resulting table should have the same number of rows, but I am getting something with a lot more rows than the original two tables. I am at a complete loss. Any advice?

    Read the article

  • SQL to get friends AND friends of friends of a user

    - by Enrique
    My MySQL tables structure is like this. USER int id varchar username FRIEND_LIST int user_id int friend_id For each friend relationship I insert 2 records in FRIEND_LIST. If user 1 is friend of user 2 then the next rows are inserted into FRIEND_LIST 1,2 2,1 I want to get the friends and friends of friends of an specific user. The select should return columns a, b, c. a: user_id b: friend_id c: username (username of friend_id ) If 1 is friend of 2 and 3. 2 is friend of 3, 4 and 5 3 is friend of 5,6,7 Then the query to get 1's friends and friends of friends should return: 1 2 two 1 3 three 2 1 one 2 3 three 2 4 four 2 5 five 3 1 one 3 5 five 3 6 six 3 7 seven Can I get this rows with a single query?

    Read the article

  • Using SQL to get the Last Reply on a Post

    - by Anraiki
    I am trying to replicate a forum function by getting the last reply of a post. For clarity, see PHPBB: there are four columns, and the last column is what I like to replicate. I have my tables created as such: discussion_id (primary key) user_id parent_id comment status pubdate I was thinking of creating a Link Table that would update for each time the post is replied to. The link table would be as follow: discussion_id (primary key) last_user_id last_user_update However, I am hoping that theres a advance query to achieve this method. That is, grabbing each Parent Discussion, and finding the last reply in each of those Parent Discussions. Am I right that there is such a query?

    Read the article

  • How to join table to itself and select max values in SQL

    - by Jakub Konop
    I have a contracts table: contractId date price partId 1 20120121 10 1 2 20110130 9 1 3 20130101 15 2 4 20110101 20 2 The contract with greatest date being the active contract (don't blame me, I blame infor for creating xpps) I need to create query to see only active contracts (one contract per part, the contract with highest date). So the result of the query should be like this: contractId date price partId 1 20120121 10 1 3 20130101 15 2 I am out of ideas here, I tried self joining the table, I tried aggregation functions, but I can't figure it out. If anyone would have any idea, please share them with me..

    Read the article

  • How to prompt user input parameters for SQL Queries in Access 2010

    - by user1848907
    SELECT Transactions.TransactionNumber FROM Transactions WHERE (((Transactions.Date)>=#11/23/12#)) AND (((Transactions.Date)<=#11/23/12#)); The above code returns all the transaction that happened between the specified dates. But I want those dates to be defined by the user every time the query is executed. I tried using the [] operators to have the user define the criteria in the WHERE, something like this: WHERE (((Transactions.Date)>=[Input a Date])) AND (((Transactions.Date)<=[Input a Date])); But microsoft Access throws a Syntax error message. The same happens when I include the # (date operators) like this WHERE (((Transactions.Date)>=#[Input a Date]#)) AND (((Transactions.Date)<=#[Input a Date]#)); Is there anopther way to manage dates that I'm not aware of or is asking a user for dates in a query out of the question

    Read the article

  • SQL Server 2008 + expensive union all

    - by Tim Mahy
    Hi al, we have 5 tables over which we should query with user search input throughout a stored procedure. We do a union all of the similar data inside a view. Because of this the view can not be materialized. We are not able to change these 5 tables drastically (like creating a 6th table that contains the similar data of the 5 tables and reference that new one from the 5 tables). The query is rather expensive / slow what are our other options? It's allowed to think outside the box. Unfortunately I cannot give more information like the table/view/SP definition because of customer confidentiality... greetings, Tim

    Read the article

  • Should i really use integer primary IDs [sql]

    - by arthurprs
    For example, i always generate an auto-increment field for the users table, but i also specifies an UNIQUE index on their usernames. There is situations that i first need to get the userId for a given username and then execute the desired query. Or use a JOIN in the desired query. It's 2 trips to the database or a JOIN vs. a varchar index The above is just an example There is a real performance benefit on INT over small VARCHAR indexes? Thanks in advance!

    Read the article

  • Finding group maxes in SQL join result

    - by Gene
    Two SQL tables. One contestant has many entries: Contestants Entries Id Name Id Contestant_Id Score -- ---- -- ------------- ----- 1 Fred 1 3 100 2 Mary 2 3 22 3 Irving 3 1 888 4 Grizelda 4 4 123 5 1 19 6 3 50 Low score wins. Need to retrieve current best scores of all contestants ordered by score: Best Entries Report Name Entry_Id Score ---- -------- ----- Fred 5 19 Irving 2 22 Grizelda 4 123 I can certainly get this done with many queries. My question is whether there's a way to get the result with one, efficient SQL query. I can almost see how to do it with GROUP BY, but not quite. In case it's relevant, the environment is Rails ActiveRecord and PostgreSQL.

    Read the article

  • Remove specific string from multiple database rows in SQL

    - by Scott
    I have a column that contains page titles, which has the website name appended to the end of each. (e.g. Product Name | Company Name Inc.) I would like to remove the " | Company Name Inc." from multiple rows simultaneously. What SQl query commands (or query itself) would allow me to accomplish this? To re-illustrate, I want to convert multiple rows of 1 column from this: Product Name | Company Name Inc. To this: Product Name

    Read the article

  • sql count function

    - by suryll
    Hi I have three tables and I want to know how much jobs with the wage of 1000 an employee has had The first SQL query gives me the names of all the employees that has recieved 1000 for a job SELECT distinct first_name FROM employee, job, link WHERE job.wage = 1000 AND job.job_id = link.job_id and employee.employee_id = link.employee_id; The second SQL query gives me the total number for all employees of how much jobs they have made for 1000 SELECT count(wage) FROM employee, job, link WHERE job.wage = 1000 AND job.job_id = link.job_id and employee.employee_id = link.employee_id; I was wondering if there was a way of joining both queries and also making the second for each specific employee???

    Read the article

  • SQL - Link to more table information

    - by BioXhazard
    I have a datagrid with 3 of 5 fields from a SQL table. The first databound was changed to an asp:hyperlink so the field can be clicked. What I want to do is, when the user clicks an object in the field, it sends the ID to another page. From there, it uses the request in order to display the required information which is found in the same SQL table. For example: User clicks on a cell in the first column, it brings them to a page with more information on that cell.

    Read the article

  • Win a place at a SQL Server Masterclass with Kimberly Tripp and Paul Randal

    - by Testas
    The top things YOU need to know about managing SQL Server - in one place, on one day - presented by two of the best SQL Server industry trainers!And you could be there courtesy of UK SQL Server User Group and SQL Server Magazine! This week the UK SQL Server User Group will provide you with details of how to win a place at this must see seminar   You can also register for the seminar yourself at:www.regonline.co.uk/kimtrippsql More information about the seminar   Where: Radisson Edwardian Heathrow Hotel, London When: Thursday 17th June 2010 This one-day MasterClass will focus on many of the top issues companies face when implementing and maintaining a SQL Server-based solution. In the case where a company has no dedicated DBA, IT managers sometimes struggle to keep the data tier performing well and the data available. This can be especially troublesome when the development team is unfamiliar with the affect application design choices have on database performance. The Microsoft SQL Server MasterClass 2010 is presented by Paul S. Randal and Kimberly L. Tripp, two of the most experienced and respected people in the SQL Server world. Together they have over 30 years combined experience working with SQL Server in the field, and on the SQL Server product team itself. This is a unique opportunity to hear them present at a UK event which will:·         Debunk many of the ingrained misconceptions around SQL Server's behaviour   ·         Show you disaster recovery techniques critical to preserving your company's life-blood - the data   ·         Explain how a common application design pattern can wreak havoc in the database ·         Walk through the top-10 points to follow around operations and maintenance for a well-performing and available data tier! Please Note: Agenda may be subject to changeSessions AbstractsKEYNOTE: Bridging the Gap Between Development and Production  Applications are commonly developed with little regard for how design choices will affect performance in production. This is often because developers don't realize the implications of their design on how SQL Server will be able to handle a high workload (e.g. blocking, fragmentation) and/or because there's no full-time trained DBA that can recognize production problems and help educate developers. The keynote sets the stage for the rest of the day. Discussing some of the issues that can arise, explaining how some can be avoided and highlighting some of the features in SQL 2008 that can help developers and DBAs make better use of SQL Server, and troubleshoot when things go wrong.  SESSION ONE: SQL Server MythbustersIt's amazing how many myths and misconceptions have sprung up and persisted over the years about SQL Server - after many years helping people out on forums, newsgroups, and customer engagements, Paul and Kimberly have heard it all. Are there really non-logged operations? Can interrupting shrinks or rebuilds cause corruption? Can you override the server's MAXDOP setting? Will the server always do a table-scan to get a row count? Many myths lead to poor design choices and inappropriate maintenance practices so these are just a few of many, many myths that Paul and Kimberly will debunk in this fast-paced session on how SQL Server operates and should be managed and maintained. SESSION TWO: Database Recovery Techniques Demo-Fest Even if a company has a disaster recovery strategy in place, they need to practice to make sure that the plan will work when a disaster does strike. In this fast-paced demo session Paul and Kimberly will repeatedly do nasty things to databases and then show how they are recovered - demonstrating many techniques that can be used in production for disaster recovery. Not for the faint-hearted! SESSION THREE: GUIDs: Use, Abuse, and How To Move Forward Since the addition of the GUID (Microsoft’s implementation of the UUID), my life as a consultant and "tuner" has been busy. I’ve seen databases designed with GUID keys run fairly well with small workloads but completely fall over and fail because they just cannot scale. And, I know why GUIDs are chosen - it simplifies the handling of parent/child rows in your batches so you can reduce round-trips or avoid dealing with identity values. And, yes, sometimes it's even for distributed databases and/or security that GUIDs are chosen. I'm not entirely against ever using a GUID but overusing and abusing GUIDs just has to be stopped! Please, please, please let me give you better solutions and explanations on how to deal with your parent/child rows, round-trips and clustering keys! SESSION 4: Essential Database MaintenanceIn this session, Paul and Kimberly will run you through their top-ten database maintenance recommendations, with a lot of tips and tricks along the way. These are distilled from almost 30 years combined experience working with SQL Server customers and are geared towards making your databases more performant, more available, and more easily managed (to save you time!). Everything in this session will be practical and applicable to a wide variety of databases. Topics covered include: backups, shrinks, fragmentation, statistics, and much more! Focus will be on 2005 but we'll explain some of the key differences for 2000 and 2008 as well.    Speaker Biographies     Paul S.Randal  Kimberley L. Tripp Paul and Kimberly are a husband-and-wife team who own and run SQLskills.com, a world-renowned SQL Server consulting and training company. They are both SQL Server MVPs and Microsoft Regional Directors, with over 30 years of combined experience on SQL Server. Paul worked on the SQL Server team for nine years in development and management roles, writing many of the DBCC commands, and ultimately with responsibility for core Storage Engine for SQL Server 2008. Paul writes extensively on his blog (SQLskills.com/blogs/Paul) and for TechNet Magazine, for which he is also a Contributing Editor. Kimberly worked on the SQL Server team in the early 1990s as a tester and writer before leaving to found SQLskills and embrace her passion for teaching and consulting. Kimberly has been a staple at worldwide conferences since she first presented at TechEd in 1996, and she blogs at SQLskills.com/blogs/Kimberly. They have written Microsoft whitepapers and books for SQL Server 2000, 2005 and 2008, and are regular, top-rated presenters worldwide on database maintenance, high availability, disaster recovery, performance tuning, and SQL Server internals. Together they teach the SQL MCM certification and throughout Microsoft.In their spare time, they like to find frogfish in remote corners of the world.  

    Read the article

  • SQL Server Driver for PHP 2.0 CTP2 is now released

    - by The Official Microsoft IIS Site
    digg_url = "http://blogs.msdn.com/b/sqlphp/archive/2010/06/15/sql-server-driver-for-php-2-0-ctp2-is-now-released.aspx";digg_title = "SQL Server Driver for PHP 2.0 CTP2 is now released";digg_bgcolor = "#FFFFFF";digg_skin = "normal"; digg_url = undefined;digg_title = undefined;digg_bgcolor = undefined;digg_skin = undefined; It is our pleasure to announce the release of Community Technology Preview 2 (CTP2) of the SQL Server Driver for PHP 2.0! We would like to...(read more)

    Read the article

  • Transactions in LINQ to SQL applications

    - by nikolaosk
    In this post I would like to talk about LINQ to SQL and transactions.When I have a LINQ to SQL class I always get asked this question, "How does LINQ treat Transactions?". When we use the DeleteOnSubmit() method or the InsertOnSubmit() method, all of those commands at some point are translated into T-SQL commands and then are executed against the database. All of those commands live in transactions and they follow the basic rules of transaction processing. They do succeed together or fail together...(read more)

    Read the article

  • List SQL Server Instances using the Registry

    - by BuckWoody
    I read this interesting article on using PowerShell and the registry, and thought I would modify his information a bit to list the SQL Server Instances on a box. The interesting thing about listing instances this was is that you can touch remote machines, find the instances when they are off and so on. Anyway, here’s the scriptlet I used to find the Instances on my system: $MachineName = '.' $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $MachineName) $regKey= $reg.OpenSubKey("SOFTWARE\\Microsoft\\Microsoft SQL Server\\Instance Names\\SQL" ) $regkey.GetValueNames() You can read more of his article to find out the reason for the remote registry call and so forth – there are also security implications here for being able to read the registry. Script Disclaimer, for people who need to be told this sort of thing: Never trust any script, including those that you find here, until you understand exactly what it does and how it will act on your systems. Always check the script on a test system or Virtual Machine, not a production system. Yes, there are always multiple ways to do things, and this script may not work in every situation, for everything. It’s just a script, people. All scripts on this site are performed by a professional stunt driver on a closed course. Your mileage may vary. Void where prohibited. Offer good for a limited time only. Keep out of reach of small children. Do not operate heavy machinery while using this script. If you experience blurry vision, indigestion or diarrhea during the operation of this script, see a physician immediately. Share this post: email it! | bookmark it! | digg it! | reddit! | kick it! | live it!

    Read the article

  • SQL Relay - G is for GO

    - by fatherjack
    At the SQL Relay event last week all the UK user group leaders did a combined session - The A to Z of SQL - where we all took two letters of the alphabet and gave a 2 minute (it was strictly timed) talk on something SQL related beginning with those letters. It was quite a riot working through 26 different talks in an hour with 25 speaker handovers and the associated switches between SSMS and the slide deck. As a speaker I thoroughly enjoyed it and i hoe we informed as much as  we entertained the...(read more)

    Read the article

  • I have written an SQL query but I want to optimize it [closed]

    - by ankit gupta
    is there any way to do this using minimum no of joins and select? 2 tables are involved in this operation transaction_pci_details and transaction SELECT t6.transaction_pci_details_id, t6.terminal_id, t6.transaction_no, t6.transaction_id, t6.transaction_type, t6.reversal_flag, t6.transmission_date_time, t6.retrivel_ref_no, t6.card_no,t6.card_type, t6.expires_on, t6.transaction_amount, t6.currency_code, t6.response_code, t6.action_code, t6.message_reason_code, t6.merchant_id, t6.auth_code, t6.actual_trans_amnt, t6.bal_card_amnt, t5.sales_person_id FROM TRANSACTION AS t5 INNER JOIN ( SELECT t4.transaction_pci_details_id, t4.terminal_id, t4.transaction_no, t4.transaction_id, t4.transaction_type, t4.reversal_flag, t4.transmission_date_time, t4.retrivel_ref_no, t4.card_no, t4.card_type, t4.expires_on, t4.transaction_amount, t4.currency_code, t4.response_code, t4.action_code, t3.message_reason_code, t4.merchant_id, t4.auth_code, t4.actual_trans_amnt, t4.bal_card_amnt FROM ( SELECT* FROM transaction_pci_details WHERE message_reason_code LIKE '%OUT%'|| message_reason_code LIKE '%FAILED%' /*we can add date here*/ UNION ALL SELECT t2.transaction_pci_details_id, t2.terminal_id, t2.transaction_no, t2.transaction_id, t2.transaction_type, t2.reversal_flag, t2.transmission_date_time, t2.retrivel_ref_no, t2.card_no, t2.card_type, t2.expires_on, t2.transaction_amount, t2.currency_code, t2.response_code, t2.action_code, t2.message_reason_code, t2.merchant_id, t2.auth_code, t2.actual_trans_amnt, t2.bal_card_amnt FROM ( SELECT transaction_id FROM TRANSACTION WHERE transaction_type_id = 8 ) AS t1 INNER JOIN ( SELECT * FROM transaction_pci_details WHERE message_reason_code LIKE '%appro%' /*we can add date here*/ ) AS t2 ON t1.transaction_id = t2.transaction_id ) AS t3 INNER JOIN ( SELECT* FROM transaction_pci_details WHERE action_code LIKE '%REQ%' /*we can add date here*/ ) AS t4 ON t3.transaction_pci_details_id - t4.transaction_pci_details_id = 1 ) AS t6 ON t5.transaction_id = t6.transaction_id

    Read the article

  • Error 404 after rewrite query strings with htaccess

    - by Cristian
    I'm trying to redirect the URLs of a client's website like this: www.localsite.com/immobile.php?id_immobile=24 In something like this: www.localsite.com/immobile/24.php I'm using this rule in .htaccess but it returns a 404 error page. RewriteEngine On RewriteCond %{QUERY_STRING} ^id_immobile=([0-9]*)$ RewriteRule ^immobile\.php$ http://localsite.com/immobile/%1.php? [L] I have tried many other rules, but none work. What can I do?

    Read the article

  • List SQL Server Instances using the Registry

    - by BuckWoody
    I read this interesting article on using PowerShell and the registry, and thought I would modify his information a bit to list the SQL Server Instances on a box. The interesting thing about listing instances this was is that you can touch remote machines, find the instances when they are off and so on. Anyway, here’s the scriptlet I used to find the Instances on my system: $MachineName = '.' $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $MachineName) $regKey= $reg.OpenSubKey("SOFTWARE\\Microsoft\\Microsoft SQL Server\\Instance Names\\SQL" ) $regkey.GetValueNames() You can read more of his article to find out the reason for the remote registry call and so forth – there are also security implications here for being able to read the registry. Script Disclaimer, for people who need to be told this sort of thing: Never trust any script, including those that you find here, until you understand exactly what it does and how it will act on your systems. Always check the script on a test system or Virtual Machine, not a production system. Yes, there are always multiple ways to do things, and this script may not work in every situation, for everything. It’s just a script, people. All scripts on this site are performed by a professional stunt driver on a closed course. Your mileage may vary. Void where prohibited. Offer good for a limited time only. Keep out of reach of small children. Do not operate heavy machinery while using this script. If you experience blurry vision, indigestion or diarrhea during the operation of this script, see a physician immediately. Share this post: email it! | bookmark it! | digg it! | reddit! | kick it! | live it!

    Read the article

  • PowerShell to fetch a SQL Execution Plan

    - by Rob Farley
    With PowerShell becoming the scripting language of choice for many people, I’ve occasionally wondered about using it to analyse execution plans. After all, an execution plan is just XML, and PowerShell is just one tool which will very easily handle xml. The thing is – there’s no Get-SqlPlan cmdlet available, which has frustrated me in the past. Today I figured I’d make one. I know that I can write T-SQL to get an execution plan using SET SHOWPLAN_XML ON, but the problem is that this must be the only statement in a batch. So I used go, and a couple of newlines, and whipped up the following one-liner: function Get-SqlPlan([string] $query, [string] $server, [string] $db) { return ([xml] (invoke-sqlcmd -Server $server -Database $db -Query "set showplan_xml on;`ngo`n$query").Item( 0)) } (but please bear in mind that I have the SQL Snapins installed, which provides invoke-sqlcmd) To use this, I just do something like: $plan = get-sqlplan "select name from Production.Product" "." "AdventureWorks" And then find myself with an easy way to navigate through an execution plan! At some point I should make the function more robust, but this should be a good starter for any SQL PowerShell enthusiasts (like Aaron Nelson) out there.

    Read the article

  • SQL SERVER Subquery or Join Various Options SQL Server Engine Knows the Best Part 2

    This blog post is part 2 of the earlier written article SQL SERVER Subquery or Join Various Options SQL Server Engine knows the Best by Paulo R. Pereira. Paulo has left excellent comment to earlier article once again proving the point that SQL Server Engine is smart enough to figure out the [...]...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Oracle to SQL Server: Crossing the Great Divide, Part 1

    When a SQL expert moves from Oracle to SQL Server, he can spot obvious strengths and weaknesses in the product that aren't obvious to the SQL Server DBA. Jonathan Lewis is that man, as he records his train of thought whilst he investigates the mechanics of the database engine. The result makes interesting reading.

    Read the article

< Previous Page | 88 89 90 91 92 93 94 95 96 97 98 99  | Next Page >