sql-server-2008-r2

How to execute SQLCLR UDF added directly to SSDT sqlproj and resolve reference error SQL71501

跟風遠走 提交于 2019-12-11 09:28:51
问题 I have been trying to find the answer to this simple question - but so far couldn't figure it out. Let say I have MyDb.sqlproj, with various sql content (sprocs, views, trigger, etc). I have added a new UDF through Add-> New item -> SQL CLR C#, User Defined Function. For example: namespace MyNameSpace { public class MyClass { [SqlFunction(DataAccess = DataAccessKind.Read)] //I use different attributes here, but it doesn't matter public static int Method1() { return 0; } } } In MyDb.sqlproj

sp_send_dbmail keep sending email

蓝咒 提交于 2019-12-11 09:17:26
问题 I created a SP which rebuild/reorganize my indexes. If an error occurs, the sp_send_dbmail notifies me the error. The call is something like this EXEC MSDB.DBO.sp_send_dbmail @profile_name=@profile_name, @recipients = 'email@domain.com', @body=@Message, @body_format='TEXT', @Subject=@Subject; The last week, worked fine, I received the errors by email. But last night, when an error occured, sent a email, and now is sending the same email continuously. On the job activity monitor the job is

Crystal Reports using multiple results from a Stored Procedure

﹥>﹥吖頭↗ 提交于 2019-12-11 08:48:08
问题 I have a stored proc in sql-server and one of the parameters it returns is a string with the query parameters. I display those query parameters at the top of the report. That works great if something is found, not so great if nothing was found. We have tried returning two query results, one the data set that I will make the report from (which includes the query parameters), the other the query parameter string. Crystal appears to only see the first data set, and this very old discussion (http

SQL how to do 1 hour interval

只愿长相守 提交于 2019-12-11 08:38:04
问题 I have sql query which returns record by date specified What I want to do is group them by 1 hour interval My query returns a date and interval. interval value looks like this 8:00,8:30,9:00,9:30,10:00 as you can see the interval has produce 5 value what I want to do is group them by this 8:00-9:00,9:00-10:00 I have designed a query: SELECT DATEPART(HOUR,VC.DATE+ VC.INTERVAL) AS DATE ,DATEPART(HOUR,VC.INTERVAL) AS INTERVAL FROM VMUK_Q1R_IB_CONSOLIDATED VC But the problem with this it display

Newer SSRS instance with old Database Engine?

旧巷老猫 提交于 2019-12-11 07:52:05
问题 Is it possible to install a SQL Server 2012 SP1 Reporting Services instance on "server A" that points to a SQL Server 2008 R2 SP2 Database Engine instance on "server B?" I cannot seem to find any documentation that indicates interoperability between different versions of SQL Server Reporting Services and the Database Engine. 回答1: Yes, you can install just reporting services on "server A". Make sure to choose feature installation and only check "Reporting Services - Native" on the feature

Capture primary key constraint violation in SQL server 2008

眉间皱痕 提交于 2019-12-11 07:43:27
问题 is there a way to automatically capture (either in SQL server log or Window Event Log) constraint violation due to Inserts into SQL server table with duplicate primary key values? for Ex: When I try to insert duplicate primary key in SQL Server Management Studio, i get the following error Msg 2627, Level 14, State 1, Line 2 Violation of PRIMARY KEY constraint 'PK_ Customer _A4AE64D87F60ED59'. Cannot insert duplicate key in object 'dbo.Customer'. The statement has been terminated. But i am

Attendance record from bio-metric device

江枫思渺然 提交于 2019-12-11 07:34:20
问题 Here is my data |Id |EmpCode |CheckInCheckOutDate |WorkDate |InOutMode |247 |51 |2017-02-13 20:08:52.000 |2017-02-13 20:08:52.000 |0 |392 |51 |2017-02-13 22:38:51.000 |2017-02-13 22:38:51.000 |1 |405 |51 |2017-02-13 22:59:18.000 |2017-02-13 22:59:18.000 |0 |415 |51 |2017-02-13 23:18:17.000 |2017-02-13 23:18:17.000 |1 |423 |51 |2017-02-13 23:33:44.000 |2017-02-13 23:33:44.000 |0 |456 |51 |2017-02-14 01:30:15.000 |2017-02-13 01:30:15.000 |1 |463 |51 |2017-02-14 02:52:02.000 |2017-02-13 02:52:02

Selecting few columns of a result set as XML

本小妞迷上赌 提交于 2019-12-11 07:29:40
问题 I have a simple SELECT statement which selects few columns from a single table: SELECT id, name, phone, address FROM tmp_user Is it possible to change this query so that only id and name are in select and remaining details are in a xml node? I expected output of this select should be id name extra data 1 Shreedhar <data><phone>...</phone><address>...</address></data> 2 John Doe <data><phone>...</phone><address>...</address></data> 3 Jane Doe <data><phone>...</phone><address>...</address><

How can I avoid duplicate rows from near-simultaneous SQL adds?

我的未来我决定 提交于 2019-12-11 07:25:42
问题 My Razor 3 web app is creating multiple rows for the same foreign key Id, when multiple input comes in for the same Id, and I would like help on how to avoid this. The SQL Server table stores data about records in another table (it's ratings users have given about certain things, where there is also a table of users and a table of rate-able things, so the ratings table has a foreign key id for user, a foreign key id for the thing rated, and a value for the rating). When no rating has been

Date format in SQL Server 2008 R2

早过忘川 提交于 2019-12-11 07:16:08
问题 How to cast date for the following format in SQL Server 2008 R2: Date: '29-01-2008 AM 12:00:00' I have above date to check with the present date of the table. How can I check only date from the above format? 回答1: If you want only the date, then do: select convert(date, left('29-01-2008 AM 12:00:00', 10), 105) This will convert it to a date and you can then compare it to `cast(getdate() as date). The full list of formats for convert() is in the documentation. 来源: https://stackoverflow.com