sql-server-2005

Need T-SQL help for converting Rows from multiple tables into Columns with values in Sql Server 2005

半世苍凉 提交于 2020-03-26 17:00:20
问题 I have a table tblUser: tblUser and a table tblBCE and data in the given below: tblBCE and a master table mstBCE which contains label text to display in front end application. This table contains data for other tab also but currently i want only for tabType 'BCE',I will do for other tab myself once i got the concept. mstBCE There is no relation between tblBCE and mstBCE tables,we need to follow the top to bottom sequence only. In front end application i display these data only by sequence i.e

What is the point of “Initial Catalog” in a SQL Server connection string?

▼魔方 西西 提交于 2020-03-08 04:57:26
问题 Every SQL Server connection string I ever see looks something like this: Data Source=MyLocalSqlServerInstance;Initial Catalog=My Nifty Database; Integrated Security=SSPI; Do I need the Initial Catalog setting? (Apparently not, since the app I'm working on appears to work without it.) Well, then, what's it for? 回答1: If the user name that is in the connection string has access to more then one database you have to specify the database you want the connection string to connect to. If your user

What is the point of “Initial Catalog” in a SQL Server connection string?

烂漫一生 提交于 2020-03-08 04:55:29
问题 Every SQL Server connection string I ever see looks something like this: Data Source=MyLocalSqlServerInstance;Initial Catalog=My Nifty Database; Integrated Security=SSPI; Do I need the Initial Catalog setting? (Apparently not, since the app I'm working on appears to work without it.) Well, then, what's it for? 回答1: If the user name that is in the connection string has access to more then one database you have to specify the database you want the connection string to connect to. If your user

Why use the INCLUDE clause when creating an index?

只愿长相守 提交于 2020-03-07 05:16:39
问题 While studying for the 70-433 exam I noticed you can create a covering index in one of the following two ways. CREATE INDEX idx1 ON MyTable (Col1, Col2, Col3) -- OR -- CREATE INDEX idx1 ON MyTable (Col1) INCLUDE (Col2, Col3) The INCLUDE clause is new to me. Why would you use it and what guidelines would you suggest in determining whether to create a covering index with or without the INCLUDE clause? 回答1: If the column is not in the WHERE/JOIN/GROUP BY/ORDER BY , but only in the column list in

Why use the INCLUDE clause when creating an index?

孤街醉人 提交于 2020-03-07 05:16:25
问题 While studying for the 70-433 exam I noticed you can create a covering index in one of the following two ways. CREATE INDEX idx1 ON MyTable (Col1, Col2, Col3) -- OR -- CREATE INDEX idx1 ON MyTable (Col1) INCLUDE (Col2, Col3) The INCLUDE clause is new to me. Why would you use it and what guidelines would you suggest in determining whether to create a covering index with or without the INCLUDE clause? 回答1: If the column is not in the WHERE/JOIN/GROUP BY/ORDER BY , but only in the column list in

SQL Server 2005 - Row_Number()

五迷三道 提交于 2020-02-25 13:26:48
问题 I'm trying to understand the unusual behaviour seen when ordering results in a descending order using the row_number() function when using a DISITINCT on the outermost select in my query as below: SELECT DISTINCT (ID), State_Id, Name_Of_Trip, Date_Of_Travel, Creation_Date, Locking_Id, Applicant_Name, Reference_Number, State_Name FROM ( SELECT app.ID, app.State_Id, app.Name_Of_Trip, app.Date_Of_Travel, app.Creation_Date, app.Locking_Id, app.Applicant_Name, app.Reference_Number, State.Name AS

SQL Server 2005 - Row_Number()

时间秒杀一切 提交于 2020-02-25 13:26:35
问题 I'm trying to understand the unusual behaviour seen when ordering results in a descending order using the row_number() function when using a DISITINCT on the outermost select in my query as below: SELECT DISTINCT (ID), State_Id, Name_Of_Trip, Date_Of_Travel, Creation_Date, Locking_Id, Applicant_Name, Reference_Number, State_Name FROM ( SELECT app.ID, app.State_Id, app.Name_Of_Trip, app.Date_Of_Travel, app.Creation_Date, app.Locking_Id, app.Applicant_Name, app.Reference_Number, State.Name AS

Dynamic table design (common lookup table), need a nice query to get the values

和自甴很熟 提交于 2020-02-25 04:18:11
问题 sql2005 This is my simplified example: (in reality there are 40+ tables in here, I only showed 2) I got a table called tb_modules, with 3 columns (id, description, tablename as varchar): 1, UserType, tb_usertype 2, Religion, tb_religion (Last column is actually the name of a different table) I got an other table that looks like this: tb_value (columns:id, tb_modules_ID, usertype_OR_religion_ID) values: 1111, 1, 45 1112, 1, 55 1113, 2, 123 1114, 2, 234 so, I mean 45, 55, 123, 234 are usertype

Stop LINQ to SQL from executing select statements after insert

这一生的挚爱 提交于 2020-02-20 00:59:22
问题 I'm using LINQ to SQL to update my database. I'm inserting a lot of records, and when I call SubmitChanges(), LINQ to SQL executes an insert and a select statement for each object. I don't really care to update my objects after they are inserted into the database. Do you know I can prevent LINQ to SQL from issuing the select statements after the insert statements? This should make my app much faster. 回答1: You're looking for ColumnAttribute.AutoSync. If you're using the designer, check each

Stop LINQ to SQL from executing select statements after insert

巧了我就是萌 提交于 2020-02-20 00:57:09
问题 I'm using LINQ to SQL to update my database. I'm inserting a lot of records, and when I call SubmitChanges(), LINQ to SQL executes an insert and a select statement for each object. I don't really care to update my objects after they are inserted into the database. Do you know I can prevent LINQ to SQL from issuing the select statements after the insert statements? This should make my app much faster. 回答1: You're looking for ColumnAttribute.AutoSync. If you're using the designer, check each