sql-server-2008-r2

Convert number stored as text data type to int

无人久伴 提交于 2019-12-23 08:54:06
问题 I have a database that is a result of an import. The database is a deliverable, I did not do the import myself, nor do I have access to the original data to do it myself. That being said, there is an integer value that was imported to a text datatype. All of the stored values are valid integers. I keep getting: Explicit conversion from data type text to int is not allowed. if I try to change the field data type in the table. I have also created a new INT field in the table and tried to update

I/O error while reading BCP format file

a 夏天 提交于 2019-12-23 08:49:44
问题 Today I created a new staging table and a BCP .fmt file. I created some test data and attempted to run the BCP utility from the command line: I've got about 20 different format files and staging tables from previous work and this is the first time I have encountered this error. How can I fix this error? Please note, I have added my solution below, but if you have other answers, please add them in. The answer was so quirky/obscure that I think it may help others. 回答1: Basically, this one was

Convert GUID to string in SQL Server Reporting Services

浪尽此生 提交于 2019-12-23 08:47:34
问题 While trying to display a GUID column in a report ..its displayed as #error .. =CStr(Fields!number.Value).ToString I tried the above code in the properties of the column..it doesn't work.. Please advise 回答1: =CType(Fields!number.Value, GUID).ToString 回答2: If it is a GUID, just display it without any processing, like other data types. In case you want to convert it for other purposes, just use ToString, for example: =IIf(Fields!number.Value.ToString=Fields!ID.Value.ToString, "true", "false")

ALL vs ANY evaluation in SQL Server

一曲冷凌霜 提交于 2019-12-23 08:43:25
问题 I'm just trying out now the below query: SELECT DISTINCT code, CASE WHEN id = ANY (SELECT DISTINCT u.id FROM unit u LEFT JOIN unit_const uc ON u.id = uc.hid WHERE u.property = 502 AND type = 'Acq') THEN 1 ELSE 0 END AS Case_Eval, (SELECT DISTINCT u.id FROM unit u LEFT JOIN unit_const uc ON u.id = uc.hid WHERE u.property = 502 AND type = 'Acq') AS Evaluation FROM unit WHERE property = 502 which correctly gives the below result: +---------------------------------------+ | Code Case_Eval

How to have analysis service up and running in SQL Server Express Edition

守給你的承諾、 提交于 2019-12-23 07:36:25
问题 I am badly stuck up with this problem! I am running Microsoft SQL Server 2008 R2 and Business Intelligence Development Studio. I am assigned a Analysis Project. Now it so happens that I have an express edition and I know that Express edition does not have analysis services included in it. So my question is How do I use Analysis services? I have spent 2 days of my life searching for the downloads of analysis services. Can anyone do the trick for me? 回答1: SQL Server Analysis Services is

Password mismatch while logging to sql server

╄→尐↘猪︶ㄣ 提交于 2019-12-23 07:04:47
问题 Alright, I have a classic asp application and I have a connection string to try to connect to db. MY connection string looks as follows: Provider=SQLOLEDB;Data Source=MYPC\MSSQLSERVER;Initial Catalog=mydb;database=mydb;User Id=me;Password=123 Now when I'm accessing db though front-en I get this error: Microsoft OLE DB Provider for SQL Server error '80040e4d' Login failed for user 'me'. I looked in the sql profiler and I got this: Login failed for user 'me'. Reason: Password did not match that

Password mismatch while logging to sql server

℡╲_俬逩灬. 提交于 2019-12-23 07:04:09
问题 Alright, I have a classic asp application and I have a connection string to try to connect to db. MY connection string looks as follows: Provider=SQLOLEDB;Data Source=MYPC\MSSQLSERVER;Initial Catalog=mydb;database=mydb;User Id=me;Password=123 Now when I'm accessing db though front-en I get this error: Microsoft OLE DB Provider for SQL Server error '80040e4d' Login failed for user 'me'. I looked in the sql profiler and I got this: Login failed for user 'me'. Reason: Password did not match that

tsql IN not working properly if passed as parameter

。_饼干妹妹 提交于 2019-12-23 05:27:38
问题 I have a sitution where I need to pass a string in order to do an IN declare @searchString varchar(50) set @searchString = ' ''Nestle'',''UFI'' ' select * from tbl1 where CompanyName IN (@SearchString) does't work. But if I do: select * from tbl1 where CompanyName IN ('Nestle','UFI') It works fine. I cannot understand why one work and the other doesn't 回答1: When you use IN it looks at a set and not a single string expression. Because of this you need to implement a function such as CsvToInt

column having maximum integer value from table sql server

喜欢而已 提交于 2019-12-23 05:26:52
问题 This query returns me the maximum integer value from a table: SELECT rownum, max(col) as maxValue -- min 10717 , max = 311216 FROM ( SELECT rownum, col FROM Tables1 UNPIVOT (col FOR ListofColumns IN (col1,col2,col3,col4,col5, col6)) AS unpivott) AS p GROUP BY rownum Instead of "col1,col2,col3,col4,col5,col6". I would like to make this dynamic(automatically taken from table having data type int/numeric). Note: Sometimes number of columns could be 50 and I don't want to write each and every

How to open SQL Server 2012 using run prompt [closed]

十年热恋 提交于 2019-12-23 04:43:31
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I am using SQL Server 2008 R2 and SQL Server 2012. How should I specify whether I have to open SSMS 2008 R2 or SSMS 2012 using run prompt when I run SSMS? Let's say for now I have to open SSMS 2012 using the RUN