sql-server-2008-r2

Why setting current identity value is not working for me in SQL Server 2008 R2?

妖精的绣舞 提交于 2020-01-06 19:29:47
问题 I am working with SQL Server 2008 R2. I have a table seq_audit which has an identity column. This is the definition of the table: CREATE TABLE [dbo].[seq_audit] ( [id] [bigint] IDENTITY(1,1) NOT NULL, [value] [bit] NULL, PRIMARY KEY CLUSTERED ([id] ASC) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY] ) ON [PRIMARY] The table is empty and never has had any rows in it before. To check its

Join two tables with two columns SQL Server 2008 R2

二次信任 提交于 2020-01-06 17:58:47
问题 I have two tables that I would like to join together. One is a table with various bits of information and one is a dimension view, a definitions table of sorts. The table with the desired information looks like this VISIT ID | ATN_DR_NO | ADM_DR_NO |... 12345678 | 987654 | 123456 |... Where the ATN_DR_NO is the Attending Doctor id number and the ADM_DR_NO is the admitting Doctor id. I have a second table that has the Doctor ID numbers and their corresponding names like so src_prct_no | pract

Installation wizard shows its success , however, SSIS Package is not getting installed

喜欢而已 提交于 2020-01-06 17:48:01
问题 I have both SQL Server 2008 R2 and 2012 both installed on same server. My SSIS package is developed by BI studio 2008 R2. I have created package manifest file for the installation. As both SQL Server 2008 R2 and 2012 installed, when I run command: H:\>where dtsinstall.exe it returns these 3 details: C:\Program Files\Microsoft SQL Server\100\DTS\Binn\dtsinstall.exe C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\dtsinstall.exe C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn

Installation wizard shows its success , however, SSIS Package is not getting installed

烂漫一生 提交于 2020-01-06 17:46:33
问题 I have both SQL Server 2008 R2 and 2012 both installed on same server. My SSIS package is developed by BI studio 2008 R2. I have created package manifest file for the installation. As both SQL Server 2008 R2 and 2012 installed, when I run command: H:\>where dtsinstall.exe it returns these 3 details: C:\Program Files\Microsoft SQL Server\100\DTS\Binn\dtsinstall.exe C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\dtsinstall.exe C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn

Multiple Columns in one table referencing back to one table get their values

白昼怎懂夜的黑 提交于 2020-01-06 14:00:06
问题 I have a table table_One which has Multiple columns(Column1, Column2, Column3, Column4.....) both references ( Contains PK values for Table_two ) to another table Table_Two . Is there any efficient way getting joining these two tables rather than joining Table_one back to table_Two Multiple Times.br/> The Structure of the Two tables and the Desired Result Set is as follows. Table_One 回答1: Following solution (SQLFiddle) reads the rows from the second table just one time: SET STATISTICS IO ON;

Create more than one non clustered index on same column in SQL Server

烈酒焚心 提交于 2020-01-06 04:01:07
问题 What is the index creating strategy? Is it possible to create more than one non-clustered index on the same column in SQL Server? How about creating clustered and non-clustered on same column? Very sorry, but indexing is very confusing to me. Is there any way to find out the estimated query execution time in SQL Server? 回答1: The words are rather logical and you'll learn them quite quickly. :) In layman's terms, SEEK implies seeking out precise locations for records, which is what the SQL

Should DateKey YYYYMMDD be char(8)?

白昼怎懂夜的黑 提交于 2020-01-05 19:29:50
问题 The two most important fields, that are everywhere in our warehouse, are the UserAccountKey and the DateKey. DateKey is (int, not null) UserAccountKey is (int, not null) Are these the correct data type? The WH was created in 2006 so type Date wasn't an option, although we are now running 2008-R2 so it is now an option for the next iteration of the WH. It's a well established WH with multiple cubes built from it and a whole reporting system. Additional question to the above is when the WH was

Should DateKey YYYYMMDD be char(8)?

橙三吉。 提交于 2020-01-05 19:29:08
问题 The two most important fields, that are everywhere in our warehouse, are the UserAccountKey and the DateKey. DateKey is (int, not null) UserAccountKey is (int, not null) Are these the correct data type? The WH was created in 2006 so type Date wasn't an option, although we are now running 2008-R2 so it is now an option for the next iteration of the WH. It's a well established WH with multiple cubes built from it and a whole reporting system. Additional question to the above is when the WH was

SQL function performance

两盒软妹~` 提交于 2020-01-05 17:22:09
问题 I have this function which is used on my view. FUNCTION [dbo].[CalculateAmount] ( @ID INT, @PRICE DECIMAL(24,4)) declare @computedValue decimal(24,4) set @computedValue = case when (select TABLE1.ID FROM dbo.[TABLE1] TABLE1 JOIN dbo.[TABLE2] TABLE2 ON TABLE2.ID = TABLE1.ID WHERE TABLE1.ID = @ID // some conditions here // Is null then @PRICE else @PRICE * CAST('1.0368' as decimal(24,4)) end So basically, I wanted to check if the ID passed as parameter is existing on TABLE1. If it returned a

Finding and removing duplicate column values in a SQL Server row

风格不统一 提交于 2020-01-05 07:24:14
问题 Yes, another SQL duplicates question :) I have a SQL Server 2008 R2 table with multiple phone number columns, looking something like: ID Tel1 Tel2 Tel3 Tel4 Tel5 Tel6 1 123 456 789 NULL NULL NULL 2 123 456 123 123 NULL NULL 3 456 789 123 456 NULL NULL I'd like to remove the duplicate phone numbers from each row - for example, in row ID 2, I need to NULL Tel3 and Tel4, and in row 3 I need to NULL Tel4. I don't need to check for duplicates between rows - the same phone number can exist between