sql-server-2005

Possible to get PrimaryKey IDs back after a SQL BulkCopy?

╄→尐↘猪︶ㄣ 提交于 2019-12-17 18:34:57
问题 I am using C# and using SqlBulkCopy. I have a problem though. I need to do a mass insert into one table then another mass insert into another table. These 2 have a PK/FK relationship. Table A Field1 -PK auto incrementing (easy to do SqlBulkCopy as straight forward) Table B Field1 -PK/FK - This field makes the relationship and is also the PK of this table. It is not auto incrementing and needs to have the same id as to the row in Table A. So these tables have a one to one relationship but I am

Reasons not to have a clustered index in SQL Server 2005

落花浮王杯 提交于 2019-12-17 18:29:46
问题 I've inherited some database creation scripts for a SQL SERVER 2005 database. One thing I've noticed is that all primary keys are created as NON CLUSTERED indexes as opposed to clustered. I know that you can only have one clustered index per table and that you may want to have it on a non primary key column for query performance of searches etc. However there are no other CLUSTERED indexes on the tables in questions. So my question is are there any technical reasons not to have clustered

Using Encrypt=yes in a Sql Server connection string -> “provider: SSL Provider, error: 0 - The certificate's CN name does not match the passed value.”

一曲冷凌霜 提交于 2019-12-17 18:24:41
问题 I'm using Encrypt=yes in a SQL Server connection string, as I need the TCPIP traffic to be encrypted, but on opening the connection I get an error: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - The certificate's CN name does not match the passed value.) Any suggestions how to fix this? I assume I need some sort of certificate relationship between my servers, but have no idea where to

Why is IS NOT NULL returning NULL values for a Varchar(max) in SQL Server?

左心房为你撑大大i 提交于 2019-12-17 18:23:14
问题 It looks like some NULL values are appearing in the list. Some NULL values are being filtered out by the query. I have checked. If I add AND AdditionalFields = '' , both these results are still returned AdditionalFields is a varchar(max) The database is SQL Server 10 with Compatibility Level = Sql Server 2005 (90) I am using Management Studio 2008 I appear to have empty strings whose length is NULL, or NULL values that are equal to an empty string. Is this a new datatype?! EDIT: New datatype

Cannot initialize the data source object of OLE DB provider “MSDASQL” for linked server “(null)”

≡放荡痞女 提交于 2019-12-17 18:13:22
问题 Having an interesting issue. I'm reading from an excel file on a server via an OpenRowset in Sql2005. I've run the query a number of times without any problems. I've just gone out for a quick meeting and suddenly I get the error "Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)"" I've made sure the files are not in use on the server and even deleted them and recopied them over onto the server and still I'm getting the same error. UPDATE: This

Not connecting to SQL Server over VPN

别来无恙 提交于 2019-12-17 17:59:38
问题 I have connected for the first time to an existing network over VPN. I can ping the IP address which is used by the SQL Server from the VPN client, but SSMS does not connect to the SQL Server. I am using the right login id and password. Why could this happen ? Any ideas ? Thanks 回答1: On a default instance, SQL Server listens on TCP/1433 by default. This can be changed. On a named instance, unless configured differently, SQL Server listens on a dynamic TCP port. What that means is should SQL

Asynchronous Triggers in SQL Server 2005/2008

别说谁变了你拦得住时间么 提交于 2019-12-17 17:54:24
问题 I have triggers that manipulate and insert a lot of data into a Change tracking table for audit purposes on every insert, update and delete. This trigger does its job very well, by using it we are able to log the desired oldvalues/newvalues as per the business requirements for every transaction. However in some cases where the source table has a lot columns, it can take up to 30 seconds for the transaction to complete which is unacceptable. Is there a way to make the trigger run

How do I avoid character encoding when using “FOR XML PATH”?

不打扰是莪最后的温柔 提交于 2019-12-17 17:45:12
问题 I'm looking to create a comma-separated list of values from a SQL Server 2005 table, just like in JanetOhara's question. I'm using a query similar to the one presented in techdo's answer to the question. Everything is working, except the list of values is getting XML encoded. What should be: Sports & Recreation,x >= y Is instead returning as: Sports & Recreation,x <= y Is there a way to disable the XML character encoding when using "FOR XML" in SQL Server? 回答1: You just need to use the right

SQL Server 2005 drop column with constraints

廉价感情. 提交于 2019-12-17 17:36:40
问题 I have a column with a "DEFAULT" constraint. I'd like to create a script that drops that column. The problem is that it returns this error: Msg 5074, Level 16, State 1, Line 1 The object 'DF__PeriodSce__IsClo__4BCC3ABA' is dependent on column 'IsClosed'. Msg 4922, Level 16, State 9, Line 1 ALTER TABLE DROP COLUMN IsClosed failed because one or more objects access this column. I couldn't find an easy way to drop a column and all its associated constraints (only found big scripts that look into

How to rollback or commit a transaction in SQL Server

蹲街弑〆低调 提交于 2019-12-17 17:29:08
问题 In my stored procedure, I have three insert statements. On duplicate key value insertion first two queries generate the error Violation of PRIMARY KEY constraint and third query runs as usual. Now I want that if any query generates any exception, everything should get rolled back. If there isn't any exception generate by any query, it should get committed. declare @QuantitySelected as char set @QuantitySelected = 2 declare @sqlHeader as varchar(1000) declare @sqlTotals as varchar(1000)