Saturday, November 24, 2012 5:13 PM
Hi Every one,
I need Help to how to write a Query following below logic
----- Get all jobs schedules between start date and 24 hrs from JobSchedule table
Jobschedule id identity column
Job id int pk
Schedule day ----à Monday,Tuesday,Wednesday etc
Schedule time--à11:00,11:30 etc
Saturday, November 24, 2012 6:10 PM
For this type of question it is a good idea to post:
1) CREATE TABLE statements for your table.
2) INSERT statements with sample data.
3) The desired result given the sample.
4) A brief description of the business rules.
5) Which version of SQL Server you are using.
This helps to clarify what you are looking for, and it's simple to copy and paste into a query to develop a tested solution.
Erland Sommarskog, SQL Server MVP, firstname.lastname@example.org
- Proposed As Answer by Kalman TothMicrosoft Community Contributor, Moderator Sunday, November 25, 2012 10:43 AM
Sunday, November 25, 2012 7:34 AMAnswerer
In addition please expand a little bit on jobs schedules between start date and 24 hrs?
Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Blog: Large scale of database and data cleansing
MS SQL Consultants: Improves MS SQL Database Performance
Sunday, November 25, 2012 1:15 PMPlease post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. If you know how, follow ISO-11179 data element naming conventions and formatting rules. Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums.
Sample data is also a good idea, along with clear specifications. It is very hard to debug code when you do not let us see it.
The little you did post is awful. RDBMS does not have a magical, generic "id" buiilt from a PHYSICAL count of insertion attempts to the disk. We have a DATETIME2(0) datatype, yet you split the single value into two columns. You put audit data in the table being audited, so it can be lost if the data is destroyed. This is silly and illegal.
Want to stop and read a book on RDBMS first, then ask questions?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL