sql-server-2008-r2

How to avoid default date 1900-01-01 in SQL Server 2008 R2 during join statement

烈酒焚心 提交于 2019-12-11 17:46:28
问题 SELECT IsNull(cmg.[Advertiser], con.[Advertiser]) as [Advertiser] , IsNull(cmg.[AdvertiserID], con.[AdvertiserID]) as [AdvertiserID] , con.[FloodlightConfiguration] , IsNull(cmg.[Campaign], con.[Campaign]) as [Campaign] , IsNull(cmg.[CampaignID], con.[CampaignID]) as [CampaignID] , IsNull(cmg.[Placement], con.[Placement]) as [Placement] , IsNull(cmg.[PlacementID],con.[PlacementID]) as [PlacementID] , IsNull(cmg.[Creative],con.[Creative]) as [Creative] , IsNull(cmg.[CreativeID],con.[CreativeID

TRANSLATE function in SQL SERVER

我的未来我决定 提交于 2019-12-11 16:46:43
问题 I read that there is a function equivalent to the standard function TRANSLATE under DB2 under SQL Server 2017. But how to do under earlier versions? For definition of function : here 回答1: EDITED: I'm feeling dumb - MatBailie correctly pointed out that my original solution was incorrect. I actually always thought that TRANSLATE('abc', 'abc', 'bcd') was supposed to return ddd but, after testing SQL Server 2017's TRANSLATE I see that 'bcd' would be the correct answer. You can see my original

ASP.NET & Crystal Report: load datasource from a stored procedure with temp tables

两盒软妹~` 提交于 2019-12-11 16:11:44
问题 I have used a stored procedure to achieve my desired output in displaying the monhtly sales report of tenants on one mall / location. The stored procedure contains multiple temp tables (due to the limitation of the existing database structure / schema) to accomplish what I need to accomplish. The procedure was indeed successful in gridview. Here's the stored procedure USE [DATABASENAME] GO ALTER PROCEDURE [dbo].[spName] // parameters @Location int, // the location number @CurrentMonthStart

CREATE ASSEMBLY in SQLCLR using assembly byte string failed because it could not open the physical file

你说的曾经没有我的故事 提交于 2019-12-11 15:24:53
问题 I am trying to add user-defined aggregates to a SQL Server 2008 database whose schema is defined in my Visual Studio 2010 solution file. The code for this custom aggregate lives in a SQLCLR project within the same solution, but I am having a lot of difficulty getting my unit tests to pass. For unit testing this project, I am using a method similar to the one here to get the byte string of the assembly. The test suite or a post-build event needs to automatically update my script to create the

table of contents in ssrs

放肆的年华 提交于 2019-12-11 13:58:38
问题 I'm looking for a tutorial or sugestions on how to build table of contents in an ssrs report, something like this: I'm almost there, the only problem is I cannot figure out how to calculate page numbers of the row in a table. Can it be done with bookmarks? or maybe a document map? 回答1: I don't believe this is possible in SSRS (deriving sequential page numbers in the body section of the report), since page numbers are only valid in page headers. However, you could use the page name property of

How to show the participation percentage in each department?

て烟熏妆下的殇ゞ 提交于 2019-12-11 13:50:14
问题 I have the following database design: Employees Table: EmployeeID, Name, OrgCode Departments Table: OrgCode, DepatName CompleteSurvey Table: ID, ParticipantID And I need to develop a table that shows the total number of employees in each department, and the total number of participants who completed the survey in each department, too. Then, I want to show the percentage of participation in each department which is mainly equal to the total number of participants / total number of employees. I

SQL Server XML String Manipluation

微笑、不失礼 提交于 2019-12-11 13:36:25
问题 Let me state I am an XML novice. That said, my issue is I have a SQL Server that creates XML data, and places that into a file that must pass through a security gate to another server. The gate has a list of several "dirty"words that will cause the files to fail if they are included. What I need, is a way for SQL to search the XML data, every node, and if the "dirty" value is present, strip it out (replace with blank). The XML is not strongly typed, and the "dirty"word could possibly be part

optimise sql function to get common elements

吃可爱长大的小学妹 提交于 2019-12-11 13:29:24
问题 I have a function that takes two delimited strings and returns the number of common elements. The The main code of the function is (@intCount is the expected return value) SET @commonCount = (select count(*) from ( select token from dbo.splitString(@userKeywords, ';') intersect select token from dbo.splitString(@itemKeywords, ';')) as total) where splitString uses a while loop and charIndex to split a string into delimited tokens and inserts it into a table. The problem I am having is that

SQL Server recursive cte help wanted

ⅰ亾dé卋堺 提交于 2019-12-11 12:29:04
问题 I'm trying to generate a data set, and I think recursion is required, but I can't quite adapt the numerous examples I've found to my purposes. The end result I want is fairly simple to describe. Two tables are involved: the first with trading pricing for stocks with the relevant fields TradeDate , Symbol , and Clse (closing price), and a table with trading days listed. I'd like to partition the pricing data by symbol, ordered by date, but I'd like the partition/ row numbering to break if a

Need a qry to join a comma separated column with another table with its Id in it to find the code

穿精又带淫゛_ 提交于 2019-12-11 12:16:44
问题 I have a table with Table name TB1 mpeFromWHId mpeToStoreList 8 16,18,24 and Table tb2 are the codes of the comma separated storeid nlid nlcode 16 ncl 18 mcl 24 dcl I need a query that will result in col1 Col2 8 ncl,mcl,dcl 回答1: First you need a function to parse comma delimited string into table, you can use this (found [here])1: CREATE FUNCTION [dbo].Split1(@input AS Varchar(4000) ) RETURNS @Result TABLE(Value BIGINT) AS BEGIN DECLARE @str VARCHAR(20) DECLARE @ind Int IF(@input is not null)