Skip to content
Advertisement

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 …

Sql Query to Linq

How would I convert this query from SQL to Linq: Update Thanks Guys, this is the code I used. Tested and returns the same as above: Answer I don’t know if the syntax is correct (especially the last two lines) but it should be pretty close. I added the 0 between group and by based on Eamon Nerbonne’s correction in

How do I calculate a running total in SQL without using a cursor?

I’m leaving out all the cursor setup and the SELECT from the temp table for brevity. Basically, this code computes a running balance for all transactions per transaction. Inspired by this code from an answer to another question, I was wondering if SQL had the ability to sum numbers in the same way it’s concatonating strings, if you get my

Dynamic order direction

I writing a SP that accepts as parameters column to sort and direction. I don’t want to use dynamic SQL. The problem is with setting the direction parameter. This is the partial code: Answer You could have two near-identical ORDER BY items, one ASC and one DESC, and extend your CASE statement to make one or other of them always

Oracle SQL escape character (for a ‘&’)

While attempting to execute SQL insert statements using Oracle SQL Developer I keep generating an “Enter substitution value” prompt: I’ve tried escaping the special character in the query using the ” above but I still can’t avoid the ampersand, ‘&’, causing a string substitution. Answer the & is the default value for DEFINE, which allows you to use substitution variables.

Advertisement