sql-server-2005

Parsing Dynamic XML to SQL Server tables with Parent and child relation

烂漫一生 提交于 2020-06-27 05:51:42
问题 I have a XML in Source Table. I need to parse this XML to 3 different tables which has Parent Child relationship. I can do this in C# but currently for this i need to implement it at SQL server side. The sample xml looks like: <ROWSET> <ROW> <HEADER_ID>5001507</HEADER_ID> <ORDER_NUMBER>42678548</ORDER_NUMBER> <CUST_PO_NUMBER>LSWQWE1</CUST_PO_NUMBER> <CUSTOMER_NUMBER>38087</CUSTOMER_NUMBER> <CUSTOMER_NAME>UNIVERSE SELLER</CUSTOMER_NAME> <LINE> <LINE_ROW> <HEADER_ID>5001507</HEADER_ID> <LINE_ID

FluentNHibernate set default column value for a bool

跟風遠走 提交于 2020-06-25 04:09:58
问题 How to set with FluentNHibernate the default value of 1 or 0 for a BIT column of the table generated from my entity for the field of type bool. I think it doesn't matter but in any case the database is sqlserver2005. 回答1: Have you tried something like this this.Map(x => x.SomeBitColumn) .Access.Property() .Default("1"); 回答2: You probably want to look at using NHibernate Validator for this, here is an ayende example for something close to what you are looking for. They give greater control

How to solve 'invalid object name' in SQL Server?

霸气de小男生 提交于 2020-06-12 04:57:17
问题 This is the error message returned: Msg 208, Level 16, State 1, Line 1 Invalid object name 'ENG_PREP'. It happens after I try the following query: insert into ENG_PREP VALUES('572012-01-1,572012-01-2,572012-01-3,572013-01-1,572013-01-2', '', '500', '', 'A320 P.001-A', 'Removal of the LH Wing Safety Rope', '', '', '', '0', '', 'AF', '12-00-00-081-001', '', '', '', '', '', '', '' ) 回答1: It means that it doesn't know what ENG_PREP is. You need to use a 'use xxx' (where xxx is the database name

Delete duplicated rows and Update references

最后都变了- 提交于 2020-05-25 17:07:30
问题 How do I Delete duplicated rows in one Table and update References in another table to the remaining row? The duplication only occurs in the name. The Id Columns are Identity columns. Example: Assume we have two tables Doubles and Data . Doubles table ( Id int, Name varchar(50) ) Data Table ( Id int, DoublesId int ) Now I Have Two entries in the Doubls table: Id Name 1 Foo 2 Foo And two entries in the Data Table: ID DoublesId 1 1 2 2 At the end there should be only one entry in the Doubles

Delete duplicated rows and Update references

与世无争的帅哥 提交于 2020-05-25 17:07:18
问题 How do I Delete duplicated rows in one Table and update References in another table to the remaining row? The duplication only occurs in the name. The Id Columns are Identity columns. Example: Assume we have two tables Doubles and Data . Doubles table ( Id int, Name varchar(50) ) Data Table ( Id int, DoublesId int ) Now I Have Two entries in the Doubls table: Id Name 1 Foo 2 Foo And two entries in the Data Table: ID DoublesId 1 1 2 2 At the end there should be only one entry in the Doubles

SQL Query to get records of parent table that have a list of child records

萝らか妹 提交于 2020-05-15 02:32:07
问题 I have two tables in an MS SQL Server 2005 database, parent and child, where the parent may be related to many child records. [Child.parent_id] is related to [parent.id]. The child table also has column [foo] I need to bring back all records in the parent table where [child.foo] matches on each of one to many parameters. For example I would like all parent records that have a [child.foo] value of 'fizz' and a [child.foo] value of 'buzz.' I have tried the below query, but it is returning

In SQL Server 2005, what is the difference between len() and datalength()?

送分小仙女□ 提交于 2020-04-13 07:31:37
问题 What is the difference between len() and datalength() in SQL Server 2005? 回答1: DATALEN will return the number of bytes that are used to store the value: http://msdn.microsoft.com/en-us/library/ms173486(SQL.90).aspx LEN will return the number of characters in a string. Since a string can use single or double-byte characters, this differs from DATALENGTH in that you will always get 1, no matter how long a single character is: http://msdn.microsoft.com/en-us/library/ms190329.aspx 回答2: DATALENGTH

Passing parameters to IN clause in SQL Server [duplicate]

自作多情 提交于 2020-04-13 06:14:37
问题 This question already has answers here : Closed 9 years ago . Possible Duplicates: Parameterizing a SQL IN clause? SQL Server - In clause with a declared variable Hi, I am facing problem passing parameters to 'IN' clause. I am using the below query. Query: SELECT Topics.Topic_Id FROM Topics Where Topic_Description IN (''+ @Topics +'') This query works when the parameter has single value. My parameter can have comma separated multiple values like : 'one','two','three','four'. But the query

What is the difference between a primary key and a surrogate key?

邮差的信 提交于 2020-04-07 14:26:39
问题 I googled a lot, but I did not find the exact straight forward answer with an example. Any example for this would be more helpful. 回答1: The primary key is a unique key in your table that you choose that best uniquely identifies a record in the table. All tables should have a primary key, because if you ever need to update or delete a record you need to know how to uniquely identify it. A surrogate key is an artificially generated key. They're useful when your records essentially have no

What happens if altering a stored procedure while it is running?

只谈情不闲聊 提交于 2020-04-05 08:45:12
问题 I have a minor, one line change (fixing a typo in a string), to a stored procedure that I would like to deploy to our production SQL Server 2005 server as soon as possible. The worry I have is what happens if at the exact time run the alter statement to update my stored procedure, it happens that something calls that stored procedure at the same time? Does it run with the previous copy of the stored procedure, or can it result to some corruption or errors? Considering the ACID nature of SQL