sql-server-2005

sql update (help me )

血红的双手。 提交于 2019-12-14 03:37:00
问题 I have 3 tables: tbl_indicator grp_nbr, sect_nbr, indicat 1 100 p 2 101 s tbl_group grp_id, grp_nbr, sect_nbr, indicat 333 1 100 a 555 1 100 p 444 2 101 s 222 2 101 y Here (in tbl_group ) grp_id is Primary Key tbl_order order_id, grp_id 5000 333 5001 555 5002 555 5003 555 5004 444 5005 444 5006 222 Here (in tbl_order ) grp_id is a Foreign Key to grp_id in tbl_group . In table tbl_indiactor, for one set of grp_nbr and sect_nbr there is an indicat, for the same set of grp_nbr and sect_nbr there

Unable to get data from Sql Server 2005 (connection time out exception)

蓝咒 提交于 2019-12-14 03:32:20
问题 java.sql.SQLException: Network error IOException: Connection timed out: connect at net.sourceforge.jtds.jdbc.ConnectionJDBC2.(ConnectionJDBC2.java:410) at net.sourceforge.jtds.jdbc.ConnectionJDBC3.(ConnectionJDBC3.java:50) at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:185) at mahesh.MyFrame.connectToServer(MyFrame.java:50) at mahesh.DataCount.main(DataCount

Find column Value by dividing with sum of a column

那年仲夏 提交于 2019-12-14 03:27:12
问题 I have a table with the following columns in a Netezza Database Id field1 field2 1 0.9 sum(field1)/0.9 2 1.7 sum(field1)/1.7 3 6.9 sum(field1)/6.9 4 0.4 sum(field1)/0.4 5 0.2 sum(field1)/0.2 6 2.8 sum(field1)/2.8 7 7.0 sum(field1)/7.0 The field2 column is to be generated and will hold values as shown in the table. For this example the sum of field1 is 19.9 . Also the field1 values will change frequently. Please help with a query that will help calculate the field2 value also the values are in

SQL Selecting distinct rows from multiple columns based on max value in one column

拜拜、爱过 提交于 2019-12-14 02:54:43
问题 This is my SQL View - lets call it MyView : ECode SHCode TotalNrShare CountryCode Country 000001 +00010 100 UKI United Kingdom 000001 ABENSO 900 USA United States 000355 +00012 1000 ESP Spain 000355 000010 50 FRA France 000042 009999 10 GER Germany 000042 +00012 999 ESP Spain 000787 ABENSO 500 USA United States 000787 000150 500 ITA Italy 001010 009999 100 GER Germany I would like to return the single row with the highest number in the column TotalNrShare for each ECode. For example, I’d like

SQL Server 2008 Full Text Search – SLOW

走远了吗. 提交于 2019-12-14 02:33:46
问题 I'm using asp.net with SQL Server 2008 SP2 I have one table with Full Text Search Enabled. My Hardware is: 2GHZ Quad-Core, 4GB RAM, SAS HDD. The table has around 5 Million records , and its structure is: Pages table: ID (INT) GroupID (INT) GroupStart (bit) Col1 varchar(900) Col2 nvarchar(450) Col3 nvarchar(450) Col4 nvarchar(450) Col5 nvarchar(450) i have a fts index on the primary key ID. I'm using the following query to search the table: SELECT * FROM ( SELECT * , ROW_NUMBER() OVER( ORDER

SQL Server - Count events that happen from 15 min to 14 days from base time

核能气质少年 提交于 2019-12-14 02:28:50
问题 I am using SQL Server 2005. I am trying to count the number of repeats that would fall in between 15 minuites and 14 days when the Client and Type are the same. The Table [Interactions] looks like: eci_date user_ID Type Client 2012-05-01 10:29:59.000 user1 12 14 2012-05-01 10:35:04.000 user1 3 15 2012-05-01 10:45:14.000 user3 4 14 2012-05-01 11:50:22.000 user1 5 15 ------------------------------------------ 2012-05-02 10:30:28.000 user2 12 14 2012-05-02 10:48:59.000 user5 12 14 2012-05-02 10

LINQ to SQL - Stored Procedure Return Type Error

99封情书 提交于 2019-12-14 02:22:52
问题 On SQL 2005 I have a simple SP that selects rows from a table. The SP does not use temporary tables or return multiple result sets. In VS2010 I drag the SP from the Server Explorer to the DBML designer and the SP is added to the LINQ data context. Everything works okay. If I then script the table and SP on to another live SQL 2005 server I am getting the error "The return types for the following stored procedures could not be detected .. " Like I say, no temp tables or multiple result sets

Select all columns except those with only null values

偶尔善良 提交于 2019-12-14 01:27:35
问题 Is there a way to select the column names of a certain table except those columns with only null values without knowing how many columns the table have. ------------------------- | col1 | col2 | col3 | ------------------------ | val1 | null | val2 | | val1 | null | null | | null | null | val2 | ------------------------- Should result in: ------------------------------------ | cols_except_those_with_null_only | ----------------------------------- | col1 | | col3 | -----------------------------

SQL Full-Text-Search returns no results when any noise words are in search string

二次信任 提交于 2019-12-14 01:07:09
问题 I have an asp.net web page used to search for company names in our database using FTS. They enter the company name in a search box and submit. First I trim any leading or trailing spaces, then i replace each internal space with " NEAR ". So a search for: "The Association of Lefthanded Picklepickers" Is fed as: "The NEAR Association NEAR of NEAR Lefthanded NEAR Picklepickers" Into the following WHERE clause used by the search results grid: WHERE CONTAINS(CompanyName, @Search) This method works

selecting most recent record

冷暖自知 提交于 2019-12-14 00:50:00
问题 How to select most recent records if the records are having almost same kind of data... example: col1 col2 col3 col4 -------------------------------------------------- 123 abc 1.1 12345 123 abc 1.1 123445 1234 dsv 2.0 123 1234 dsv 2.0 1233 12345 dsvw 1.2 1234 The maximum of col4 when it compares with rest of the columns. See the row1 and row2 data looks similar but we need the latest data based on col4. Same thing with row3 and row4, data looks similar but we need the latest data based on