sql-server-2000

Why are parameters slower than literal values in a where clause?

此生再无相见时 提交于 2020-01-02 08:28:10
问题 Situation: c#, sql 2000 I have a table, lets call it 'mytable' with 30 million rows. The primary key is made up of fields A and B: A char(16) B smallint(2) When i do a search like this, it runs really slowly (eg it does a full tablescan) string a="a"; int b=1; string sql = "select * from table(nolock) where a=@a and b=@b"; using (SqlCommand cmd = new SqlCommand(sql, conn)) { cmd.Parameters.AddWithValue("@a", a); cmd.Parameters.AddWithValue("@b", b); using (SqlDataReader rdr = cmd

How to get columns Primary key constraints using SqlConnection.GetSchema()

陌路散爱 提交于 2020-01-02 03:20:10
问题 I have some code of ADO.NET to dynamically detect the database schema, what I need is how to get unique columns constraints and Primary key constraints using the GetSchema method on SqlConnection . This is the code that I have: conn.Open(); SqlCommand mSqlCommand = new SqlCommand("sp_pkeys", conn); mSqlCommand.CommandType = CommandType.StoredProcedure; mSqlCommand.Parameters.Add( "@table_name", SqlDbType.NVarChar).Value = tableName; SqlDataReader mReader = mSqlCommand.ExecuteReader(

Max size of varchar(max) in SQL Server 2000

杀马特。学长 韩版系。学妹 提交于 2020-01-02 00:53:10
问题 I would like to know what is the maximum size of varchar in SQL Server 2000. While I was googling somewhere it was written 8000 characters and somewhere it was written 8060 bytes. Which one is correct? 回答1: Varchar is 8000 and nvarchar is 4000. Here's the varchar msdn reference: http://msdn.microsoft.com/en-us/library/aa258242(SQL.80).aspx 回答2: A SQL Server data page has 8k: 8192 bytes. From this a portion is reserved for the page header, leaving 8060 bytes the maximum lnegth a single row can

Validate telephone number in SQL Server 2000

时光总嘲笑我的痴心妄想 提交于 2020-01-01 19:53:30
问题 Does anyone have a nifty way of validating telephone numbers using sql (SQL Server 2000). I need to select all users fro ma Db that have valid phone number Thanks Sp Valid number 08450000000 01332000000 07444000000 +441332000000 Standard UK numbers 回答1: If you have a regular expression to match the number, you can install a regex extended stored procedure on your SQL Server. I installed this extended stored procedure at work and we use it quite a bit. There are several procedures (each with

SQL Table and column Parser for stored procedures

这一生的挚爱 提交于 2020-01-01 05:41:29
问题 Is there an application , which can parse a given set of stored procedures (SQL Server 2000) and gets all tables and associated columns that are being used in it. The stored procedure can have tables from different databases. Output should be like TableA columnA columnC columnD TableB columnE columnF columnG I have written an small application using Database Edition GDR Any one interested can refer to http://tsqlparsergdr.codeplex.com 回答1: You can use SHOWPLAN_ALL setting and parse the output

select a value where it doesn't exist in another table

坚强是说给别人听的谎言 提交于 2020-01-01 00:56:13
问题 I have two tables Table A: ID 1 2 3 4 Table B: ID 1 2 3 I have two requests: I want to select all rows in table A that table B doesn't have, which in this case is row 4. I want to delete all rows that table B doesn't have. I am using SQL Server 2000. 回答1: You could use NOT IN : SELECT A.* FROM A WHERE ID NOT IN(SELECT ID FROM B) However, meanwhile i prefer NOT EXISTS : SELECT A.* FROM A WHERE NOT EXISTS(SELECT 1 FROM B WHERE B.ID=A.ID) There are other options as well, this article explains

java to sql server connectivity exception

谁说我不能喝 提交于 2019-12-31 06:58:06
问题 I have this error/exception- SQL Exception: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "connect timed out. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.". and my code is- try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); String connectionUrl

java to sql server connectivity exception

ⅰ亾dé卋堺 提交于 2019-12-31 06:58:02
问题 I have this error/exception- SQL Exception: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "connect timed out. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.". and my code is- try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); String connectionUrl

Have you ever had SQL Server 2008 return a different result set than SQL Server 2000?

余生颓废 提交于 2019-12-30 07:15:13
问题 I am not looking for help with the actual code of my stored procedure (yet anyway), but a client sent me a copy of his SQL Server 2000 database stating that a particular proc was returning incorrect results; I restored the database to my server (SQL Server 2008R2) and ran the proc and it produced the correct results. Keep in mind there is no front-end that could be causing the difference - in both the cases I simply execute the proc thru enterprise manager and management studio. I am

Need to convert Text field to Varchar temporarily so that I can pass to a stored procedure

风流意气都作罢 提交于 2019-12-30 06:09:21
问题 I am using a SQL 2000 database. I am working with a database in which I cannot change the types on the tables, or the stored procedures. One of the stored procedures I need to call expects a parameter of 'text'. I can get to the text field, but I am unable to figure out who to store that in a variable or any other way to pass it into the stored procedure? If I try and create a text variable, SQL won't let me - if I convert it to varchar I only get the first character from the text field. Any