sql-server-2000

T-SQL Between Dates Confusion

血红的双手。 提交于 2019-11-26 18:29:16
问题 I am working with T-SQL in SQL Server 2000 and I have a table TRANSACTIONS which has a date column TRANDATE defined as DateTime, among many other columns which are irrelevant for this question.. The table is populated with transactions spanning many years. I ran into code, test, that has me confused. There is a simple SELECT , like this: SELECT TRANDATE, RECEIPTNUMBER FROM TRANSACTIONS WHERE TRANDATE BETWEEN '12/01/2010' and '12/31/2010' ORDER BY TRANDATE and its not returning two rows of

How to execute SSIS package when a file is arrived at folder

瘦欲@ 提交于 2019-11-26 16:45:14
问题 The requirement is to execute SSIS package, when a file is arrived at a folder,i do not want to start the package manually . It is not sure about the file arrival timing ,also the files can arrive multiple times .When ever the files arrived this has to load into a table.I think, some solution like file watcher task ,still expect to start the package 回答1: The way I have done this in the past is with an infinite loop package called from SQL Server Agent, for example; This is my infinite loop

Pivot using SQL Server 2000

混江龙づ霸主 提交于 2019-11-26 16:34:57
I put together a sample scenario of my issue and I hope its enough for someone to point me in the right direction. I have two tables Products Product Meta I need a result set of the following Rich Andrews We've successfully used the following approach in the past... SELECT [p].ProductID, [p].Name, MAX(CASE [m].MetaKey WHEN 'A' THEN [m].MetaValue END) AS A, MAX(CASE [m].MetaKey WHEN 'B' THEN [m].MetaValue END) AS B, MAX(CASE [m].MetaKey WHEN 'C' THEN [m].MetaValue END) AS C FROM Products [p] INNER JOIN ProductMeta [m] ON [p].ProductId = [m].ProductId GROUP BY [p].ProductID, [p].Name It can also

How to create and populate a table in a single step as part of a CSV import operation?

ⅰ亾dé卋堺 提交于 2019-11-26 16:15:57
问题 I am looking for a quick-and-dirty way to import CSV files into SQL Server without having to create the table beforehand and define its columns . Each imported CSV would be imported into its own table. We are not concerned about data-type inferencing. The CSV vary in structure and layout, and all of them have many many columns, yet we are only concerned with a few of them: street addresses and zipcodes. We just want to get the CSV data into the SQL database quickly and extract the relevant

Find index of last occurrence of a sub-string using T-SQL

狂风中的少年 提交于 2019-11-26 16:06:53
Is there a straightforward way of finding the index of the last occurrence of a string using SQL? I am using SQL Server 2000 right now. I basically need the functionality that the .NET System.String.LastIndexOf method provides. A little googling revealed this - Function To Retrieve Last Index - but that does not work if you pass in a "text" column expression. Other solutions found elsewhere work only so long as the text you are searching for is 1 character long. I will probably have to cook a function up. If I do so, I will post it here so you folks can look at it and maybe make use of. gbn

Calendar Table - Week number of month

笑着哭i 提交于 2019-11-26 15:33:54
I have a calendar table with data from year 2000 to 2012 (2012 wasn't intentional!). I just realize that I don't have the week number of month (e.g In January 1,2,3,4 February 1,2,3,4) How do I go about calculating the week numbers in a month to fill this table? Here is the table schema CREATE TABLE [TCalendar] ( [TimeKey] [int] NOT NULL , [FullDateAlternateKey] [datetime] NOT NULL , [HolidayKey] [tinyint] NULL , [IsWeekDay] [tinyint] NULL , [DayNumberOfWeek] [tinyint] NULL , [EnglishDayNameOfWeek] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [SpanishDayNameOfWeek] [nvarchar]

How to create the linked server for SQL Server 2008 where we have the database from 2000 and 2005

梦想的初衷 提交于 2019-11-26 15:23:24
Currently I am working on SQL Server 2000,2005 & 2008, my requirement is like, the database available in SQL Server 2000 & 2005 will be available in 2008 using a linked server. Let's say I have a database in SQL Server 2000 called LIVE_2000 and in SQL Server 2005 it's called LIVE_2005 , can someone please help me to create the linked server for LIVE_2000 and LIVE_2005 into SQL Server 2008? 1st thing is this even possible? Thanks in advance...` There are a few different ways that you can create a linked server in SQL Server you can use the GUI in SQL Server Management Studio or via a script.

Perform regex (replace) in an SQL query

为君一笑 提交于 2019-11-26 13:59:00
问题 What is the best way to replace all '&lt' with < in a given database column? Basically perform s/&lt[^;]/</gi Notes: must work in MS SQL Server 2000 Must be repeatable (and not end up with <;;;;;;;;; ) 回答1: Some hacking required but we can do this with LIKE , PATINDEX , LEFT AND RIGHT and good old string concatenation. create table test ( id int identity(1, 1) not null, val varchar(25) not null ) insert into test values ('< <- ok, &lt <- nok') while 1 = 1 begin update test set val = left(val,

How can I generate a temporary table filled with dates in SQL Server 2000?

巧了我就是萌 提交于 2019-11-26 12:43:41
问题 I need to make a temporary table that holds of range of dates, as well as a couple of columns that hold placeholder values (0) for future use. The dates I need are the first day of each month between $startDate and $endDate where these variables can be several years apart. My original sql statement looked like this: select dbo.FirstOfMonth(InsertDate) as Month, 0 as Trials, 0 as Sales into #dates from customer group by dbo.FirstOfMonth(InsertDate) \"FirstOfMonth\" is a user-defined function I

Regular Expressions in SQL Server servers?

元气小坏坏 提交于 2019-11-26 12:16:22
问题 Is it possible to make efficient queries that use the complete regular expression feature set. If not Microsoft really should consider that feature. 回答1: For SQL Server 2000 (and any other 32 bit edition of SQL Server), there is xp_pcre, which introduces Perl compatible regular expressions as a set of extended stored procedures. I've used it, it works. The more recent versions give you direct access to the .NET integrated regular expressions (this link seems to be dead, here is another one: