sql-server-2000

Table Valued Function where did my query plan go?

随声附和 提交于 2019-12-18 04:25:29
问题 I've just wrapped a complex SQL Statement in a Table-valued function on SQLServer 2000. When looking at the Query Plan for a SELECT * FROM dbo.NewFunc it just gives me a Table Scan of the table I have created. I'm guessing that this is because table is created in tempdb and I am just selecting from it. So the query is simply : SELECT * FROM table in tempdb My questions are: Is the UDF using the same plan as the complex SQL statement? How can I tune indexes for this UDF? Can I see the true

Row_Number simulation in Sql server 2000

◇◆丶佛笑我妖孽 提交于 2019-12-17 20:30:04
问题 I have a sample input table as Declare @input TABLE(Name VARCHAR(8)) INSERT INTO @input(Name) values('Aryan') INSERT INTO @input(Name) values('Aryan') INSERT INTO @input(Name) values('Joseph') INSERT INTO @input(Name) values('Vicky') INSERT INTO @input(Name) values('Jaesmin') INSERT INTO @input(Name) values('Aryan') INSERT INTO @input(Name) values('Jaesmin') INSERT INTO @input(Name) values('Vicky') INSERT INTO @input(Name) values('Padukon') INSERT INTO @input(Name) values('Aryan') INSERT INTO

How to connect to MSSQL 2000 from PHP 5.3 and up

两盒软妹~` 提交于 2019-12-17 19:02:55
问题 I have a legacy business application built on MS SQL Server 2000. I have some webbased utilities that access this database using PHP 5.2 with mssql extension. I need to reinstall the web server, and I looked forward to upgrade to PHP 5.4. Unfortunately, the mssql extension is not supported on PHP 5.3 and newer. There is the sqlsrv extension available form Microsoft, but the description says that it is only supported for accessing SQL server 2005 and up. How can I connect to my SQL Server 2000

How to connect to MSSQL 2000 from PHP 5.3 and up

会有一股神秘感。 提交于 2019-12-17 19:02:00
问题 I have a legacy business application built on MS SQL Server 2000. I have some webbased utilities that access this database using PHP 5.2 with mssql extension. I need to reinstall the web server, and I looked forward to upgrade to PHP 5.4. Unfortunately, the mssql extension is not supported on PHP 5.3 and newer. There is the sqlsrv extension available form Microsoft, but the description says that it is only supported for accessing SQL server 2005 and up. How can I connect to my SQL Server 2000

how to search Sql Server 2008 R2 stored procedures for a string?

五迷三道 提交于 2019-12-17 18:52:53
问题 I'm migrating a legacy SQLS2k to 2008R2, and it seems all data access was done through stored procs, and any custom queries use the legacy *= =* outer join syntax. There are upwards of a hundred procs so I don't want to open each one individually to see if it uses that syntax (most wouldn't), is there a way I can query the metadata for a list of procs/functions/views/triggers, then loop through searching for the *= or =* strings, printing out the name of the offending object? My background is

SQL Server Trigger loop

徘徊边缘 提交于 2019-12-17 18:47:26
问题 I would like to know if there is anyway I can add a trigger on two tables that will replicate the data to the other. For example: I have a two users tables, users_V1 and users_V2, When a user is updated with one of the V1 app, it activate a trigger updating it in users_V2 as well. If I want to add the same trigger on the V2 table in order to update the data in V1 when a user is updated in V2, will it go into an infinite loop? Is there any way to avoid that. 回答1: I don't recommend explicitly

Pass a variable into a trigger

我只是一个虾纸丫 提交于 2019-12-17 18:37:04
问题 I have a trigger which deals with some data for logging purposes like so: CREATE TRIGGER trgDataUpdated ON tblData FOR UPDATE AS BEGIN INSERT INTO tblLog ( ParentID, OldValue, NewValue, UserID ) SELECT deleted.ParentID, deleted.Value, inserted.Value, @intUserID -- how can I pass this in? FROM inserted INNER JOIN deleted ON inserted.ID = deleted.ID END How can I pass in the variable @intUserID into the above trigger, as in the following code: DECLARE @intUserID int SET @intUserID = 10 UPDATE

Pass a variable into a trigger

家住魔仙堡 提交于 2019-12-17 18:36:09
问题 I have a trigger which deals with some data for logging purposes like so: CREATE TRIGGER trgDataUpdated ON tblData FOR UPDATE AS BEGIN INSERT INTO tblLog ( ParentID, OldValue, NewValue, UserID ) SELECT deleted.ParentID, deleted.Value, inserted.Value, @intUserID -- how can I pass this in? FROM inserted INNER JOIN deleted ON inserted.ID = deleted.ID END How can I pass in the variable @intUserID into the above trigger, as in the following code: DECLARE @intUserID int SET @intUserID = 10 UPDATE

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

只谈情不闲聊 提交于 2019-12-17 18:35:50
问题 This question already has answers here : Closed 7 years ago . 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

Find last sunday

戏子无情 提交于 2019-12-17 16:07:36
问题 How will you find last sunday of a month in sql 2000? 回答1: 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. 回答2: select dateadd(day,1-datepart(dw, getdate()), getdate()) 回答3: 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,