sql-server-2005

Expected database model is inconsistent in real-time

こ雲淡風輕ζ 提交于 2020-01-06 14:20:42
问题 In this question, I was facing an issue where I was writing an update for a deployed application to bring the database up to date with the newer version we are deploying. Basic outline as follows: Began with currently deployed version of application Added new functionality that used existing database Added new database tables and relationships Added new functionality that depended on the new databse structure Testing complete, ready for deployment The issue here is that the currently deployed

Why do I get empty results using generated code from DB?

浪子不回头ぞ 提交于 2020-01-06 13:08:32
问题 I'm using SQL Server 2005. I have a table scores with 6 rows and columns - name, score and id . I added the data source with VS and it generated a dataset called testDataSet . So I tried the following code which gives me zero results: testDataSet db = new testDataSet(); var result = from row in db.scores select row.name; Where is the problem? 回答1: The probem you are having is that you are querying an empty DataSet . You first have to create a connection to your testDataSet and fill the tables

SQL Server identity counterpart problem

为君一笑 提交于 2020-01-06 12:56:49
问题 I'm using SQL Server and I want to use identity constraint in it I know how to use it in following manner create table mytable ( c1 int primary key identity(1,1); ) the above code works fine but what if i want the identity column to have values as EMP001, EMP002,... instead of 1,2.... Thanks in advance, Guru 回答1: Identity columns can only be integers. If you want it to "look like" EMP001, EMP002, etc then that's simply a display issue and not a storage one (that is, you don't need to store

SQL Server identity counterpart problem

泄露秘密 提交于 2020-01-06 12:56:34
问题 I'm using SQL Server and I want to use identity constraint in it I know how to use it in following manner create table mytable ( c1 int primary key identity(1,1); ) the above code works fine but what if i want the identity column to have values as EMP001, EMP002,... instead of 1,2.... Thanks in advance, Guru 回答1: Identity columns can only be integers. If you want it to "look like" EMP001, EMP002, etc then that's simply a display issue and not a storage one (that is, you don't need to store

How to average/sum data in a day in SQL Server 2005

无人久伴 提交于 2020-01-06 12:43:29
问题 I'm trying to average data in SQL Server 2005 in a day. Here is what my database look like this if I use simple query as SELECT timestamp, FEED FROM ROASTER_FEED ORDER timestamp Data: timestamp Feed 02/07/2011 12:00:01 1246 02/07/2011 12:00:01 1234 02/07/2011 12:00:01 1387 02/07/2011 12:00:02 1425 02/07/2011 12:00:03 1263 ... 02/07/2011 11:00:01 1153 02/07/2011 11:00:01 1348 02/07/2011 11:00:01 1387 02/07/2011 11:00:02 1425 02/07/2011 11:00:03 1223 .... 03/07/2011 12:00:01 1226 03/07/2011 12

Adding Row Numbers To a SELECT Query Result in SQL Server Without use Row_Number() function

泪湿孤枕 提交于 2020-01-06 08:46:17
问题 i need Add Row Numbers To a SELECT Query without using Row_Number() function. and without using user defined functions or stored procedures. Select (obtain the row number) as [Row], field1, field2, fieldn from aTable UPDATE i am using SAP B1 DIAPI, to make a query , this system does not allow the use of rownumber() function in the select statement. Bye. 回答1: I'm not sure if this will work for your particular situation or not, but can you execute this query with a stored procedure? If so, you

Pass in Dynamic number of parameters to a stored procedure

青春壹個敷衍的年華 提交于 2020-01-06 08:29:09
问题 I have a function in my .NET application, that needs to do a search of an unknown number of parameters. for example: select * from tbl where x=1 or x=2 or x=3 or x=4 is it possible to do in .NEt and SQL? how do i go about creating dynamic parameters in .NET (I was thinking doing it with a loop) but then how do i declare them in my stored procedure? does sql have arrays? please help. thank you! 回答1: You can pass in a comma seperated list, use a table function to split that out into a table and

Update Field based on another table's values

。_饼干妹妹 提交于 2020-01-06 08:25:41
问题 Is there a more elegant way to write the following Microsoft SQL Server 2008 command? UPDATE TableB SET TableBField2=0 WHERE TableBID IN( SELECT TableBID FROM TableB JOIN TableA on TableB.TableAID=TableA.TableAID WHERE TableBField2 < 0 AND TableAField1 = 0 ) In plain speak, what I'm doing is updating a table based on the value of a field in a joined table. I wonder if my use of IN() is considered inefficient. 回答1: This should be more efficient: UPDATE TableB b SET TableBField2=0 WHERE exists

Data Migration From Oracle To SQL Server

馋奶兔 提交于 2020-01-06 08:16:10
问题 I have an Oracle database in which there is one or more table. I also have blob data, i.e. images are stored, now I would like to move that data to Sql Server database. What is the best way to do this? I would like to test it for one table migration which contains image data in the Oracle database and move it into SQL Server table. How do I test for migrating data from one table from Oracle to SQL Server? But first thing I would like to confirm is that whether Image data moving from Oracle DB

How to find out size of the individual databases in the sql server 2005?

醉酒当歌 提交于 2020-01-06 07:59:12
问题 Please tell the query to find out size of the individual databases in the sql server 2005? 回答1: try this sp_spaceused exec sp_spaceused 回答2: EXEC sp_MSforeachtable 'EXEC sp_spaceused [?]' 来源: https://stackoverflow.com/questions/1496136/how-to-find-out-size-of-the-individual-databases-in-the-sql-server-2005