sql-server-2000

Remove trailing empty space in a field content

心不动则不痛 提交于 2019-11-28 08:39:15
I am using SQL server MSDE 2000. I have a field called notes of type nvarchar(65). The content is 'Something ' with an extra space after the content (quotes for clarity) in all the records. I used the following command. UPDATE TABLE1 SET notes = RTRIM(LTRIM(notes)) But it does not work. Is there any alternate way to do it? Are you sure the query isn't working? Try: SELECT TOP 100 '~'+ t.notes +'~' FROM TABLE1 t TOP 100 will limit the results to the first 100 rows, enough to get an idea if there's really a space in the output. If there is, and RTRIM/LTRIM is not removing it - then you aren't

SQL select max(date) and corresponding value [duplicate]

£可爱£侵袭症+ 提交于 2019-11-28 08:23:37
Possible Duplicate: How to get the record of a table who contains the maximum value? I've got an aggregate query like the following: SELECT TrainingID, Max(CompletedDate) as CompletedDate, Max(Notes) as Notes --This will only return the longest notes entry FROM HR_EmployeeTrainings ET WHERE (ET.AvantiRecID IS NULL OR ET.AvantiRecID = @avantiRecID) GROUP BY AvantiRecID, TrainingID Which is working, and returns correct data most of the time, but I noticed a problem. The Notes field which gets returned will not necessarily match the record that the max(completedDate) is from. Instead it will be

How to insert JPEG into a SQL Server 2000 database field of image type using Transact SQL

∥☆過路亽.° 提交于 2019-11-28 07:30:55
问题 I'm trying to figure out how to insert a .JPG file into a SQL Server 2000 database field of type image using Transact SQL. Thanks. 回答1: Use OPENROWSET: INSERT MyTable (ImageColumnName) SELECT BulkColumn FROM OPENROWSET (BULK 'c:\myjpeg.jpg', SINGLE_BLOB) AS X EDITED Whoops, you're using 2000--the previous solution is not supported. You have to use WRITETEXT: CREATE TABLE MyTable ( ID INT PRIMARY KEY IDENTITY (1,1), ImageColumnName IMAGE NULL ) GO -- must insert a dummy value into the image

Is there a way to get a list of all current temporary tables in SQL Server?

独自空忆成欢 提交于 2019-11-28 06:40:46
I realize that temporary tables are session/connection bound and not visible or accessible out of the session/connection. I have a long running stored procedure that creates temporary tables at various stages. Is there a way I can see the list of current temporary tables? What privileges do I need to be able to do so? Alternatively, Is there a way I can see the particular SQL statement being executed inside a running stored procedure? The procedure is running as a scheduled job in SQL Server. I am using SQL Server 2000. Thanks for your guidance. Sandro Is this what you are after? select * from

How to join two tables together with same number of rows by their order

∥☆過路亽.° 提交于 2019-11-28 03:46:10
问题 I am using SQL2000 and I would like to join two table together based on their positions For example consider the following 2 tables: table1 ------- name ------- 'cat' 'dog' 'mouse' table2 ------ cost ------ 23 13 25 I would now like to blindly join the two table together as follows based on their order not on a matching columns (I can also guarantee both tables have the same number of rows): -------|----- name |cost -------|------ 'cat' |23 'dog' |13 'mouse'|25 Is this possible in a T-SQL

SQL Server 2000: Ideas for performing concatenation aggregation subquery

冷暖自知 提交于 2019-11-28 03:45:37
问题 i have a query that returns rows that i want, e.g. QuestionID QuestionTitle UpVotes DownVotes ========== ============= ======= ========= 2142075 Win32: Cre... 0 0 2232727 Win32: How... 2 0 1870139 Wondows Ae... 12 0 Now i want to have a column returned, that contains a comma separated list of " Authors " (e.g. original poster and editors). e.g.: QuestionID QuestionTitle UpVotes DownVotes Authors ========== ============= ======= ========= ========== 2142075 Win32: Cre... 0 0 Ian Boyd 2232727

How to Parse a comma delimited string of numbers into a temporary orderId table?

本秂侑毒 提交于 2019-11-28 00:48:16
问题 I have a bunch of orderIds '1, 18, 1000, 77 ...' that I'm retreiving from a nvarchar(8000). I am trying to parse this string and put the id into a temporary table. Is there a simple and effective way to do this? To view a list of all the orderIds that I parsed I should be able to do this: select orderid from #temp 回答1: The fastest way via a numbers table that takes seconds to create: --First build your numbers table via cross joins select top 8000 ID=IDENTITY(int,1,1) into numbers from

SQL: Group By on Consecutive Records

最后都变了- 提交于 2019-11-27 21:28:53
A slightly tricky SQL question (we are running SQL server 2000). I have the following table, StoreCount - WeekEndDate StoreCount 2010-07-25 359 2010-07-18 359 2010-07-11 358 2010-07-04 358 2010-06-27 358 2010-06-20 358 2010-06-13 358 2010-06-06 359 2010-05-30 360 2010-05-23 360 2010-05-16 360 I want to turn this into the following output - StartDate EndDate StoreCount 2010-07-18 2010-07-25 359 2010-06-13 2010-07-11 358 2010-06-06 2010-06-06 359 2010-05-16 2010-05-30 360 As you can see, I'm wanting to group the store counts, by only as they run in sequence together. Patrick Marchand Here's a

Find last sunday

本秂侑毒 提交于 2019-11-27 21:28:21
How will you find last sunday of a month in sql 2000? SELECT DATEADD(day,DATEDIFF(day,'19000107',DATEADD(month,DATEDIFF(MONTH,0,GETDATE() /*YourValuehere*/),30))/7*7,'19000107') Edit: A correct, final, working answer from my colleague. seanmcgriff.net select dateadd(day,1-datepart(dw, getdate()), getdate()) An alternative approach, borrowed from data warehousing practice. Create a date-dimension table and pre-load it for 10 years, or so. TABLE dimDate (DateKey, FullDate, Day, Month, Year, DayOfWeek, DayInEpoch, MonthName, LastDayInMonthIndicator, many more..) The easiest way to fill-in the

What Causes “Internal connection fatal errors”

二次信任 提交于 2019-11-27 21:20:20
I've got a number of ASP.Net websites (.Net v3.5) running on a server with a SQL 2000 database backend. For several months, I've been receiving seemingly random InvalidOperationExceptions with the message "Internal connection fatal error". Sometimes there's a few days in between, while other times there are multiple errors per day. The exception is not limited to one site in particular, though they share business and data access assemblies. The error seems to always be thrown from SqlClient.TdsParser.Run(). It sometimes is thrown from old-school direct SqlCommand.Execute() calls, while other