sql-server-2008-r2

The formal parameter “@mode” was not declared as an OUTPUT parameter, but the actual parameter passed in requested output

…衆ロ難τιáo~ 提交于 2020-01-02 01:59:29
问题 I have this stored procedure: ALTER PROCEDURE spCertificationType @result nvarchar(15) output, @mode int AS BEGIN if @mode = 1 begin exec spGeneratedID 2, @result output print @result end END but when I tried to execute it,it has this error The formal parameter “@mode” was not declared as an OUTPUT parameter, but the actual parameter passed in requested output. I tried to set @mode as output like this: ALTER PROCEDURE spCertificationType @result nvarchar(15) output, @mode int output AS BEGIN

How to figure out which SQLDependency triggered change function?

冷暖自知 提交于 2020-01-01 17:26:08
问题 I'm exploring query notifications with the SQLDependency class. Building a simple working example is easy, but I feel like I'm missing something. Once I step past a simple one-table/one-dependency example I'm left wondering how can I figure out which dependency triggered my callback? I'm having a bit of trouble explaining, so I included the simple example below. When AChange() is called I cannot look at the sql inside the dependency, and i don't have a reference to the associated cache object

Issue with Window Function in MSSQL 2008 R2

99封情书 提交于 2020-01-01 16:35:13
问题 I am receving execution error in following sql script. Select TOP 1 Percent a.accode,a.voucherdate,a.credit,a.Debit, SUM(a.Debit) Over (Order By [a.accode],[a.voucherdate] ) as rdr from VoucherMain as a Order By a.accode,a.voucherdate Error Message Incorrect syntax near 'order'. Can anyone tell me what's wrong with the script syntext? 回答1: The problem is that you need SQL Server 2012 and above. Okay, I added the "and above" for future visitors, but compare 2008 OVER CLAUSE with 2012 OVER

Issue with Window Function in MSSQL 2008 R2

人走茶凉 提交于 2020-01-01 16:34:49
问题 I am receving execution error in following sql script. Select TOP 1 Percent a.accode,a.voucherdate,a.credit,a.Debit, SUM(a.Debit) Over (Order By [a.accode],[a.voucherdate] ) as rdr from VoucherMain as a Order By a.accode,a.voucherdate Error Message Incorrect syntax near 'order'. Can anyone tell me what's wrong with the script syntext? 回答1: The problem is that you need SQL Server 2012 and above. Okay, I added the "and above" for future visitors, but compare 2008 OVER CLAUSE with 2012 OVER

Alter column from NVARCHAR to NBINARY

前提是你 提交于 2020-01-01 16:22:07
问题 I accidentally created a column with the wrong type NVARCHAR (for storing password salts) and I want to convert it to NVARBINARY . I tried ALTER TABLE [dbo].[TableName] ALTER COLUMN [ColumnName] [varbinary] (20) NOT NULL GO but it says Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query. Is there a way to do that? CONVERT seems to be for expressions only, not for alterations. 回答1: The only way by altering will be someting like:

Unable to log in to server in SQL Server 2008 R2 Management Studio

不打扰是莪最后的温柔 提交于 2020-01-01 14:57:14
问题 I have a SQL Server 2008 R2 instance and can log in using the sa user. But I want to define another user ( administrator ) to log in with SQL Server Management Studio, so I did the following: Logged in to the server in Management Studio as sa . Right clicked on the database name. Clicked on properties. Then under permission, I select the required username ( administrator ). And I grant him all the permission. But when I tried to log in using administrator , I got the following error: Login

What is the best way to push inserted data out of SQL Server to an application?

梦想与她 提交于 2020-01-01 09:43:25
问题 I would like to use some mechanism within SQL Server (or one of its services) to push change messages out (via UDP, for example, but TCP is OK, too) when rows get inserted into a table. I would like for these messages to be more than notifications of change, but to actually contained the changed data. Is there a mechanism that comes with SQL Server 2008 R2 to do this? I've heard of Service Broker and Extended Events, but am not sure that these are the right tools for the job when it comes to

Does SQL Server support IS DISTINCT FROM clause?

不打扰是莪最后的温柔 提交于 2020-01-01 07:37:12
问题 Does SQL Server support IS DISTINCT FROM statement which is SQL:1999 standard? E.g. the query SELECT * FROM Bugs WHERE assigned_to IS NULL OR assigned_to <> 1; can be rewritten using IS DISTINCT FROM SELECT * FROM Bugs WHERE assigned_to IS DISTINCT FROM 1; 回答1: No, it doesn't. The following SO question explains how to rewrite them into equivalent (but more verbose) SQL Server expressions: How to rewrite IS DISTINCT FROM and IS NOT DISTINCT FROM? There's also a Uservoice entry for this issue,

“Merge” style operation with literal values?

十年热恋 提交于 2019-12-31 22:27:15
问题 I have a table containing a student-grade relationship: Student Grade StartDate EndDate 1 1 09/01/2009 NULL 2 2 09/01/2010 NULL 2 1 09/01/2009 06/15/2010 I am trying to write a stored procedure that takes Student , Grade , and StartDate , and I would like it to check to make sure these values are not duplicates insert the record if it's not a duplicate if there is an existing student record, and it has a EndDate = NULL , then update that record with the StartDate of the new record. For

“Merge” style operation with literal values?

↘锁芯ラ 提交于 2019-12-31 22:27:10
问题 I have a table containing a student-grade relationship: Student Grade StartDate EndDate 1 1 09/01/2009 NULL 2 2 09/01/2010 NULL 2 1 09/01/2009 06/15/2010 I am trying to write a stored procedure that takes Student , Grade , and StartDate , and I would like it to check to make sure these values are not duplicates insert the record if it's not a duplicate if there is an existing student record, and it has a EndDate = NULL , then update that record with the StartDate of the new record. For