sql-server-2008-r2

Getting a “one or more parameters required to run the report have not been specified” error

ε祈祈猫儿з 提交于 2019-11-30 11:06:07
I am building a report that I would like to accept two values from the user, feed those into a query, and find the data associated with those entries. For example, if you had a list of employees, performance measures, and values associated with those; then the user would select an employee name / performance measure, and they would get the scoring information on that employee for that measure. I have two parameters, each being populated from SQL queries getting a distinct list of employee names and measures, and a table below that just pulls up information based on ~ 'WHERE name = @Name AND

Difference of create Index by using include column or not using

半城伤御伤魂 提交于 2019-11-30 11:01:11
I Want To Create Index In SQL Server 2008 R2 in Column1 and Column2 What is the difference of below query: Not include CREATE NONCLUSTERED INDEX [IX_1] ON [dbo].[MyTable] ( [Column1] ASC, [Column2] ASC ) ON [PRIMARY] Or include: CREATE NONCLUSTERED INDEX [IX_2] ON [dbo].[MyTable] ( [Column1] ASC ) INCLUDE ([Column2]) ON [PRIMARY] Martin Smith In the first one Column2 gets added to the index key. In the second one it might not (*) get added to the key in which case it will only appear in the index leaf pages. This can allow the index to be searched by Column1 but avoid the need to go back to

Reset autoincrement in Microsoft SQL Server 2008 R2

佐手、 提交于 2019-11-30 10:56:58
问题 I created a primary key to be autoincrement. I added two rows: ID=1, ID=2 I deleted these two rows. I added a new row, but the new row's ID was: ID=3 How can I reset or restart the autoincrement to 1? 回答1: If you use the DBCC CHECKIDENT command: DBCC CHECKIDENT ("YourTableNameHere", RESEED, 1); But use with CAUTION! - this will just reset the IDENTITY to 1 - so your next inserts will get values 1, then 2, and then 3 --> and you'll have a clash with your pre-existing value of 3 here! IDENTITY

Remote Procedure call failed with sql server 2008 R2

让人想犯罪 __ 提交于 2019-11-30 10:28:27
问题 I am working with SQL Server 2008 R2. I am unable to connect to my database remotely. I got the following error. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) I have checked the SQL Server properties

Construct DateTime using today's date at a specific time

限于喜欢 提交于 2019-11-30 09:48:47
I'd like to get 4:30 PM of the current day. Hard-coding this way doesn't work: SELECT '07242012 16:30:00.000' This is proving to be more difficult than I thought it would be. How do I approach this? SQL Server 2000 / 2005: SELECT DATEADD(MINUTE, 30, DATEADD(HOUR, 16, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP))); -- or SELECT DATEADD(MINUTE, (16*60) + 30, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP)) -- or SELECT CONVERT(DATETIME, CONVERT(CHAR(9), CURRENT_TIMESTAMP, 112) + '16:30'); SQL Server 2008+: SELECT CONVERT(DATETIME, CONVERT(DATE, CURRENT_TIMESTAMP)) + '16:30'; SQL Server 2012: SELECT

SSIS how to convert string (DT_STR) to money (DT_CY) when source has more than 2 decimals

。_饼干妹妹 提交于 2019-11-30 09:27:49
问题 I have a source flat file with values such as 24.209991, but they need to load to SQL Server as type money. In the DTS (which I am converting from), that value comes across as 24.21. How do I convert that field in SSIS? Right now, I am just changing the type from DT_STR to DT_CY, and it gives a run error of 'Data conversion failed. The data conversion for column "Col003" returned status value 2 and status text "The value could not be converted because of a potential loss of data.".' Do I use

Bring SQL Server database online

感情迁移 提交于 2019-11-30 09:22:23
I executed the task Take offline of a SQL Server 2008 R2 database. I cant bring it online! I tried with USE master; GO ALTER DATABASE [DBNAME] SET ONLINE I get an error. User does not have permission to alter database 'DBNAME', the database does not exist, or the database is not in a state that allows access checks. I also tried using the task Bring online and I get the exact same error. Can anyone help me asap? I think you're going to need to login with the SA account, or some other account with sysadmin privileges, and then run your code to put it back online. While you're in there, add

How to get node name and values from an xml variable in t-sql

牧云@^-^@ 提交于 2019-11-30 09:04:54
I have the following xml - <Surveys xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ImmForm XML Schema NHS Direct.xsd"><Svy SurveyName="WeeklyFluSurveillance2012/13-NHSDirectWeek40w/e07/10/2012" OrgCode="NHS Direct"><TotCR>222.10</TotCR><PerCF>0.40</PerCF><PerCFunder1>0.20</PerCFunder1><PerCF1to4>0.30</PerCF1to4><PerCF5to14>0.50</PerCF5to14><PerCF15to44>0.40</PerCF15to44><PerCF45to64>0.20</PerCF45to64><PerCF65plus>3.60</PerCF65plus> <PerCFNE>4.22</PerCFNE> <PerCFNW>6.50</PerCFNW> <PerCFYH>0.80</PerCFYH> <PerCFEM>1.00</PerCFEM> <PerCFWM>1.50</PerCFWM></Svy><

Detecting circular references in SQL

99封情书 提交于 2019-11-30 09:02:17
问题 I have the following table: CREATE TABLE X ( A SOMETYPE NOT NULL, B SOMETYPE NOT NULL, C SOMETYPE NULL, PRIMARY KEY (A,B), FOREIGN KEY (A,C) REFERENCES X (A,B) ); The entities stored in X are hierarchically organized: If a row (A1,B1,C1) exists and C1 IS NOT NULL then it is considered to be a "child" of (A1,C1,C2) whatever C2 is. Since an item cannot descend from itself, I would like to make it illegal that circular hierarchical sequences exist: -- legal INSERT INTO X (A1,B1,NULL); INSERT

Convert a string with 'YYYYMMDDHHMMSS' format to datetime

不打扰是莪最后的温柔 提交于 2019-11-30 08:52:23
I recognize there has been many questions posted about converting strings to datetime already but I haven't found anything for converting a string like 20120225143620 which includes seconds. I was trying to perform a clean conversion without substring-ing each segment out and concatenating with / and : . Does anyone have any suggestions? You can use the STUFF() method to insert characters into your string to format it in to a value SQL Server will be able to understand: DECLARE @datestring NVARCHAR(20) = '20120225143620' -- desired format: '20120225 14:36:20' SET @datestring = STUFF(STUFF