|
Tim Carmichael wrote: If this is ... It's actually a homework question.
|
|
|
|
|
|
1)
∏{order#} (∑{datediff(ODate,Today)>14}
(REN o(ORDER) θ{o.order#=ons.order#} REN ons( ∏ {oredr#} (ORDER) - ∏ {oredr#} (SHIPMENT))))
2)
∏{CName} (REN c(CUSTOMER) θ{c.Cust#=onp.Cust#} REN onp( ∏ {Cust#} (CUSTOMER) - ∏ {Cust#} (ORDER)))
Operators used:
∑ is SELECT
∏ is PROJECT
θ is THETA JOIN
- is SET DIFFERENCE
REN is RENAME
{} is for enclosing expressions
|
|
|
|
|
Hi
I have executed package through command line its working fine. The same package executed in SQL SERVER AGENT throwing exception. Please find the exception below
Executed as user: NT Service\SQLSERVERAGENT. Microsoft (R) SQL Server Execute Package Utility Version 11.0.2100.60 for 64-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 5:13:13 AM Could not load package "C:\Packages\ITEMMASTER_IMPORT.dtsx" because of error 0x80131534. Description: The package failed to load due to error 0x80131534 "(null)". This occurs when CPackage::LoadFromXML fails. Source: {C45D90C3-5C86-4B77-B2D6-6A6261230041} Started: 5:13:13 AM Finished: 5:13:13 AM Elapsed: 0.078 seconds. Process Exit Code 5. The step failed.
|
|
|
|
|
Does the user "SQLSERVERAGENT" have the same rights as the user that is using the command-line?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
hello,
I have 2 MSSQLDB 2008 same version and installed on simillar enviroment ,i implement Transactiona Replication but each time need reinitalizing subscriber and generate new snapshoot to syncronize the data.
if there is solution to do it automaticlly knowing i tried same implemntation on test DB and work normally.
Thank you.
|
|
|
|
|
I've written lots of small applications where I work, developing the databases in SQL Server, which is my forte, and the front ends in ASP.NET. When I've been doing it all myself it's been easy because, as the application developer, I know the databases and have no trouble writing ad-hoc queries in the application or, more often, calling Stored Procedures that I've written, knowing what parameters are required, and so on.
But now I'm embarking on a much larger project, for which we'll be hiring developers to write the application. I'm just writing the database. My plan was to write well-documented Stored Procedures to perform every operation required on the database - inserting, updating, deleting, retrieving records, and so on, and then letting the developers just call these procedures from the application without them needing to know the database's structure, effectively creating an API. If I have time, I also intended to write web services as an intermediate level for them to use, so that they call these services rather than the Stored Procedures. I don't know how much benefit there is to doing this for the core .NET application, but since we intend to also create mobile apps down the line, the same services could be used for those as well.
This morning I've been reading about CRUD and writing RESTful services and so on (not completely understanding it all), and now I'm starting to wonder if I'm missing something. I want to set up an API, so to speak, that will seem sensible, easy to work with and perhaps even familiar to our experienced developers after they are recruited, but since this is the first time I've worked in this way I'm not really sure what they'll be expecting. I want to work in line with best practice to deliver a successful project and an excellent product. Does my proposed plan fit this requirement, or should I be doing something else?
EDIT: Maybe I'd get more useful replies if this was in the Web Development thread? Can a mod move it?
|
|
|
|
|
Design and Architecture would probably be a better forum but the same people will look at it as here...
If you are confident at designing the data structure and getting it right then I would suggest doing everything up to the WCF/Service layer. However as you sound like a particularly advanced power user I would probably look at getting a senior dev to work with you on the database and service and when that is in place get the UI devs on board to complete the application.
Be prepared to change your design as dictated by the UI, forget the crap about agile you may hear, the best apps are built by people who recognise a design error early and fix it NOW.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for the tips. I definitely agree that being flexible, as far as possible, and changing things in response to design challenges that arise is important.
|
|
|
|
|
phil2415 wrote: This morning I've been reading about CRUD and writing RESTful services and so on (not completely understanding it all)
Rest applies to the application server not to the database. The application server deals with a data model where objects in that often but not always map to tables in the database. It that 'not always' part that means that the application server should have its own data model and then map that to the database.
The stored procedures provide the access layer to the database. Far as I am concerned they (stored procs) server the same purpose as any other application layer so I am in favor of them. Additionally I consider the permissions possible with them a win.
phil2415 wrote: I'm not really sure what they'll be expecting.
First thing of course is that someone, somewhere needs to come up with a data model. Doesn't need to be formal but a team (more than one person) can't work without a division of labor and so they need to target a data model and so do you. You should of course be prepared to participate in that process. You might even be the sole person given that you have experience both in database and application development.
Your role other than that would be in insuring that the data model is not going to impose problems such as performance. Then normal DDL development with any additional database tests (archive, back up, etc) that would normally be identified in any production system.
Depending on the team/project you might also be in charge of writing the application side abstraction layer - the thing that interfaces with the stored proc.
Of course one potential problem with all of the above is that one of the incoming people already has an idea how the database should be done and it doesn't jive with your view.
|
|
|
|
|
Thanks for the advice. I'm already devising the data model for the database. My idea is that before the developers even arrive, the bulk of the database will be written and SPs in place for handling fundamental operations. I've no doubt that changes will need to be made once the development team starts, but hopefully the basic foundations should be fairly sound.
|
|
|
|
|
I agree with developing up through the Web Service part as an API so the application developers don't need to even know there's a database involved.
<YouProbablyAlreadyKnowThis>
Be sure that at the API level the methods are written as high-level application operations, rather than as specific database operations.
E.g. if a transaction requires two INSERTs and an UPDATE, those details should be hidden in one method rather than requiring the application developers to know that they need to call three methods and in what order.
</YouProbablyAlreadyKnowThis>
|
|
|
|
|
Love the <youprobablyalreadyknowthis> tag, I might have to steal that some time! All the more pleased with it given that I actually did know it!
|
|
|
|
|
Hi,
I have expiry_date field. I am using nthis code to get expired this month list.
SELECT contracts.contract_id, contract_types.type_name, contracts.contract_name, contracts.supplier, contracts.contact_name, contracts.contact_number, contracts.expiry_date, contracts.reminder FROM contracts
JOIN contract_types ON contract_types.type_id = contracts.type
WHERE MONTH(contracts.expiry_date) = MONTH(NOW()) AND YEAR(contracts.expiry_date) = YEAR(NOW());
Now, I would like to get list of expiring next month. How can I do this? what if current month is 12? then Next Month will be 1 and Year will also be changed?
Kindly advise
Technology News @ www.JassimRahma.com
|
|
|
|
|
|
this solved my problem.
WHERE MONTH(contracts.expiry_date) = MONTH(DATE_ADD(DATE(NOW()), INTERVAL 1 MONTH)) AND YEAR(contracts.expiry_date) = YEAR(DATE_ADD(DATE(NOW()), INTERVAL 1 MONTH));
Thank you so much
Technology News @ www.JassimRahma.com
|
|
|
|
|
This may be easier to read and you won't need to do calculations on years:
WHERE DATEDIFF(mm,contracts.expiry_date,DATE_ADD(NOW(), INTERVAL 1 MONTH)) = 1
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
Hm, depends on the details of his requirements.
If I see it correctly, your query will select all data within one month from now. His question looked like he needed the data of next calendar month.
|
|
|
|
|
Try the query out - you will find that it selects the data from next calendar month
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
modified 13-Aug-14 5:22am.
|
|
|
|
|
Have a look at the DATEDIFF function.
E.g.
select datediff(mm,getdate(),getdate()+180)
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
modified 12-Aug-14 4:15am.
|
|
|
|
|
Hi, i've been looking at moving one of our processed from excel (+vba) into t-sql to make life easier but am stuck.
We have lots of tasks that are assigned to work groups which we want to distribute evenly across the work groups. This is a simple task for ntile.. However when these tasks are no longer required they are removed which leaves the groups uneven. When new tasks are added we want to still try to keep these groups balanced.
EG Existing groups :
GroupName - Task Count
Group1 - 1000
Group2 - 999
Group3 - 998
If we were to add 6 new tasks they would have more assigned to Group 2 & 3 as they have less than group 1.
Task 1 - Group3
Task 2 - Group3
Task 3 -Group2
Task 4 - Group1
Task 5 - Group2
Task 6 - Group3
Sample tables
Create table GroupTable
(GroupID int, Name varchar(200) )
Insert into GroupTable values (1,'Group1')
Insert into GroupTable values (2,'Group2')
Insert into GroupTable values (3,'Group3')
Create table Jobs(jobid int identity(1,1), name varchar(100),Groupid int)
Insert into Jobs(name,Groupid) values ('Task1',1)
Insert into Jobs(name,Groupid) values ('Task2',1)
Insert into Jobs(name,Groupid) values ('Task3',1)
Insert into Jobs(name,Groupid) values ('Task4',1)
Insert into Jobs(name,Groupid) values ('Task5',2)
Insert into Jobs(name,Groupid) values ('Task6',2)
Insert into Jobs(name,Groupid) values ('Task6',2)
Insert into Jobs(name,Groupid) values ('Task7',3)
Insert into Jobs(name) values ('TaskA')
Insert into Jobs(name) values ('TaskB')
Insert into Jobs(name) values ('TaskC')
Insert into Jobs(name) values ('TaskD')
Insert into Jobs(name) values ('TaskE')
Insert into Jobs(name) values ('TaskF')
This gives us 6 unassigned tasks and a uneven group assignment
GROUPNAME TASK_COUNT
<none> 6
Group1 4
Group2 3
Group3 2
This means the new tasks will be assigned like this
TaskA - Group3
TaskB - Group3
TaskC - Group2
TaskD - Group1
TaskE - Group2
TaskF - Group3
Can anyone help?
Thanks
Dan
|
|
|
|
|
Insert new tasks like this:
insert into jobs
select top(1)
@TaskName,
groupid
from jobs
group by groupid
order by count(*),groupid
|
|
|
|
|
Good Day All
i have a Following Query
1) Query 1
DECLARE @FINALVAUE VARCHAR(MAX) = (Convert(decimal,@CAUSATIVE_FACTORS_ID) - 1) + Convert(decimal,@LU_PERCENTAGE_FAILURE_IN_SAMPLE_ID) + Convert(decimal,@LU_REPORTING_HISTORY_ID)
PRINT @FINALVAUE
The Calculation is like this
2) Query 2
DECLARE @FINAL VARCHAR(MAX)
SET @FINAL= (4-1) + 0.08 + 0.2
SELECT @FINAL
The first Query i am retrieving values from the Variables which are varchar and converting to decimal and doing the calculations. and the second Query i am just taking the value as is. i used this to debug in trying to solve this problem. My problem here in the first Query in the @FINALVAUE variable the answer is "3" and in the second Query the answer is "3.28"
, i want the first Query to display the same value which is "3.28"
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
CONVERT(DECIMAL, value) will convert without decimal palces ...
Use something like CONVERT(DECIMAL(4, 2), value)...
http://msdn.microsoft.com/en-us/library/ms187746.aspx[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Thanks that saved the day.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|