sql-server-2008-r2

Why are the performances of these 2 queries so different?

橙三吉。 提交于 2019-12-05 16:43:21
问题 I have a stored proc that searches for products (250,000 rows) using a full text index. The stored proc takes a parameter that is the full text search condition. This parameter can be null, so I added a null check and the query suddenly started running orders of magnitude slower. -- This is normally a parameter of my stored proc DECLARE @Filter VARCHAR(100) SET @Filter = 'FORMSOF(INFLECTIONAL, robe)' -- #1 - Runs < 1 sec SELECT TOP 100 ID FROM dbo.Products WHERE CONTAINS(Name, @Filter) -- #2

How to test connection to a data source in SSAS using C#

元气小坏坏 提交于 2019-12-05 16:18:47
I have a database in Analysis Services on a remote server. This contains a data source for another database located on another remote server. I am trying to write a connectivity test using C# which will check the database connection between the two databases. I have been unable to do this using ADOMD.NET. I'm currently looking at using SMO to do this but I haven't had any luck so far. I would greatly appreciate any advice or suggestions. Update: After further research, I have come up with the below test (Please note that I intend to add more try..catch blocks and Assertions later). Also, this

Must declare the scalar variable error for stored procedure

跟風遠走 提交于 2019-12-05 15:52:43
I have following stored procedure: CREATE procedure validateLogin ( @password varchar(200), @username varchar(100), @IpAddress varchar(100) ) AS BEGIN Declare @qry varchar(max), @LockedIp varchar(max), @LockedTime DateTime, @TimeDifference int; set @qry = 'select IdUser, UserName, FirstName, LastName, idOrg, Users.idRole, Roles.Title as [Role], Allowed_IP from Users, Roles where Users.idRole = Roles.idRole and lower(UserName) = @username and [password] = @password' ; select @LockedIp = isnull(Allowed_IP,''), @LockedTime = isnull(LockedTime, getDate()) from Users where UserName = ISNULL(

TSQLQuery.FieldByName().AsString -> TStringStream Corrupts Data

China☆狼群 提交于 2019-12-05 15:41:27
I'm using Delphi XE2. My code pulls data from a SQL-Server 2008 R2 database. The data returned is a nvarchar(max) field with 1,055,227 bytes of data. I use the following code to save the field data to a file: procedure WriteFieldToFile(FieldName: string; Query: TSQLQuery); var ss: TStringStream; begin ss := TStringStream.Create; try ss.WriteString(Query.FieldByName(FieldName).AsString); ss.Position := 0; ss.SaveToFile('C:\Test.txt'); finally FreeAndNil(ss); end; end; When I inspect the file in a hex viewer, the first 524,287 bytes (exactly 1/2 meg) look correct. The remaining bytes (524,288 to

coordinateSystemId on DbGeography

我怕爱的太早我们不能终老 提交于 2019-12-05 14:51:45
问题 I need to geocode a large number of addresses, using the Bing Map service, EF 5 and SQL Server 2008. I'm using the geography data type in SQL, which translates to a DbGeography type by the EF. When I create a DbGeography object, like this string point = string.Format("POINT({0} {1})",address.Longitude,address.Latitude); address.Location = System.Data.Spatial.DbGeography.PointFromText(point, 4326); The second parameter calls for a "coordinateSystemId". What exactly is this? A lot of the

Encrypting database tables in SQL Server 2008

ⅰ亾dé卋堺 提交于 2019-12-05 13:07:51
I have a Windows application using a database in SQL Server 2008. I do not want users to see the database tables. How can I encrypt tables in my database? demas You have different options here. You can use symmetric encryption for your data: CREATE TABLE sales ( ... ) Create symmetric key: CREATE CERTIFICATE cert_sales WITH SUBJECT = N'Sales certificate', START_DATE = N'2009-01-01', EXPIRY_DATE = N'2018-12-31'; CREATE SYMMETRIC KEY symkey_sales WITH ALGORITHM = AES_256 ENCRYPTION BY CERTIFICATE cert_sales Encrypt data: TRUNCATE TABLE sales; OPEN SYMMETRIC KEY symkey_sales DECRYPTION BY

SQL Increment count on repeat values?

◇◆丶佛笑我妖孽 提交于 2019-12-05 13:00:16
Not sure how to ask this question, I'm not looking for the total count of a value in a column, rather I want to incrementally count repeat values. For example: If my table looks like this: 1, ken 2, ken 3, adam 4, ken 5, adam 6, dan I want to add a column during my select that tags duplicates with an incremental number like this: 1, ken, 1 2, ken, 2 3, adam, 1 4, ken, 3 5, adam, 2 6, dan, 1 You can do this via ROW_NUMBER() with a PARTITION on your second column, ordering by the first: Select Col1, Col2, Row_Number() Over (Partition By Col2 Order By Col1 Asc) As Col3 From YourTable 来源: https:/

how to know if SSIS is installed in my SQL SERVER 2008 R2

一世执手 提交于 2019-12-05 12:13:01
I have sql server 2008 r2, I want to put my stored procedures in packages, i search the internet , i see that i have to install a data tool from microsoft for that. but this tool needs to be SSIS installed in SQL SERVER 2008 R2, how do i know if i have it ? thank u this is my sql server 2008 r2 You can go to SQL Server Configuration Manager (usually available in Start>Sql Server 2008 R2> Configuration Tools). Once launched, you have access to all available services. If Sql Server Integration Services 10.0 is there, you can right click it and start it, if it's not already launched. Otherwise,

Replacing a sql column value based on a column another table

两盒软妹~` 提交于 2019-12-05 11:32:14
I have table1 (col1,col2) and table2(col1,col2) as given below/ Now i need to replace values of col2 of table1 with corresponding value of col1 and col2 from table2. So that the final table should look like this. how can we do this in query?? I assume table1.col2 and table2.col2 have the same text type(?) update table1 set table1.col2=table2.col2 from table1 join table2 on (table1.col2=table2.col1) 来源: https://stackoverflow.com/questions/12248413/replacing-a-sql-column-value-based-on-a-column-another-table

SQL DateTime Conversion Fails when No Conversion Should be Taking Place

喜欢而已 提交于 2019-12-05 11:10:58
I'm modifying an existing query for a client, and I've encountered a somewhat baffling issue. Our client uses SQL Server 2008 R2 and the database in question provides the user the ability to specify custom fields for one of its tables by making use of an EAV structure. All of the values stored in this structure are varchar(255) , and several of the fields are intended to store dates. The query in question is being modified to use two of these fields and compare them (one is a start, the other is an end) against the current date to determine which row is "current". The issue I'm having is that