Skip to content

Should SQL ranking functionality be considered as “use with caution”

This question originates from a discussion on whether to use SQL ranking functionality or not in a particular case. Any common RDBMS includes some ranking functionality, i.e. its query language has elements like TOP n … ORDER BY key, ROW_NUMBER() OVER (ORDER BY key), or ORDER BY key LIMIT n (overview). They do a great job in increasing performance if

Export all MS Access SQL queries to text files

I have to document an MS Access database with many many macros queries, etc. I wish to use code to extract each SQL query to a file which is named the same as the query, eg if a query is named q_warehouse_issues then i wish to extract the SQL to a file named q_warehouse_issues.sql I DO NOT WISH TO EXPORT

How should I pass a table name into a stored proc?

I just ran into a strange thing…there is some code on our site that is taking a giant SQL statement, modifying it in code by doing some search and replace based on some user values, and then passing …

how can I Update top 100 records in sql server

I want to update the top 100 records in SQL Server. I have a table T1 with fields F1 and F2. T1 has 200 records. I want to update the F1 field in the top 100 records. How can I update based on TOP …

How To Do Percent/Total in SQL?

I have an typical CUSTOMER/ORDERS set of tables and I want to display the total percentage of sales a particular customer is responsible for. I can get the total number of orders in the system like so: And I can get the the total number of orders made by the customer like so: How can I combine these into a

Function vs. Stored Procedure in SQL Server

I’ve been learning Functions and Stored Procedure for quite a while but I don’t know why and when I should use a function or a stored procedure. They look same to me, maybe because I am kinda newbie …