sql-server-2012

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

SQL Server Agent job dependency

跟風遠走 提交于 2019-12-12 02:19:10
问题 We have a 4h datawarehouse job that runs every 4h on 4h schedule. We want to create a new 'daily' schedule and have some processes run out of hours. However, if when the daily job comes to run and the 4h job is still running, I would like it to wait for the 4h job to complete, then run (or have a specified duration). I haven't decided which is best yet... How is this possible? Thanks! Please do not suggest 3rd party options as I have no control over the infrastructure. 回答1: Please maintain

How to use between clause on a nvarchar?

纵然是瞬间 提交于 2019-12-12 02:13:37
问题 I have a table which is attached in image here sample table values I want that this conditions will return one row where Vendor_Value_Table.Feature_ID in (17,19) and value_text like 'Dhol Wala$Shahnai Wala' and value_text between 0 and 100` because this represent to single vendor_id but the problem is datatype of Value_Text Column is nvarchar(max) how to do that kindly suggest. 回答1: Assuming you wont have ANY NEGATIVE NUMBER You must cast nvarchar to Int for your between clause and set a

Script to copy database between servers

﹥>﹥吖頭↗ 提交于 2019-12-12 02:12:41
问题 The answer from Spike here was very nearly exactly what we needed. The only hurdle is how to have the backup run on one server and the restore run on another through linked server all in one script ? It must be a script that can be turned into a stored procedure that's fed only source and destination DB names. Does it present a problem that the source server is SQL Server Express 2012 whereas the destination is the full version? It has to be a script that can run against any DB by just

SQL Server : how many days each item was in each state

我的梦境 提交于 2019-12-12 01:57:56
问题 Given a table that stores every revision for every item. For example: +--------+----------+---------------+--------+---------------------+ | ItemId | Revision | PreviousState | State | DateChanged | +--------+----------+---------------+--------+---------------------+ | 1 | 1 | NULL | New | 2014-11-13 10:00:00 | | 1 | 2 | New | Active | 2014-11-15 10:00:00 | | 1 | 3 | Active | New | 2014-11-17 10:00:00 | | 1 | 4 | New | Active | 2014-11-19 10:00:00 | | 1 | 5 | New | Active | 2014-11-20 10:00

Performing calculations in sql

烂漫一生 提交于 2019-12-12 01:45:39
问题 I have the following SQL query; SELECT DISTINCT Contacts.ContactId, ROUND(SUM(LandingDetails.Quantity * LandingDetails.UnitPrice), 2) AS Owed, SocietyMemberships.WeeklyDeductionRate, SocietyMemberships.FromMinimumReturn, Deductions.DeductionRate FROM dbo.LandingDetails INNER JOIN dbo.LandingHeaders ON LandingDetails.LandingId = LandingHeaders.LandingId INNER JOIN dbo.Vessels ON LandingHeaders.VesselId = Vessels.VesselId INNER JOIN dbo.Contacts ON Vessels.OwnerId = Contacts.ContactId INNER

Why i can not find value is numeric conditional in dqs domain rule?

穿精又带淫゛_ 提交于 2019-12-12 01:39:27
问题 I'm beginner in Sql server Data quality services and for that purpose read this tutorial from microsoft MSDN site: Create a Domain Rule But in the my data quality can not find value is numeric condition in domain build rule,what happen?how can i solve that problem?thanks for all. 来源: https://stackoverflow.com/questions/38990258/why-i-can-not-find-value-is-numeric-conditional-in-dqs-domain-rule

Query for matching IP address in SQL Server

别等时光非礼了梦想. 提交于 2019-12-12 01:22:33
问题 I am trying to match IP addresses. The input IP address can be " 5.1.82.1 ". So, I am matching like first part of input IP address with all the IP address in database that start with 5 . My query is like following SELECT top 1 PARSENAME(ipaddress, 4) AS firstpart, ipaddress FROM IPs WHERE (Country = 'pk') AND (PARSENAME(ipaddress, 4) <= '5') ORDER BY Expr2 DESC The above query results all the IP addresses that start with 5 . Now I need to match the second part of the address which is " 1 "

How to give page break in SSRS

大城市里の小女人 提交于 2019-12-12 01:13:39
问题 I am making a very simple report in SSRS. I am trying to do the following: On page 1 display following text THIS IS PAGE 1 On page 2 display following text THIS IS PAGE 2 I added "Text" field in my report in which I have set the value field to "THIS IS PAGE 1". But I can't find any option to add page break after it. How do I give page break? 回答1: I am not sure what is the purpose of having Page Break for you without any content.. but still i tried by adding a table on a report with one column

How to accurately figure percentage of a finite total

六眼飞鱼酱① 提交于 2019-12-12 01:12:28
问题 I’m in the process of creating a report that will tell end users what percentage of a gridview (the total number of records is a finite number) has been completed in a given month. I have a gridview with records that I’ve imported and users have to go into each record and update a couple of fields. I’m attempting to create a report tell me what percentage of the grand total of records was completed in a given month. All I need is the percentage. The grand total is (for this example) is 2000.