sql-server-2005

Any SQL Server multiple-recordset stored procedure gotchas?

限于喜欢 提交于 2019-12-22 04:39:43
问题 Context My current project is a large-ish public site (2 million pageviews per day) site running a mixture of asp classic and asp.net with a SQL Server 2005 back-end. We're heavy on reads, with occasional writes and virtually no updates/deletes. Our pages typically concern a single 'master' object with a stack of dependent (detail) objects. I like the idea of returning all the data required for a page in a single proc (and absolutely no unnecesary data). True, this requires a dedicated proc

SQL Server 2005 unique key with null value

邮差的信 提交于 2019-12-22 04:38:24
问题 I have a table in SQL Server 2005 with a foreign key, and I want that foreign key to be a unique value or null. I've set it up as a unique key, but it won't allow me to have multiple nulls in the same table. Is it possible to do what I want? 回答1: This is a long time complaint about SQL Server's Unique constraints/indexes. The best solution is to create a view with schemabinding and then put a unique index on that column: Create View dbo.MyUniqueColView With SchemaBinding As Select

sql scripting variable default value

房东的猫 提交于 2019-12-22 04:37:12
问题 I have a script file e.g. test.sql. I want to call this from another script, say caller.sql, in sqlcmd mode using :r test.sql. This works fine, but I want to use a scripting variable in test.sql. When I call test.sql from caller.sql I can set the scripting variable and all is well. However, I want to use a default value for the scripting value so that if the caller does not set the variable, or if I run test.sql directly (not from caller.sql) then the scripting variable defaults to a set

Randomly assign work location and each location should not exceed the number of designated employees

断了今生、忘了曾经 提交于 2019-12-22 04:34:07
问题 I am trying to select unique random posting/recruitment places of employees within a list of places, all the employees are already posted at these places, i am trying to generate a new random posting place for them with "where" condition that "employee new random location will not be equal to their home place and randomnly selected Employees with their designation must be less than or equal to Place wise designation numbers from Places table " the Employee table is : EmpNo EmpName

SELECT statement in JAVA

☆樱花仙子☆ 提交于 2019-12-22 04:31:07
问题 public void search() throws Exception{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url = "jdbc:odbc:******"; String user = "*****"; String pass = "*****"; Connection con = DriverManager.getConnection(url, user, pass); Statement state = con.createStatement(); ResultSet rs = state.executeQuery(""); ResultSetMetaData rsmetadata = rs.getMetaData(); int columns = rsmetadata.getColumnCount(); DefaultTableModel dtm = new DefaultTableModel(); Vector column_name = new Vector(); Vector data

Need help finding the correct T-SQL Query

可紊 提交于 2019-12-22 04:15:10
问题 I am not quite sure how to go about doing this. Basically I have have a table like this UserId DateRequested Approved ApprovedBy Notes ------------ ----------------------- -------- ----------- ----- 1 2011-05-26 0 NULL NULL 1 2011-05-27 0 NULL NULL 1 2011-05-28 0 NULL NULL 1 2011-06-05 0 NULL NULL 1 2011-06-06 0 NULL NULL 1 2011-06-25 0 NULL NULL Which basically contains the days an employee requests a holiday. Now, when a day or days is granted, this data needs to be copied over to a table

How to get the data from linked servers using queries

寵の児 提交于 2019-12-22 04:13:05
问题 I have created a linkedserver as ravikiran-vm which is the virtual machine in my desktop. Now I have a database called kiran which contains an employ table. To retrieve employ data, I do the following: select * from ravikiran-vm.kiran.employ but it shows the error "Incorrect syntax near '-'." Can anyone help me, please? Thanks in advance. Thanks guys with ur support it working fine... Now i hav to schedule this as a new job.when i execute it as normal it shows o/p. but when i cinfigure the

How to get the data from linked servers using queries

扶醉桌前 提交于 2019-12-22 04:13:04
问题 I have created a linkedserver as ravikiran-vm which is the virtual machine in my desktop. Now I have a database called kiran which contains an employ table. To retrieve employ data, I do the following: select * from ravikiran-vm.kiran.employ but it shows the error "Incorrect syntax near '-'." Can anyone help me, please? Thanks in advance. Thanks guys with ur support it working fine... Now i hav to schedule this as a new job.when i execute it as normal it shows o/p. but when i cinfigure the

SQL Server - Performance/Size Drawbacks of Null Columns

白昼怎懂夜的黑 提交于 2019-12-22 03:54:52
问题 I'm working on a table design that could involve many NULL values in about 10 fields maybe 75% of the time the fields would be unused. I just generated some fake data (a million records) and could not sense any impact on SQL Server 2005. Size difference was in the KB. Performance - no measurable difference after adding an index to the 3 non-nullable columns. I know SQL Server 2008 has the sparse columns feature (which I assume is going to be used on the next SharePoint's UserData table). I

Why does the order of join clauses affect the query plan in SQL Server?

最后都变了- 提交于 2019-12-22 03:15:48
问题 I am building a view in SQL Server 2000 (and 2005) and I've noticed that the order of the join statements greatly affects the execution plan and speed of the query. select sr.WTSASessionRangeID, -- bunch of other columns from WTSAVW_UserSessionRange us inner join WTSA_SessionRange sr on sr.WTSASessionRangeID = us.WTSASessionRangeID left outer join WTSA_SessionRangeTutor srt on srt.WTSASessionRangeID = sr.WTSASessionRangeID left outer join WTSA_SessionRangeClass src on src.WTSASessionRangeID =