sql-server-2000

SQL 2000: T-SQL to get foreign key relationships for a table

和自甴很熟 提交于 2019-12-21 05:41:04
问题 Similar but NOT IDENTICAL to SQL Server 2000 - Query a Table’s Foreign Key relationships I need a T-SQL statement that will work SQL 2000 that given a table name, will return the foreign key relationships for that table e.g. Table MyFristTable has a foreign key to MySecondTable, where MyFirstTable.ColA must be in MySecondTable.ColB. I'd be delighted, if the sql statement (or stored proc) is ran for MyFirstTable and returned a result set on the lines of Column | FK_Table | FK_COLUMN ----------

SQL Server: How to ignore referential integrity until COMMIT?

旧街凉风 提交于 2019-12-21 05:36:17
问题 i have a process to move rows from one database to another. Because of some circular foreign key reference chains i cannot remove the rows from the old database, nor can i insert them into the new database. Since the entire operation happens in a transaction 1 , i want SQL Server to ignore referential integrity failures until i call COMMIT TRANSACTION . For example 2 : Table: Turboencabulators Table: Marselvanes ========================= ======================= PK TurboencabulatorID int /->

SQL Server Deadlock Fix: Force join order, or automatically retry?

时间秒杀一切 提交于 2019-12-21 04:22:26
问题 i have a stored procedure that performs a join of TableB to TableA : SELECT <--- Nested <--- TableA Loop <-- | ---TableB At the same time, in a transaction, rows are inserted into TableA , and then into TableB . This situation is occasionally causing deadlocks, as the stored procedure select grabs rows from TableB , while the insert adds rows to TableA , and then each wants the other to let go of the other table: INSERT SELECT ========= ======== Lock A Lock B Insert A Select B Want B Want A .

How to increment in a select query

你离开我真会死。 提交于 2019-12-21 04:06:28
问题 I've got a query I'm working on and I want to increment one of the fields and restart the counter when a key value is different. I know this code doesn't work. Programmatically this is what I want... declare @counter int, @id set @counter = 0 set @id = 0 select distinct id, counter = when id = @id then @counter += 1 else @id = id @counter = 1 ...with the end result looking something like this: ID Counter 3 1 3 2 3 3 3 4 6 1 6 2 6 3 7 1 And yes, I am stuck with SQL2k. Otherwise that row_number

Declaring a default constraint when creating a table

岁酱吖の 提交于 2019-12-20 09:31:07
问题 I am creating a new table in Microsoft SQL server 2000 by writing the code instead of using the GUI, I am trying to learn how to do it "the manual way". This is the code I am actually using, and it works fine: CREATE TABLE "attachments" ( "attachment_id" INT NOT NULL, "load_date" SMALLDATETIME NOT NULL, "user" VARCHAR(25) NOT NULL, "file_name" VARCHAR(50) NOT NULL, CONSTRAINT "pk_attachments" PRIMARY KEY ("attachment_id"), CONSTRAINT "fk_users" FOREIGN KEY ("user") REFERENCES "users" ("user")

Value should be 0 between the two dates?

佐手、 提交于 2019-12-20 07:38:37
问题 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 … From the above two table I want to ID, Date, value from table2 where table2.date between table1.fromdate and table1.todate then table2.value =0 Expected Output Id Date

SQL Server 2005: Importing data from SQL Server 2000

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 06:28:17
问题 In SQL Server 2000, you have the "All Tasks... - Export Data" option. Where is this option the SQL Server 2005 Management Studio? Or, is there a SQL Server 2005 way of doing this? EDIT: I am using the Express edition. EDIT: Joel's response answers my question but Mike's answer gives a great alternative to those of us using the Express edition (vote him up!!). 回答1: If you're using the express edition of management studio the Import and Export features aren't available. 回答2: You could use the

Cannot connect to SQL SERVER 2000

烂漫一生 提交于 2019-12-20 06:25:30
问题 I am using php 5.3.1 to connect to my SQL SERVER 2000 on remote machine. I use Windows XP. On using simple program like this: $conn = mssql_connect("VBNET","sa","mypass") or die ( 'Can not connect to server' ); I get following error: Warning: mssql_connect() [function.mssql-connect]: message: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection. (severity 14) in C:\wamp\www\Mssql\test.php on line 8 Warning: mssql_connect() [function.mssql-connect]: Unable to

Multiple sub queries

北战南征 提交于 2019-12-20 06:20:34
问题 Is it possible to get the result as below from the same table date-wise records: Enrolled Enrolled as Email Enrolled as Text Deals Redeemed <First Date> 7 5 2 6 <Next Date> 9 3 6 14 Table structure look something like this: Customer_id, field1, field2, responsecode, created_date My current query is something like this: Select Created, Enroll = (Select COUNT(*) from tblCustomer where field1 <> '' group by created), Email = (Select COUNT(field1) from tblCustomer where field1 = 'E-mail' and

ROW_NUMBER Alternative for SQL Server 2000

。_饼干妹妹 提交于 2019-12-20 05:31:47
问题 RIGHT now I'm using ROW_NUMBER() in my procedure in SQL Server 2008 as follows: WITH cars as(SELECT carid,mileage,retailprice,imageurl,model,year, Zips.Distance AS Miles, Manufacturers.mfgName as Make, dealers.companyname as companyname, CASE @sortby WHEN 'D' THEN ROW_NUMBER() OVER (ORDER BY Manufacturers.mfgName) WHEN 'P' THEN ROW_NUMBER() OVER (ORDER BY retailprice) WHEN 'M' THEN ROW_NUMBER() OVER (ORDER BY mileage) END as 'rownum' FROM usedcars INNER JOIN #TempZips Zips ON Zips.ZipCode