sql-server-2000

T-SQL Old style joins *= and =*

时光总嘲笑我的痴心妄想 提交于 2019-12-08 11:56:29
问题 We have about 150 old style queries and views that use the *= and =* type ANSI92? join. Does anybody know of a tool / method or script that could help with the conversion or do we have to just slog through all 150 of them. Thanks Select PapersSent, DateSent, Code, ActionDate, ClientAction, ClientContactRef, PublishAppraisal, PublishCV, SponsorContactREF, MeetingNotes, InternalNotes, Contact_AdminAction, MeetingLocation from tblMeetingNotes a, tblPapersOptions b, tblContactLog c where a.CREF=

How to get multiple column data in a comma separated string?

北战南征 提交于 2019-12-08 10:52:35
问题 I am getting data like Result ------ 10 23 21 But i want to get data in the following format. Result ------ 10, 23, 21 How to get that in a Query? Thanks in advance for any help :) 回答1: Here is one way, There is a student table having studentName column with datatype as nvarchar(50) then following query will give you student names as comma separated values, DECLARE @VALUES NVARCHAR(1000) SELECT @VALUES = COALESCE(@VALUES + ',','') + CAST(STUDENTNAME AS NVARCHAR(50)) FROM STUDENT SELECT

Select Top 5 records of every employee in SQL Server

孤者浪人 提交于 2019-12-08 10:42:24
问题 I have the following issue, I have this query that select the latest 5 records created for an employee: SELECT TOP 5 p.value, p.record_date AS FECHA FROM employee_loan_movements p WHERE p.employee_code = '1' AND p.record_date <= '2009-11-11' AND p.movement_type = 1 AND p.value > 0 ORDER BY p.record_date DESC Now i need to build a query to select the top 5 of every employee in the loan_movements table, I know i can do it in Oracle by selecting selecting rownum and rownum <= 5 but I cant manage

Help with generating a report from data in a parent-children model

十年热恋 提交于 2019-12-08 07:26:12
问题 I need help with a problem regarding data saved in a parent-children model table and a report I need to build upon it. I've already tried searching for topics about parent-children issues, but I couldn't find anything useful in my scenario. What I have A Microsoft SQL Server 2000 database server. A categories table, which has four columns: category_id , category_name , father_id and visible ; the categories have x root categories (where x is variable), and could be y level deep (where y is

Addresses stored in SQL server have many small variations(errors)

一曲冷凌霜 提交于 2019-12-08 07:06:30
I have a table in my database which stores packing slips and their information. I'm trying to query that table and get each unique address. I've come close, but I still have many near misses and I'm looking for a way to exclude these near duplicates from my select. Sample Data CompanyCode CompanyName Addr1 City State Zip 10033 UNITED DIE CUTTING & FINISHIN 3610 HAMILTON AVE CLEVELAND Ohio 44114 10033 UNITED DIE CUTTING & FINISHING 3610 HAMILTON AVE CLEVELAND Ohio 44114 10033 UNITED DIE CUTTING & FINISHING 3610 HAMILTON AVE. CLEVELAND Ohio 44114 10033 UNITED DIE CUTTING & FINISHING 3610

How to select column names from multiple tables in SQL Server 2000-2008 that are in a set of names

。_饼干妹妹 提交于 2019-12-08 06:44:50
问题 If I have a set of names like this: ('first', 'fname', 'firstname', 'namef', 'namefirst', 'name') What is the best method in SQL Server 2000 - 2008 to retrieve the distinct table names that contain column names in the above set for a specific database? And I wanted to exclude system table and temp tables from the list of tables that are displayed. SELECT so.name FROM sysobjects so INNER JOIN syscolumns sc ON so.id = sc.id WHERE sc.name IN ('first', 'fname', 'firstname', 'namef', 'namefirst',

Median in SQL Server 2000

喜你入骨 提交于 2019-12-08 06:09:16
问题 For even rows formula for median is (104.5 + 108)/2 for table below and For odd rows it is 108 for table below Total Total 100 100 101 101 104.5 104.5 108 108 108.3 108.3 112 112 114 Code below works in SQL Server 2008 but not in SQL Server 2000 as it does not understand row_number() and over . How can we change the lower code to make it work on SQL Server 2000? select avg(Total) median from (select Total, rnasc = row_number() over(order by Total), rndesc = row_number() over(order by Total

Rolling back and update command in Sql Server 2000

别来无恙 提交于 2019-12-08 05:17:43
问题 I have used an update command to update the whole table in an Sql Server 2000 database by mistake. I was actually meaning to update just one row. Now all the 2000 rows contain the update. Is there a way to roll back this change? 回答1: Unless you started your update with an explicit transaction, no. However, you might be able to use Log Rescue . I'm not sure though if this can help you in this case. A better option might be to restore a backup to a new database and merge the old and new tables.

What are the new t-sql features sql server 2005?

随声附和 提交于 2019-12-08 05:04:33
问题 Where do I find a complete list of new T-SQL features in sql server 2005 comparing with 2000? A few ones that I know: Pivot, Output, Try..Catch. Anything else? Thank you. 回答1: Here is a Microsoft reference from Books online: http://msdn.microsoft.com/en-us/library/ms189465(SQL.90).aspx It contains Sample database enhancements, tsql data types and some others. Not the best resource (silly because it's written for SQL Server), but something. Here is a good resource at SQLServerCentral.com.

sql server 2000 TSQL: creating index on table variable

时光毁灭记忆、已成空白 提交于 2019-12-08 04:37:35
问题 Is the following possible? I am unable to do so. Do I have to have a permanent table to create index? declare @Beatles table ( LastName varchar(20) , FirstName varchar(20) ) CREATE CLUSTERED INDEX Index_Name_Clstd ON @Beatles(LastName) 回答1: Not on a table variable, but on a temp table see this http://www.sqlteam.com/article/optimizing-performance-indexes-on-temp-tables 回答2: No, you cannot create indices on a table variable - see this article here and this posting here comparing local, global