sql-server-2008-r2

Self-joining query to find descendants of a node syntax issue

无人久伴 提交于 2019-12-07 01:38:28
I have a self-linking table that records one record for every "Step" in a process (Step.ParentStepId is a foreign key to Step.StepId): CREATE TABLE [dbo].[Step]( [StepId] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](50) NOT NULL, [Description] [text] NULL, [Sequence] [int] NULL, [ParentStepId] [int] NULL, CONSTRAINT [PK_Step] PRIMARY KEY CLUSTERED ( [StepId] ASC ) ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] ALTER TABLE [dbo].[Step] WITH CHECK ADD CONSTRAINT [FK_Step_Step] FOREIGN KEY([ParentStepId]) REFERENCES [dbo].[Step] ([StepId]) I'd like to write a query to return all of the Steps where a

SSAS Tabular on Azure?

浪尽此生 提交于 2019-12-07 01:07:26
问题 I'm attempting to deploy an ssas tabular model (I don't know what I'm doing ) I have made multidimensional on SQL Server 2008 R2 with VS2013. I wanted to try Tabular in conjunction with power BI. So I set up a SQL Azure DB, I have Azure SQL database and Visual Studio 2013 Pro I can get the connection to the Azure DB in VS2013 and write T-SQL against it but when I try and create a tabular model and select the Azure database as the SQL Server workspace it fails to make a connection. Is it

Is it possible to create User-Defined Data Types when using EF 4.1 Code First?

我是研究僧i 提交于 2019-12-07 00:43:30
When using EF 4.1 Code First, is it possible to create User-Defined Data Types for your schema? Simple answer is no. Longer answer: Current EF implementation leads to multiple issues when trying to use user defined types: The type must be defined prior to its usage in table's DDL definition. Because of that the type cannot be defined in Seed method of database initializer (as often used for other database constructs like triggers or indexes). To make this work you must create whole new initializer by implementing IDatabaseInitializer and separate database creation and table creation because

Visual Studio 2015 - Sql Server Project Database Diagram

雨燕双飞 提交于 2019-12-06 20:11:45
问题 Is there as way to create database diagram in Visual Studio as a Sql Server Project? I know it is possible to do it in sql server management studio, but I am also wondering if it is possible to do in Visual studio. 回答1: As per MSDN (https://msdn.microsoft.com/en-us/library/y5a4ezk9.aspx) the Visual Database Designer was deprecated in Visual Studio 2013. If you're using an older version of Visual Studio, note that support for the design tool within Visual Studio stops at SQL Server 2008 R2.

IIF(…) not a recognized built-in function

丶灬走出姿态 提交于 2019-12-06 18:19:55
问题 I'm trying to use this in Microsoft SQL Server 2008 R2: SET @SomeVar = @SomeOtherVar + IIF(@SomeBool, 'value when true', 'value when false') But I get an error: IIF(...) is not a recognized built-in function name Is IIF() only compatible with a later version? Is there an alternate function I can use? 回答1: As others have said, IIF comes from SQL 2012. Before then, you can use CASE: SET @SomeVar = @SomeOtherVar + CASE WHEN @SomeBool THEN 'value when true' ELSE 'value when false' END 回答2: What's

Insert into table from temporary table

泪湿孤枕 提交于 2019-12-06 18:09:38
问题 I have the following table: Example : create table test ( col1 varchar(10), col2 varchar(20), col3 varchar(30) ); Now I want to insert two values by variables and last one by #temp table. #Temp : create table #temp ( col3 varchar(30) ); #Temp : Contains col3 ----- A1 A2 A3 Insertion into test table: Declare @col1 varchar(10) = 'A' Declare @col1 varchar(20) = 'B' Declare @sql varchar(max) SET @SQL = N'insert into test values('+@col1+','+@col2+',........); EXEC(@SQL) /* How to insert `@col3`

SQL Server dbo.sysdiagrams is a user table or system table

那年仲夏 提交于 2019-12-06 17:02:48
问题 When use Database Diagrams in a simple database, SQL Server create a dbo.sysdiagrams table in the Table\Systam Tables node (in Microsoft management studio\object explorer). But sysdiagrams table marked as user table in SQL Server. you can get user table by below query. SELECT * FROM sys.tables t WHERE OBJECTPROPERTY(t.object_id,'IsUserTable') = 1 I don't know that sysdiagram table is a system table or is a user table. Exists microsoft_database_tools_support with value 1 In the extended

FluentNhibernate support for SQL Server 2008 R2

孤者浪人 提交于 2019-12-06 16:10:17
问题 I want to implement a Fluent Nhibernate application with SQL Server 2008 R2. I am in a confusion whether Fluent Nhibernate 1.2 supports SQL Server 2008 R2. If supports what will be the configuration. Does it looks like below? var config = Fluently.Configure() .Database( MsSqlConfiguration .MsSql2008R2 .ConnectionString(@"Data Source=.\SQLEXPRESS;AttachDbFilename='FNHLD.mdf';Integrated Security=True;User Instance=True")) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<NHibernateRepository<T>

How to get the row count for views from a database?

柔情痞子 提交于 2019-12-06 15:53:41
I'm trying to make a customized view that gets me the row count for all the views and tables of a database. Getting the count of table is damn in SQL Server SELECT TABLE_SCHEMA, TABLE_NAME = TABLES.TABLE_NAME, RECORD_COUNT = MAX(SYSINDEXES.ROWS) FROM SYS.SYSINDEXES "SYSINDEXES", INFORMATION_SCHEMA.TABLES "TABLES" WHERE TABLES.TABLE_NAME = OBJECT_NAME(SYSINDEXES.ID) AND TABLES.TABLE_TYPE = 'BASE TABLE' GROUP BY TABLES.TABLE_SCHEMA, TABLES.TABLE_NAME Now, I need to get the rowcount for VIEWS I feel the only way is to count the number of rows from the views i.e. count(*) from view_name But, I

Display Images from Windows Folder in SSRS Report

China☆狼群 提交于 2019-12-06 15:35:46
I'm trying to make a report in BIDS (2008) that will include external images. We want to use the report to proof the images & other info before we approve our flyer for printing. I've done a bit of searching, but haven't gotten the help I need yet. The path to the images will be image specific, like "\\NETWORKSERVER\ServerD\Docs\Flyer's Images\Quarterly Flyer\ImageName.png" The URL works fine when I paste it in the search bar of my local pc or the server that has BIDS installed on it, but the report will not display the image. When I add an image to the textbox, how do I set it up so that it