sql-server-2008-r2

Get a datetime from year, day of the year and hour in SQL Server 2008 R2

别来无恙 提交于 2019-12-22 04:33:31
问题 I have a table in a Microsft SQL Server 2008 R2, which came from an outside source. The columns of the are as follows: ID, Year, DAY, HOUR & Value , where DAY contains the day of the year (from 1 to 366) and HOUR represents the hour of the day (from 0 to 23). I wish to create a new datetime column and populate it with the dateTime created from the data in Year, DAY & HOUR columns. What SQL function should I use to create the DateTime from its parts? SQL Server 2012 has DATETIMEFROMPARTS, but

How to Connect to SQL Server 2008 R2 Using EF and MVC 3

只谈情不闲聊 提交于 2019-12-22 01:32:25
问题 I am simply trying to learn MVC 3 and following a book from Wrox. Things were fine until I tried to execute a small exercise. I am getting an error which is very common. I have tried everything but could't find what the problem is. Can somebody help me out. My configuration. installed VS201 and then used WebPlatForm Installer to install SP1. Which did installed SP1 and installed MVC3 templates and framework as well on my machine. So far so good. After that I installed SQL Server 2008 R2

is not a recognized built-in function name

时光总嘲笑我的痴心妄想 提交于 2019-12-22 01:24:48
问题 Created a function CREATE FUNCTION Split_On_Upper_Case(@Temp VARCHAR(1000)) RETURNS VARCHAR(1000) AS BEGIN DECLARE @KeepValues AS VARCHAR(50) SET @KeepValues='%[^ ][A-Z]%' WHILE PATINDEX(@KeepValues COLLATE Latin1_General_Bin,@Temp)>0 SET @Temp=STUFF(@Temp,PATINDEX(@KeepValues COLLATE Latin1_General_Bin,@Temp)+1,0,' ') RETURN @Temp END When iam trying to exexute this SELECT Split_On_Upper_Case('SaiBharath') It gives an error "'Split_On_Upper_Case' is not a recognized built-in function name."

Get Last NOT NULL values from all the columns

走远了吗. 提交于 2019-12-22 00:09:11
问题 I have a situation where I am trying to get last not null value from all the columns. here is some data to for demo puposes. Test Data DECLARE @t TABLE (ID INT, Col1 INT, Col2 INT, Col3 INT, Dated DATETIME) INSERT INTO @t VALUES (1, NULL, 100 , NULL, '20131210'), --<-- Column2 from this row (1, 20 , 200 , NULL, '20131209'), --<-- Column1 from this row (1, 30 , NULL , 300 , '20131208'), --<-- Column3 from this row (1, 40 , 400 , NULL, '20131207') ╔════╦══════╦══════╦══════╦════════════════════

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. error in VB.Net

杀马特。学长 韩版系。学妹 提交于 2019-12-21 20:43:50
问题 There were three similar questions in StackOverFlow but none gave an answer.. If have found why this error in occurring but don't know the fix. I am using Strongly Typed Dataset for my project which is created as a dll for DAL. I have added the Sql Server Table into this dataset using the designer and has created a DataAdapter It works fine when i insert using DataTableAdapter daLabTest.Insert(txtLabTestId.Text, cmbLabTestType.Text, cmbTestName.Text, txtLabFees.Text, dtpLabEffDate.Value) but

How can I improve this SQL query?

微笑、不失礼 提交于 2019-12-21 18:13:16
问题 I ran into an interesting SQL problem today and while I came up with a solution that works I doubt it's the best or most efficient answer. I defer to the experts here - help me learn something and improve my query! RDBMS is SQL Server 2008 R2, query is part of an SSRS report that will run against about 100,000 rows. Essentially I have a list of IDs that could have multiple values associated with them, the values being Yes, No, or some other string. For ID x, if any of the values are a Yes, x

How can I improve this SQL query?

时光总嘲笑我的痴心妄想 提交于 2019-12-21 18:13:03
问题 I ran into an interesting SQL problem today and while I came up with a solution that works I doubt it's the best or most efficient answer. I defer to the experts here - help me learn something and improve my query! RDBMS is SQL Server 2008 R2, query is part of an SSRS report that will run against about 100,000 rows. Essentially I have a list of IDs that could have multiple values associated with them, the values being Yes, No, or some other string. For ID x, if any of the values are a Yes, x

newtonsoft.json parser in a C# CLR for SQL Server 2008 R2 - How to deploy?

℡╲_俬逩灬. 提交于 2019-12-21 17:50:50
问题 I have created a CLR which uses the newtonsoft json parser. I need to deploy the CLR . I have created an assembly for the parser dependency: CREATE ASSEMBLY [Newtonsoft.Json] FROM 'C:\share\Release\Newtonsoft.Json.dll' WITH PERMISSION_SET = UNSAFE The above statement throws an error: `Assembly 'Newtonsoft.Json' references assembly 'system.runtime.serialization, version=3.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.', which is not present in the current database. SQL Server

Is this the correct way to use UNION ALL in a stored procedure?

回眸只為那壹抹淺笑 提交于 2019-12-21 17:19:00
问题 Is this the correct way to UNION ALL in a stored procedure? ALTER PROCEDURE [GetHomePageObjectPageWise] @PageIndex INT = 1 ,@PageSize INT = 10 ,@PageCount INT OUTPUT ,@whereStoryID varchar(2000) ,@whereAlbumID varchar(2000) ,@wherePictureID varchar(2000) AS BEGIN SET NOCOUNT ON; SELECT StoryID , AlbumID , StoryTitle , NULL AS AlbumName , (SELECT URL FROM AlbumPictures WHERE (AlbumID = dbo.Stories.AlbumID) AND (AlbumCover = 'True')) AS AlbumCover , Votes , NULL AS PictureId , 'stories' AS

update a database table field with comma separated list from join

纵饮孤独 提交于 2019-12-21 15:24:13
问题 I have two tables named Districts and Schools . The Districts table contains a column named Schools . I need to populate the Schools column of the Districts table from the corresponding Schools table, so that each row in the Districts table has a comma separated list of values of school names from the Schools table. How can I do this? Should I use an UPDATE query or a stored procedure? I only got as far as: SQL Fiddle Districts Table +------------+------+---------+ | DistrictId | Name |