sql-server-2014

Subquery returned more than 1 value. (Insert within a while loop)

♀尐吖头ヾ 提交于 2019-12-12 02:19:13
问题 DECLARE @int int DECLARE @saveamount int DECLARE @savedate datetime SET @int=1 SET @saveamount=400 SET @savedate= '20160101 13:00:00.00' WHILE @int<=357 BEGIN INSERT INTO watersave (reservoirid, amount, savedate) VALUES (1,@saveamount,@savedate) SET @int=@int+1 SET @saveamount=@saveamount+(SELECT ROUND((6 - 12 * RAND()), 0)) SET @savedate=@savedate+1 END Trying to insert for test purposes but stacked with the subquery returned more than 1 value error on line 9. Any idea? Regards 回答1: Since

How to add parameters for multiple agents to exclude from the SSRS Stats Report

走远了吗. 提交于 2019-12-12 02:16:55
问题 Scenario: I have a report that pulls up stats for agents for a certain date range (usually the same day, yesterday) which I've set as parameters. I've built the report in Visual Studio Report builder and the report works great. Challenge: Some agents are taken off calls and work on emails instead that day. So, though they are logged in, they can't be added to the call queue stats. Need: I need to add parameters which can select agents from the drop down (Ctrl+select) and have the report run

Running composite query on SQL server 2014 does not return result set

岁酱吖の 提交于 2019-12-12 01:55:52
问题 We have the following code: Connection conn = null; String dbURL = "jdbc:sqlserver://DBDerver details here"; String user = "user name"; String pass = "password@123"; try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); conn = DriverManager.getConnection(dbURL, user, pass); String sql = "update Table1" + "set DBID = DBID+1 where TABLENAME = '" + "Table2" + "';" + "select DBID from Table 1 where TABLENAME = '" + "Table 2" + "'"; System.out.println("generateId(), SQL = " + sql);

Getting a value from stored procedure within a stored procedure

╄→гoц情女王★ 提交于 2019-12-12 01:42:53
问题 I have a stored procedure which returns an XML file. At the moment some calculations are done in XSL but I would like to do these within the database using another stored procedure. (adding the result of that calculation to the XML) ALTER PROCEDURE [dbo].[app_Get_Phone_And_Tariffs] -- Add the parameters for the stored procedure here @phone nvarchar(150) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert

maintaining a custom auto increment column

↘锁芯ラ 提交于 2019-12-11 18:58:51
问题 I have a table with ID (identity) and XID (int) which is my custom auto increment column. I am using an instead of insert trigger to maintain XID, but I am getting duplicates. table xtable (ID identity, XID int) trigger - instead of insert insert into [xtable] (XID) select [x].[NextavailableID] from inserted [i] cross apply ( select coalesce(max([t].[XID]), 0) + 1 [NextavailableID] from [xtable] [t] ) [x]; Assuming inserted = 1 row. This trigger doesn't prevent duplicates in the XID column.

Insert first table into temp table when procedure returns multiple tables in SQL Server 2014

我们两清 提交于 2019-12-11 18:46:03
问题 I have 2 procedures proc_Data , proc_FetchData . I'm calling proc_Data from within proc_FetchData . proc_Data returns 2 tables. I want to insert only the first table into a temp table in my second procedure and use it further. The problem is I cannot change proc_Data in any way as this is a very old procedure used in various parts of our application. Sample code for reference create procedure proc_Data As Begin select 'Apples' select 'Oranges','Grapes' end create procedure proc_FetchData As

can we get value of above cell of same column of table in ssrs report builder? How?

时光毁灭记忆、已成空白 提交于 2019-12-11 17:58:10
问题 I have edited my question and replace the previous explanation with new one. I think I could't explain my problem clearly before. here is my scenario: Col1 |Col2 |Col3 |Col4 |Col5 | Col6 ------|------|------|-------|------| 3333.00 (Table 1) ------|------|------| 15.00| 0.00| 3348.00 (Table 2) ------|------|------| 0.00|550.00| 2798.00 (Table 2) Sub ToTal:-----| 15.00|550.00| 2798.00 (Table 3) In this report value (3,333.00) of Table 1 is Opening Balance. For Table2 and Table3, col4 is

How to sum column wise and row-wise in SQL Server?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 17:11:26
问题 Please look at the below What I am looking for is That is Total should happen both at the row and column level My attempt declare @t table(aggrementid varchar(20), bom_pos int, bucket int null, paymentstatus varchar(50)) insert into @t select '1', 3000, null, null union all select '2', 3000, 0, 'Non-Delinquient' union all select '3', 4000, 0, 'Non-Delinquient' union all select '4', 5000, 0, 'Non-Delinquient' union all select '5', 7000, 0, 'NPA' union all select '6', 8000, 1, 'NPA' Select

SQL Server 2014 Type DATE is not a defined system type

旧城冷巷雨未停 提交于 2019-12-11 17:05:06
问题 I am using the below query in the stored procedure SELECT @ICOUNT = COUNT(*) FROM MESSAGES WHERE CAST(CREATEDDATE AS DATE) >= CAST(@STARTDATE AS DATE) AND CAST(CREATEDDATE AS DATE) <= CAST(@ENDDATE AS DATE); Its working correctly in Sql Server 2008, Where as in Sql Server 2014 I'm facing the below error: Type DATE is not a defined system type. 回答1: If the compatibility level is 90, it means you are not working with SQL Server 2014, since it does not support this compatibility level (lowest

Laravel 5.4 return wrong last inserted id

安稳与你 提交于 2019-12-11 16:58:41
问题 I am using SQL SERVER 2014 and Laravel 5.4 I habe a tble named tblMyUser whose primary key MyUserId Now I want to insert one row in table and get Last Insered Id but this return wrong id with respect to sql server tblMyUser table This is my Model MyUser.php namespace App; use DB; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class MyUser extends Authenticatable { use Notifiable; protected $table = 'tblMyUser'; protected $primaryKey =