sql-server-2000

How to get use text columns in a trigger

拈花ヽ惹草 提交于 2019-11-29 17:24:50
I am trying to use an update trigger in SQL Server 2000 so that when an update occurs, I insert a row into a history table, so I retain all history on a table: CREATE Trigger trUpdate_MyTable ON MyTable FOR UPDATE AS INSERT INTO [MyTableHistory] ( [AuditType] ,[MyTable_ID] ,[Inserted] ,[LastUpdated] ,[LastUpdatedBy] ,[Vendor_ID] ,[FromLocation] ,[FromUnit] ,[FromAddress] ,[FromCity] ,[FromProvince] ,[FromContactNumber] ,[Comment]) SELECT [AuditType] = 'U', D.* FROM deleted D JOIN inserted I ON I.[ID] = D.[ID] GO Of course, I get an error Cannot use text, ntext, or image columns in the

Return the id of the just added row

自古美人都是妖i 提交于 2019-11-29 15:53:43
In a similar vein to my previous question I again ask the SO guys for your collective wisdom and help. In a stored procedure and after passing some checks I need to insert a new row and return the newly created id for it. The check if a row exists works so it is the bit after that which I am undecided upon. The table has two important columns: The LocationID and the CaseID. The CaseID is autoincrementing, so when you add insert a new locationid it will automatically rachet up. I currently have this: -- previous checks for existance of CaseID IF @CaseID IS NULL BEGIN INSERT INTO Cases

Stored Procedure failing on a specific user

你离开我真会死。 提交于 2019-11-29 15:48:54
I have a Stored Procedure that is constantly failing with the error message "Timeout expired," on a specific user. All other users are able to invoke the sp just fine, and even I am able to invoke the sp normally using the Query Analyzer--it finishes in just 10 seconds. However with the user in question, the logs show that the ASP always hangs for about 5 minutes and then aborts with a timeout. I invoke from the ASP page like so " EXEC SP_TV_GET_CLOSED_BANKS_BY_USERS '006111' " Anybody know how to diagnose the problem? I have already tried looking at deadlocks in the DB, but didn't find any.

Weird SQL Server view definition

别来无恙 提交于 2019-11-29 15:16:24
I've "inherited" a well over 10-year old app, and it does show its age at times. I've stumbled across a really weird view definition today - I just can't seem to make sense of it! Can you help me? This was originally on SQL Server 7.0 and has since been migrated to SQL Server 2005 - but obviously it's never been refactored / redone.... This is the view definition - based on a bunch of tables and another view: CREATE VIEW dbo.MyOddView AS SELECT t1.MVOID, t1.SomeOtherColumn, t2.Number , t3.OID, t3.FKOID, t4.AcctNo, t5.ShortDesc, t5.ZipCode, t5.City, t6.BankAcctNo FROM dbo.viewFirst vf INNER

How can I obtain an Active Directory Group name from a SQL Server stored SID?

独自空忆成欢 提交于 2019-11-29 14:25:24
This is a follow-up of a question I asked earlier this morning ( posted here .) Following the instructions provided, I've managed to query my SQL Server 2000 database for a SID associated with an AD Group. The SID, however, looks like this: 0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF01234567 What can I do to obtain the name of the AD Group referenced by the SID? I've tried googling PowerShell scripts, however, most of their examples of SIDs look like this: S-1-5-21-1454471165-1004335555-1606985555-5555 Obviously, that doesn't look like the value I'm getting back from the SQL Server. How

how to get the next autoincrement value in sql

风流意气都作罢 提交于 2019-11-29 09:36:13
I am creating a winform application in c#.and using sql database. I have one table, employee_master , which has columns like Id, name, address and phone no . Id is auto increment and all other datatypes are varchar . I am using this code to get the next auto increment value: string s = "select max(id) as Id from Employee_Master"; SqlCommand cmd = new SqlCommand(s, obj.con); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); int i = Convert.ToInt16(dr["Id"].ToString()); txtId.Text = (i + 1).ToString(); I am displaying on a textBox. But when last row from table is deleted, still I get that value

Does size of a VARCHAR column matter when used in queries [duplicate]

旧巷老猫 提交于 2019-11-29 07:19:23
Possible Duplicate: is there an advantage to varchar(500) over varchar(8000)? I understand that a VARCHAR(200) column containing 10 characters takes same amount of space as a VARCHAR(20) column containing same data. I want to know if changing a dozen VARCHAR(200) columns of a specific table to VARCHAR(20) would make the queries run faster, especially when: These columns will never contain more than 20 characters These columns are often used in ORDER BY clause These columns are often used in WHERE clause Some of these columns are indexed so that they can be used in WHERE clause PS: I am using

Does size of a VARCHAR column matter when used in queries [duplicate]

安稳与你 提交于 2019-11-29 07:17:36
Possible Duplicate: is there an advantage to varchar(500) over varchar(8000)? I understand that a VARCHAR(200) column containing 10 characters takes same amount of space as a VARCHAR(20) column containing same data. I want to know if changing a dozen VARCHAR(200) columns of a specific table to VARCHAR(20) would make the queries run faster, especially when: These columns will never contain more than 20 characters These columns are often used in ORDER BY clause These columns are often used in WHERE clause Some of these columns are indexed so that they can be used in WHERE clause PS: I am using

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

自作多情 提交于 2019-11-29 07:16:42
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 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 syscolumns s1 ,syscolumns s2 ,syscolumns s3 GO --add PK alter table numbers add constraint PK_numbers primary key

Multiple Versions of SQL Server using Entity Framework in a single ASP.NET application

泪湿孤枕 提交于 2019-11-29 06:13:36
I am using the Entity Framework in a web application that utilizes SQL server 2000, 2005, and 2008. When I create a new EDMX file using anything other than 2008 (version of the first edmx created) I receive error 0172: All SSDL artifacts must target the same provider. The Provider 'MyDatabase' is different from ' MyDatabase ' that was encountered earlier. It seems that somewhere in the code the connection is wired to a 2008 datastore and when it checks the SSDL file and sees a different ProviderManifestToken value it throws this error. I am a little more than frustrated. It is hard to imagine