sql-server-2008-r2

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

走远了吗. 提交于 2019-12-07 08:44:38
问题 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

Crosstab query with count of values in SQL Server 2008 R2

血红的双手。 提交于 2019-12-07 07:25:45
问题 I've searched and am not finding (or understanding!) how to do what I need to do. I feel a bit silly asking this since there are other examples, but I'm just not getting it.... Here's the data I have in a view: [Approach Status] [Clinic] Approached GI Med Onc Pending GI Med Onc Approached GI Med Onc Not Approached Breast Med Onc Approached Breast Med Onc What I need is: [Approach Status] [GI Med Onc] [Breast Med Onc] Approached 2 1 Not Approached 0 1 Pending 1 0 I've played with modifying

Dynamic SQL Result INTO Temporary Table

瘦欲@ 提交于 2019-12-07 07:23:41
问题 I need to store dynamic sql result into a temporary table #Temp . Dynamic SQL Query result is from a pivot result, so number of columns varies(Not fixed). SET @Sql = N'SELECT ' + @Cols + ' FROM ( SELECT ResourceKey, ResourceValue FROM LocaleStringResources where StateId =' + LTRIM(RTRIM(@StateID)) + ' AND FormId =' + LTRIM(RTRIM(@FormID)) + ' AND CultureCode =''' + LTRIM(RTRIM(@CultureCode)) + ''' ) x pivot ( max(ResourceValue) for ResourceKey IN (' + @Cols + ') ) p ;' --@Cols => Column Names

Replacing a sql column value based on a column another table

隐身守侯 提交于 2019-12-07 06:41:31
问题 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?? 回答1: 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

SQL server 2008 R2 Arithmetic overflow error converting numeric to data type numeric

余生颓废 提交于 2019-12-07 06:09:05
问题 I have a confusing error that I can not understand on SQL Server 2008 R2. But when I try the same request on a local server (SQL Server 2008 R2 also) everything works fine. So here is the request raising the problem: select cast(cast(1.260 as numeric(13,3)) as numeric(10,2)) I also added the result of some queries indicating the environment of each server: On the local server: --------------------------------------- 1.26 (1 row(s) affected) Microsoft SQL Server 2008 R2 (RTM) - 10.50.1617.0

why is there the error `Attempting to set a non-NULL-able column's value to NULL` on merge command sometimes?

天涯浪子 提交于 2019-12-07 05:30:17
问题 I use merge statement for inserting new data or deleting data. I use a temp table as source and a table as target . the target table has a foreign ke y with another table( Table A ). I encounter following error sometimes when ( when matched then delete statement) is executed. error: Attempting to set a non-NULL-able column's value to NULL. If I comment this line the query is run perfectly. also If i remove the foreign key between Material table and table A query is run perfectly too. I have

Slow “Select” Query with varchar(max)

折月煮酒 提交于 2019-12-07 03:54:20
问题 I have a small table with 500 rows. This table has 10 columns including one varchar(max) column. When I perform this query: SELECT TOP 36 * FROM MyTable WHERE (Column1 = Value1) It retrieves around 36 rows in 3 minutes. The varchar(max) columns contains in each row 3000 characters. If I try to retrieve only one row less: SELECT TOP 35 * FROM MyTable WHERE (Column1 = Value1) Then the query retrieves 35 rows in 0 seconds. In my clients statistics, Bytes received from server, I have: 95 292 for

Conflict between Delphi and SQL server

只愿长相守 提交于 2019-12-07 03:01:27
I have a Query that works in SQL Server as well but when i save it in ado query in delphi it doesn't work and stops with this error : Incorrect syntax near 'GO' But the below code is correct and has not any error . i was tested it in sql server . The below code is not Regular because i copy and past it from delphi . My Query : create function GetTedad(@pfcode INT, @pdcode INT) returns int as begin declare @Tedad int; select @Tedad= sum(t2.tedade_avalie) from Tbl_avalie_salon t2 where t2.FCode = @pfcode and t2.DCode = @pdcode return (@Tedad); end; GO create function getSumBSen2(@pfcode INT,

Generate script for triggers only using script wizard

帅比萌擦擦* 提交于 2019-12-07 02:54:26
问题 I have SQL Server 2008 R2. I have around 150 tables in a database and for each table I have recently created triggers. It is working fine in my local environment. Now I want to deploy them on my live environment. The question is I want to deploy only the triggers. I tried the Generate Script wizard but it is creating script with table schema along with triggers, NOT triggers only. Is there anyway to generate all the triggers drop and create type script? 回答1: Forget the wizard. I think you

Arithmetic overflow error converting IDENTITY to data type tinyint

妖精的绣舞 提交于 2019-12-07 01:52:39
问题 I am designing table in SQL Server 2008 R2 SP2 Express database. I created table with nvarchar column for data and tinyint column for auto-incrementing identity assuming there will be no more than few rows (that's why I choose 0-255 tinyint ). When I add more than 255 rows, this error keeps occurring permanently even after I delete all rows in that table and try to add one new row. I am doing this using SQL Server Management Studio Express. How to force database engine to check what indexes