Quantcast
Channel: CodeSection,代码区,SQL Server(mssql)数据库 技术分享 - CodeSec
Viewing all articles
Browse latest Browse all 3160

SQL Server Sorting Algorithm

$
0
0
Sort javascript to match SQL Server sort

Can anyone point me towards a sorting algorithm in javascript that would sort the same way SQL Server does (for nvarchar/unicode columns)? For reference, my previous question about this behavior can be found here: SQL Server 2008 - different sort ord

SQL Server: Sorting and Verifying

I have a table named Logs: ->OCCUR_TIME --date and time ->NAME --name of a person ->KIND --the kind of log (eg. 40 means `something`) ->VALUE --the value of the kind of log (eg. 99) I have to create a query: SELECT * FROM LOGS WHERE NAME='dude

SQL Server - Sort by datepart week

I am using SQL Server. When I try to sort information by week using the datepart function it returns no values. There are values in my table for the selected date range. The query I am trying to use is: Declare @StartDate datetime, @EndDate datetime

UPDATE SQL Server Statement Algorithm

Suppose I have two tables. Table 1: ID NAME 1 'AAA' 2 'BBB' Table 2: ID IDNAME 1 'CCC' 1 'DDD' I have to update first table values so I am using below query: UPDATE a SET a.name = b.IDname FROM table1 a JOIN table2 b ON a.ID = b.id Now, my question i

SQL Server: sorting null values from date to last line

I have a problem here in sorting of date that has some of entries are null I want the null values to be in the last row. I've already tried a solution found here in stack overflow the code is like this. SELECT * FROM table WHERE ... ORDER BY CASE WHE

Can I store the SQL Server sort order in a variable?

I have the following SQL within a stored procedure. Is there a way to remove the IF statement and pass the 'ASC'/'DESC' option as a variable? I know I could do the query a number of different ways, or return a table and sort it externally etc. I woul

SQL Server sort by hour plus one hour

I have a database of events each with a Time field that needs to be sorted in ascending order from said time. The "day" for these events start at 11:00PM (events take place 24 hours / day from 11:00PM to 10:59PM). Is there a way to sort my event

Dynamic SQL Server Sorting on Multiple Columns

I have a stored procedure which uses dynamic sorting, 2 parameters determine the sorting - column: @SortIndex and sort direction: @SortDirection relevant code: ... ROW_NUMBER() OVER ( ORDER BY -- string order by CASE @SortDirection WHEN 'ASC' THEN CA

SQL Server sort column based on the same column

I have a db table containing a column display_order. The data looks like this: 2 4 7 10 12 I want to update the same db column and it should look like this: 1 2 3 4 5 Please suggest some easy SQL code.Have a look into ROW_NUMBER(), this will help you

Can SQL Server SQL_Latin1_General_CP1_CI_AS be securely converted to Latin1_General_CI_AS?

We have a legacy database with some (older) columns using "SQL_Latin1_General_CP1_CI_AS" and more recent changes have used "Latin1_General_CI_AS". This is a pain as joins need the additional COLLATE statement to work. I'd like to bring

Character set issues with Oracle Gateways, SQL Server, and Application Express

I am migrating data from a Oracle on VMS that accesses data on SQL Server using heterogeneous services (over ODBC) to Oracle on AIX accessing the SQL Server via Oracle Gateways (dg4msql). The Oracle VMS database used the WE8ISO8859P1 character set. T

Avoiding unnecessary sorting in SQL Server GROUP BY?

I have tables of data samples, with a timestamp and some data. Each table has a clustered index on the timestamp, and then a data-specific key. Data samples are not necessarily equidistant. I need to downsample the data in a particular time range in

Retrieve sorted column value in SQL Server

What i have: I have a Column ID SerialNo 1 101 2 102 3 103 4 104 5 105 6 116 7 117 8 118 9 119 10 120 These are just the 10 dummy rows. The actual table has over 100 000 rows. What I Want to get: A method or formula like any sorting techniq

Keep the SQL Server table sorted in the database

In my application I use a simple table that contains the number of times a file was accessed and the date at which it was last accessed. I'm trying to sort the saved entries so that the files with the highest number of accesses are always on top in t


Viewing all articles
Browse latest Browse all 3160

Trending Articles