sql-server-2000

How to skip date where holiday code = 1

Using SQL Server 2000 Table1 Date Holiday 23-02-2009 0 24-02-2009 1 25-02-2009 0 Table2 ID Date 01 23-02-2009 01 24-02-2009 02 25-02-2009 …, Here I want to skip the date where Holiday =1 Expected Output 01 23-02-2009 02 25-02-2009 How to make a query for this condition? ...

Searching for data from one table in another table in t-sql (sql server2000) ?

Hey. I have table A. This table does not have any PK, it just stores lots of rows, which can only be identified by combination of its column values. There is procedure that takes data from table A, and from other tables, does proper matching/processing and feeds table B. Now, how do I check if data from table A is correctly inserted into...

Value should be 0 between the two dates?

Using SQL Server 2000 I want to compare the table2.date between table1.from, table1.todate, if exist then value should be 0 (zero) Table1 ID FromDate ToDate 001 20090801 20090815 002 20090817 20090820 …, Table2 Id Date Value 001 20090730 100 001 20090731 200 001 20090801 300 001 20090802 400 … 001 20090815 0 001 20090816 250 … ...

How to save a single result set to a temp table from a SQL stored procedure returning multiple sets?

I need to store the result set of a stored procedure in a temporary table (using SQL Server 2000). From what I've read, this (poorly constructed example) should work: create table #tempTable (TempId int primary key, Column1 varchar(100), Column2 varchar(100), DateCreated datetime) insert into #tempTable (TempId, Column1, Column2, Dat...

SQL server table population source

Hi, I have an Audit database(created by someone else). Something is polulating it, with table sizes data (which makes sense as it is Audit database). The SQL server has too many jobs. I want to know what is populating the audit tables. Is there anything like sys.comments etc? which can tell me what is populating tables or do I have ...

How can I use Group By (instead of self-joins) to get correct data (specific example included)

Looking at the related questions, I don't think this specific question has been asked, so here goes. I had a situation where I joined on a table three times to get different data based on dates. This took too long, so in an effort to optimize, I rewrote it using a group by as defined here: http://weblogs.sqlteam.com/jeffs/jeffs/archive...

INSERT conflicted with foreign key - SQL Server bug?

UPDATE: the issue does not happen when run against SQL Server 2008. So this is something strange (or wrong) with SQL Server 2000. I try to do a simple insert on SQL Server 2000: INSERT INTO UserAddresses (UserId, AddressId) SELECT UserId, Id FROM Addresses and I get this: INSERT statement conflicted with COLUMN FOREIGN KEY ...

sp_spaceused alternative in SQL 2000

Hi, Like we have alternative for sp_helpdb sp = sysdatabases table, Do we have an alternative table for sp_spaceused sp in SQL server 2000? Regards Manjot ...

SQLServer: How to pair up ordered data for sequences of arbitrary (and unequal length)?

Here's my scenario: I have two tables A, B which (for the sake of this question are identical): Table X (PK) ID 1 2 Table A: ID FKID Value Sort 1 1 a 1 2 1 aa 2 3 1 aaa 3 4 2 aaaa 1 5 2 aaaaa 2 Table B: ID FKID Value Sort 1 1 b 1 2 1 bb 2 3 2 bbb 1 4 2 bbbb 2 5 2 bbbbb ...

SQL Server 2000: search through out database

Some how some records in my table are getting updated with value of xyz in a certain column. Out of hundred of stored procedures, functions, triggers, how can I determine which code is doing this action. Is there a way to search through the database some how through each and every script of the code? Please help. ...

Same as "Trigger to update data on another SQL Server" but in SQL Server 2000

I have the same question to ask, but I'm using both SQL 2000 Server. When the table1 in SQL Server 2000 gets updated/inserted/deleted, I have to update another table in SQL Server 2000. How is it possible to achieve that ? Thanks in advance ...

Calling a SQL Server 2000 Inline Table-Valued Function from Excel 2003 / MS Query

Hi, A large part of our user base accesses corporate data by building ODBC queries inside Excel 2003 using Microsoft Query. For the more complex stuff they often get me involved. There have been a number of occasions whereby I've decided that the most logical way to extract certain data would be to use an Inline Table-Valued Function ...

Logic in stored procedure

I have need of some logic in a stored procedure. All the stored procedure does it perform a couple of logic rules and then returns a true or false depending on the result. The pseudo SQL code: CREATE TABLE #PV ([Date] DATETIME, Dis FLOAT, Del Float, Sold Float) INSERT #PV exec GetPVSummaryReport @ID, @PID, @From, @To SELECT AVG(Dis) / ...

Would this be an appropriate situations for a cursor?

I have the following script: SELECT left(SHI.FSOKEY, 6) AS [SoNo] , substring(SHI.FSOKEY, 7, 3) AS [So Item] , right(SHI.FSOKEY, 3) AS [So Rels] , QAL.FCLOT AS [LotSerial] FROM shmast SHM INNER JOIN shitem SHI ON SHM.FSHIPNO = SHI.FSHIPNO INNER JOIN qalotc QAL ON SHM.FSHIPNO = Left(QAL.FCUSEINDOC, 6) ...

Any issues with join hints in a SQL Server 2000 view?

I have some ad-hoc reporting users hitting some SQL Server views. Occasionally the read locks taken by these users for particularly lengthy queries causes trouble elsewhere in the system. I am considering adding some strategic with(nolock) hints to the views but wanted to know if there are any gotchas associated with hints in views. P...

SQL Order By and "Not-So-Much Group"

Hello, Lets say I have a table: -------------------------------------- | ID | DATE | GROUP | RESULT | -------------------------------------- | 1 | 01/06 | Group1 | 12345 | | 2 | 01/05 | Group2 | 54321 | | 3 | 01/04 | Group1 | 11111 | -------------------------------------- I want to order the result by t...

How to join a one-to-many relationship to ensure that only 1 row from the left comes back?

Sorry about a vague title, but here's what i am trying to do. I have the following two tables TABLE_PERSON | TABLE_PHONE | col_Name | col_Name col_phoneID col_phoneNbr -------- | -------- ----------- ------------ Clark Kent | Clark Kent 1 111-111-1111 Bruce Wayne | Clark Kent ...

How do I view previous queries in SQL Server 2000 database

How do I view previous queries in SQL Server 2000 database ...

Variables and stored procedures

As a follow-up to my previous question I would like to know if there is a simple way of doing the following (which doesn't compile): CREATE TABLE #PV ([ID] INT, [Date] DATETIME, Dis FLOAT, Del Float, Sold Float) INSERT #PV @ID, exec GetPVSummaryReport @ID, @PID, @From, @To The reason is I need to join #PV onto another table by [ID], b...

Strategies to issue unique records via db?

Hi, We have more than 1 instances of a certain exe running from different locations. An exe is supposed to fetch a set of records and do some work based on them. The set of records fetched from exe A should not be fetched by exe B and vice versa. Exes A & B are the same exes; they are running from different locations. The number of inst...