sql-server-2005

FOR XML AUTO and column name with space issue in SQL Server 2005

匆匆过客 提交于 2019-12-12 05:29:39
问题 Here is my SQL select ID as [Emp ID], Name as [Employee name], Sal as [Salary] from Emp FOR XML AUTO, ELEMENTS, ROOT('customers') When I issue this SQL then unknown data is added in xml with my field name. I got the xml like <customers> <Emp> <Emp_x0020_ID>1</Emp_x0020_ID> <Employee_x0020_name>bob</Employee_x0020_name> <Salary>2020</Salary> </Emp> <Emp> <Emp_x0020_ID>2</Emp_x0020_ID> <Employee_x0020_name>keith</Employee_x0020_name> <Salary>6500</Salary> </Emp> <Emp> <Emp_x0020_ID>3</Emp_x0020

calculating sales, refund and breakages from SQL Server Tables

故事扮演 提交于 2019-12-12 05:15:59
问题 This question was migrated from Server Fault because it can be answered on Stack Overflow. Migrated 9 years ago . I have 4 tables namely Products, SalesLog, Breakages, SalesReturn. Products Table CREATE TABLE [dbo].[Products]( [ProductId] [int] IDENTITY(1,1) NOT NULL, [pName] [nvarchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [pSize] [int] NULL, [pPrice] [decimal](10, 2) NULL, [pPackQty] [int] NULL, [pGroup] [int] NULL, [pCode] [int] NULL, [OpenStock] [int] NULL, [CloseStock] [int]

How to make additional columns on pivot of sql table in SQL Server 2005?

喜夏-厌秋 提交于 2019-12-12 05:11:53
问题 After getting such a great feedback from my last question. Maybe someone can help me with this problem also. I have to rotate a given table from an SQL Server but a normal pivot just doesn't work (as far as i tried). So has anybody an idea how to rotate the table into the desired format? Just to make the problem more complicated, the list of given labels can vary and it is possible that a new label name can come into at any given time. Given Data ID | Label | Numerator | Denominator | Ratio -

Transmission Compression from .net to SQL

筅森魡賤 提交于 2019-12-12 05:03:48
问题 I have an win forms App that the users use off line, any they have to sync data using a 3g modem and a cisco VPN, unfortunately the limited band width, poor signal quality and large volume of data transferred is making the sync process unreliable. is there any way to get .net to compress the SQL commands and then having sql decompress and run before sending the results in a compressed reply to reduce the network traffic? 回答1: To create off-line synchronization i recommend to use Service

how to link the following 2 tables to get the result which is shown below in SQL Server?`

送分小仙女□ 提交于 2019-12-12 04:59:36
问题 Visit LoginID, StaffName, qno, trackno, tmstamp 1, James, 1001, 1, 01-01-2011 2, John, 1002, 2, 01-01-2011 2, John, 1003, 3, 01-01-2011 Matter content, trackno, tmstamp 001, 1, 01-01-2011 002, 1, 01-01-2011 001, 2, 01-01-2011 002, 2, 01-01-2011 003, 2, 01-01-2011 001, 3, 01-01-2011 Result StaffName, tmstamp, noOfQno, noOfContent James, 01-01-2011, 1, 2 John, 01-01-2011, 2, 4 Visit and Matter are 2 tables. The result is the result I want. How can I achieve that? 回答1: Try this: SELECT StaffName

SQL Server 2005 Index rebuild when increasing the size of a varchar field

允我心安 提交于 2019-12-12 04:59:22
问题 I have a 12 varchar(50) fields in a table of about 90 million rows that I need to increase to varchar(100) in length. Each of these fields has an index (with only the one field as a member). If I increase the length of the varchar fields, will the indexes either need to be rebuilt (or would be rebuilt automatically), or would the statistics become out of date? I don't have a reasonably sized test system test (or perhaps dont know how to see if the indexes were rebuilt or statistics need to be

Parent Child table record - Building SQL query [duplicate]

倖福魔咒の 提交于 2019-12-12 04:57:36
问题 This question already has an answer here : Closed 8 years ago . Possible Duplicate: Parent Child table record - Building SQL query Here is my table and data of these tables Table name: Code CID Code 1 abc 2 def 3 xyz Table Name : Details ID Date Value1 CID 1 1/1/2009 12 1 2 1/1/2009 25 2 3 1/1/2009 18 3 4 1/2/2009 36 1 5 1/2/2009 45 2 6 1/3/2009 19 1 Resultant Table: Date Value1 CID Code 1/1/2009 12 1 abc 1/1/2009 25 2 def 1/1/2009 18 3 xyz 1/2/2009 36 1 abc 1/2/2009 45 2 def 1/2/2009 Null 3

Delete all rows from database by using single query? [duplicate]

荒凉一梦 提交于 2019-12-12 04:47:08
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to delete all rows from all tables in a SQL Server database? I want to delete all rows from a SQL Server 2005 database. Can anyone to define a procedure to delete all rows from database by using single query? 回答1: In that case, this will work: EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' GO EXEC sp_MSForEachTable 'DELETE FROM ?' GO EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'

How can I easily flatten this Sql Server hierarchy into an inherited inclusive list?

一个人想着一个人 提交于 2019-12-12 04:44:28
问题 I have tables (for simplicity sake) as outlined below: Category -------------------- CategoryId (0 for root nodes) ParentCategoryId ProductCategory -------------------- ProductId CategoryId I'd like to be able to retrieve a distinct list of all categories and their inherited products (all the way back to category 0). Category 0 should include ALL products, and all other categories should follow down the hierarchy as infinitely deep as it goes. Example Table Contents: CategoryId,

How to add Timestamp value in SQL Server 2005 by using LINQ

笑着哭i 提交于 2019-12-12 04:42:15
问题 My database table have a Timestamp column named as inTime and i am using LINQ for insert, update data in SQL server. Now i want to add the timestamp value in my database but i don't know how to insert? spaBL.attendance obj = new spaBL.attendance(); obj.FK_employeeId = 1; obj.inTime =[what to write here??] inTime is of timestamp type. 回答1: You cannot update a timestamp. See here. And indeed, as TomTom indicated, it doesn't contain actual time information. 回答2: You do not provide values for