Determine Quarter End And Beginning Dates

Jul 23, 2005

Hello,

I have a query that I would like to schedule in DTS. The criteria of
this query checks for records in the table that are within the current
quarter. Here is what I have.

WHERE submit_date BETWEEN '01/01/2005' AND '03/31/2005'

I would like to dynamically generate the Quarter End and Quarter
Beginning dates within my where clause based on the date that DTWS
package is being executed on. Can anyone show me how this can be
accomplished?


Thank You.

View 3 Replies


ADVERTISEMENT

Getting Year/quarter/month/day In The Right Order (was Dates)

Feb 28, 2005

I have a program that calls queries (OLAP system) the system includes a dimension of date: Year, Quater, Month, Week

When the result appears in the table, it is not in order? Only the year is in oredr and after that each heirachy is wrong and not in order....not sure how to do this!!!

any help would be grateful!!! not sure what I should be looking at.....

View 14 Replies View Related

Transact SQL :: How To Get Four Quarter End Dates Based On Given Date

Jun 3, 2015

I have a simple following table which is having only one date column.

CREATE TABLE TEST_DATE
(
InputDate DATE
)
GO
INSERT INTO TEST_DATE VALUES('01-01-2015')
INSERT INTO TEST_DATE VALUES('06-25-2015')
INSERT INTO TEST_DATE VALUES('11-23-2014')
GO
SELECT * FROM TEST_DATE;

And the expected out put would be as follows:

I want to derive a Four Quarter End Date based on Date selected.

For Example if i select 01-01-2015 then
First Quarter End Date would be Previous Quarter End Date
Second Quarter End Date would be Current Quarter End Date
Third Quarter End Date would be Next Quarter End Date
Fourth Quarter End Date would be Next +1 Quarter End Date Like that

View 9 Replies View Related

Analysis :: How To Find Quarter / Year / Month / Semester Start And End Dates In MDX

Sep 24, 2015

I have a date dimension set in the SSAS Cube. I have been trying get quarter,year,month,semester start and end dates using ClosingPeriod() and OpeningPeriod() functions but not getting the exact value. How the get correct dates for a given date.

View 2 Replies View Related

Reporting Services :: Range Bar Chart - X Axis Dates Label Format Need To Be Converted To Quarter

Sep 4, 2014

I have created range bar chart and I am not able to achieve the following tasks.

1. Change X-axis Label Format to Quarter:

I have x-axis with dates and y axis of project groups. I have changed x-axis interval type = month and interval=3.
   
Set the Maximum =  Max(ProjectEndDate) and Minimum = Min(ProjectStartDate).

Now my chart showing 3 months x-axis interval dates in mm/dd/yyyy format. I want to change this interval date format to Quarter. The problem is LabelsFormat property is not recognize  the "=Q or q or quarter" and also not accepting the expressions. How can I achieve this?

2. Placing series side by side when it is not overlapping

I want to place the same group series side by side only when the previous project end date is less than next project start date, otherwise place the next project to next row. How can I achieve this?

View 2 Replies View Related

SQL Server 2012 :: Rollover Prior Quarter Data To New Quarter In A Table - Output Identity Values

Jun 5, 2014

I have a process to rollover prior quarter data to new quarter in a table.

For example, i have a table with (col1, col2, year, qtr) with data like ( Note: col1 is identity(1,1) )

1,'today',2014,1
2,'tomorrow,2014,1
3,'friday',2014,1

Now when i run my process, above 3 records will be rolled over new quarter 2014 Q2 and the table will be like

1,'today',2014,1
2,'tomorrow,2014,1
3,'friday',2014,1
4,'today',2014,2
5,'tomorrow,2014,2
6,'friday',2014,2

Row 1 with identity 1 has rolled over to new quarter row 4 with identity 4 ( qtr fields are changed )
Row 2 with identity 2 has rolled over to new quarter row 5 with identity 5. Same with last row as well.

Here, i have another table called "ident_map" with columns like (old identity, new identity ) and during rollover i am supposed to load ident_map table with old and new identity. So after rollover is complete, ident_map table should look like

1,4
2,5
3,6

I know using output clause I can capture the new identity values. 4,5,6 in this case. But is there any way to capture both old identity and new identity during rollover so that i can load the ident_map table with old and new identity.

View 9 Replies View Related

T-SQL (SS2K8) :: How Datediff Determine Difference Between Two Dates

Jan 19, 2015

select datediff(wk, '2015-01-11', '2015-01-19') returns 1 (shouldn't it return 2?)
select datediff(wk, '2015-01-10', '2015-01-19') returns 2

View 5 Replies View Related

T-SQL (SS2K8) :: Select Past 3 Dates And Determine If 1st And 3rd Are Within Timeframe?

Sep 7, 2014

I have a table with addresses and activity dates. I need to be able to retrieve the past 3 activity dates and see if the first and last occurred within 15 days. If so, I need to flag them.

Using max date gets me the last date but not the previous two. I was trying to use top 3 in desc order and that didnt seem to work either.

View 9 Replies View Related

Sql For Financial Reporting Periods This Month, Last Month, This Quarter, Last Quarter, This Year, Last Year

Oct 26, 2006

Does anyone know of a way to use a funtion for returning records based on fiscal reporting periods like Quickbooks uses for example "This Month", "Last Month", "This Quarter", "Last Quarter", "This Year", "Last Year". While I realize that I can create a very long date time parsing routine  for this but it is not very elegant or useful. I thought there might be a way to do this already with an existing function.I have created a stored procedure that I pass a @ViewRange Parameter to and it returns the records that I want but I need this ability in several procedures and wanted to turn it into a stored procedure.IF @ViewRange = 'This Month' SELECT TOP 20 Customer.LastName AS Customer, SUM(Sales.AmtCharge) AS Amount FROM Customer INNER JOIN Sales ON Customer.CustNo = Sales.CustNo WHERE (MONTH(Sales.InvDate) = MONTH(CURRENT_TIMESTAMP)) AND (YEAR(Sales.InvDate) = YEAR(CURRENT_TIMESTAMP)) GROUP BY Customer.LastName ORDER BY SUM(Sales.AmtCharge) DESC;IF @ViewRange = 'Last Month' SELECT TOP 20 Customer.LastName AS Customer, Sum(Sales.AmtCharge) AS Amount FROM Customer INNER JOIN Sales ON Customer.CustNo = Sales.CustNo WHERE(MONTH(Sales.InvDate) = MONTH(CURRENT_TIMESTAMP) - 1) And (YEAR(Sales.InvDate) = YEAR(CURRENT_TIMESTAMP)) GROUP BY Customer.LastName ORDER BY Sum(Sales.AmtCharge) DESC; Any ideas? 

View 8 Replies View Related

Beginning With SQL

Mar 5, 2001

Hello,

I have been using Access for quite some time now, and am very comfortable with it. I would like to take the next step though, and start working with SQL server.
What do I need to begin? Windows NT? Which version of SQL? enterprise or professional? (I noticed it's very expensive) Any other things I need to know before I begin?

Thank you,
Carrie

View 1 Replies View Related

Beginning MDX

Jan 10, 2007

I'm pretty new at Mdx , so bare with me. I want to make a calculated member called Occupant Fatalities.

The occupant fatalities looks like this right now:

( [Measures].[Fatalities] , [Crash Person].[Person Type].&[Driver])



Now the question is , How do i add another person type to this calculated member. It wont work when i do this.

( [Measures].[Fatalities] , [Crash Person].[Person Type].&[Driver].&[Passenger])

whats the code for having more then one member from a hierachy? or having 2 members from different hierarchies?



any help is appreciated.

View 1 Replies View Related

Beginning SQL

Mar 2, 2006

I purchased SQL Server 2005 and intend to take a class this month. I have installed it. How do I get started trying it out? I took an online tutorial, but I don't understand the mechanics of accessing the db to start with or if I even have a db to work with. Any suggestions?

View 1 Replies View Related

Beginning SQL

Aug 2, 2007

Hello, I would like to be able to construct a small SQL data base with Visual Basic.Net code for practice. I want to be able to add to the data base, subtract from the data base, perform all Sql procedures ( Select, delete, etc.) I would also like to include the ExecuteNonQuery, ExecuteScalar, and ExecuteReader methods. Can anybody out there recommend a good tutorial for me? Thank you so much. MarcAbelson_2000@yahoo.com

View 1 Replies View Related

Beginning SQL Server

Dec 22, 2006

Dan Tuohy writes "Hi Guys, im working for a company who have asked me to create a database to store there client information. They have totally left everything up to me and are aware that i know little about SQL server. I have downloaded SQL Server Express edition for use as the database engine. The server that the company have is a Linux server but the workstation machines are Windows :s

I am overwhelmed by the pro's and cons of SQL Server, Oracle blah blah blah lol.

Can you give me some pointers, ie books that would guide me step by step, or just some helpfull points to get me started?

Thanks ever so much,

Dan Tuohy"

View 2 Replies View Related

How To Learn Sql From Beginning?

Jul 23, 2005

How to learn sql from beginning?I would like to learn sql but don't have a clue.can you help me?where would I start?

View 1 Replies View Related

Beginning With SQL Express

Oct 10, 2006

Hi everyone,

I want to set a database which will be made of two parts:

- One main set of files which is shared among users

- Another set of files which is proper to each users and will be mainly used for processing infos.

Because I must support Windows 2000 and XP as O/S platforms, I can't use SQL Everywhere. It seems that I'm stuck with SQL Express. My questions are the following:

- Can SQL Express manage database files with variable namepath?

- How can I configure SQL Express so that such a file may reside on a dynamically configurable path, I mean, which would be configured by application?

Many thanks in advance for your help,

Stéphane

View 12 Replies View Related

How Do I Inser New Rows On In The Beginning

Aug 7, 2004

I have a table .. has 3 fields.. first is ID (Autoincrement) the other two are texts like
ID | Text1 |Text2
1 |aaa |aaa2
2 |bbb |bbb2
3 |ccc |ccc2

etc..
now there is a change in my requrement I need to add 4 more rows at the beginning like.
ID | Text1 | Tex2
1 |xxx |xxx2
2 |yyy |yyy2
.,
.
5 |aaa |aaa2
6 |bbb |bbb2

How can I add rows in the beginning by auto adjusting the ID colum.
I'm using the enterptice manager to do this>.
HELP!

View 1 Replies View Related

Beginning SQL Server Book?

Jul 23, 2005

Greetings:I would like to ask for recommendations for a good beginning book onSQL Server. My web host offers a 100MB SQL Server database as part ofthe package, and I'd like to use the feature to learn.I am proficient in Access and familiar with basic connectivity to itvia ASP. I don't have my own license for SQL Server (and currentlycan't afford one) so all development will need to be done byinterfacing with the remote database. As such, I won't need a lot ofexplanation regarding installation and software setup.Does anyone here know of a good study resource for someone in thisscenario?Many thanks in advance,Kay

View 5 Replies View Related

Beginning With SQL Server Compact

Dec 12, 2006

Hi all,
I am just starting to look into this interesting piece of technology, but am a little confused on how this works. I apologize if this has been asked earlier. My question is with this specific SQL server distribution, what is being used as the front end (to create and view your database & tables)? I read that SQL Server Compact Edition RC1 will have runtime only - How will you then get an application to point to a database via SQL compact?

View 3 Replies View Related

Install Wizard Stops At The Very Beginning

Nov 23, 1999

We are currently trying to install SQL Server 7 Enterprise edition using MS SELECT CDs. The install wizard stops at the beginning telling us that the used CD can only be used to install SQL Server clients with this computer although we used exactly this CD-ROM to install all other SQL Servers, too.

Did anybody have the same problem and knows what the reason for the abortion is?

Thanks
Axel

View 2 Replies View Related

Double Quote In Beginning Of Record

Dec 14, 2005

Some of my records starts with a double quote, when I do a search for all records starting with A I can get all except the ones that start "A fine day ...

View 4 Replies View Related

Beginning SSIS - Sharepoint And Excel

Feb 14, 2006

Hi all, I have never used SSIS before, but am looking to use it in this aspect:

1) A user uploads an Excel file into Sharepoint. This will be through a Document Library in a Sharepoint page.

2) When this file is uploaded, I'd like SSIS to notice there is a new file and process it - it will pull information from the Excel file, put it into a database, and - if this is possible - delete the new file.

3) This is iffy. Can SSIS then generate an InfoPath document  from the information stored in the database? If not, I can just have a InfoPath query form.

I'd just like to know if this is possible. If you have any helpful links, please let me know - I would greatly appreciate it!

Thanks,

James

View 8 Replies View Related

DTS.Pipeline: Validation Phase Is Beginning.

Nov 19, 2007

Hi, My package hangs and the log says DTS.Pipeline: Validation phase is beginning. Any ideas why this is happennig? This same package runs fine when I run it without turning on the transaction.

View 4 Replies View Related

Query By Quarter

May 19, 2004

Hello, everyone:

There is a table named INCOME that has INCOME column for each day and DATE column starting from Aug. 29 1980. How to calculate income summary by each quarter? Thanks.

ZYT

View 9 Replies View Related

Calculate Quarter

Jan 28, 2007

Hi,

I need to retrieve both Mont and Quarter from an MS SQL server field containing a date as ''01/01/2007 12:10:00'.

Retrieving the Month is working properly, but getting some sql error with the Quarter function.

I will appreciate if someone can indicate me how should I do in order to retrieve the Quarter from a date.

To retrieve the month, I am using:

& "MONTH(STOCK.VALUEDATE) AS 'Month'"


To retrieve the Quarter, I am trying (but getting error):

& "QUARTER(STOCK.VALUEDATE) AS Quarter"
Thanks,

Aldo.

View 3 Replies View Related

Beginning Question About Coping/moving A Sql Database

Sep 3, 2007

First, I consider myself a novice in Mssql. I've recently began the revision of a website that uses MS Sql Server 2000. In a effort to set up a working environment on my pc, I asked to get a copy of the sql server database. The response was something like "I'm not going to do that!" or "that's too much effort" which left me baffled. Furthermore, the size of the database shouldn't be the issue.

In Access all that is needed is the .mdb file to copy a database. In Sql Server is it that more complicated? My questions are as follows

How does someone copy a sql server database to another pc?
Were they expecting that I remotely test with Sql Server? Is that possible or practical? Isn't it prefered to have the db localized?

Thanks sincerely,
Breck

View 4 Replies View Related

Osql - Blank Space Beginning Of Line

Feb 2, 2007

Hi,
I'm running the osql below from a batch file:

%SQLPath%osql -U%DBUser% -P%DBPswd% -S%SQLServer% -d%Gatewaydb% -w256 -b -n; -c -h-1 -iBatchScriptsSQL_Get_Create_Batch1.sql -oZ:mboxmmis835increate_835_1.bat

My output file comes out fine with one exception, there is a blank space at the beginning of each line. Is there a way to remove this ? One suggestion I have seen is to do this with BCP instaed of osql but I don't know if BCP can "run" my "SQL_Get_Create_Batch1.sql" file above. The ".sql" creates a temporary table and then does a select.

Thanks,
J

View 8 Replies View Related

[DTS.Pipeline] Information: Pre-Execute Phase Is Beginning

Nov 28, 2007

Hi,

I have a SSIS package which pumps data from one server to other without any additional steps. There are 11 tables for which data is transferred. And this packages runs fine on two different environments but fails in one environment i.e. on SIT.

It doesn't throw any error and every time stops at the below step

[DTS.Pipeline] Information: Pre-Execute phase is beginning.

Progress: Pre-Execute - 0 percent complete
Progress: Pre-Execute - 1 percent complete
Progress: Pre-Execute - 2 percent complete
Progress: Pre-Execute - 3 percent complete
Progress: Pre-Execute - 4 percent complete
Progress: Pre-Execute - 5 percent complete
Progress: Pre-Execute - 6 percent complete
Progress: Pre-Execute - 7 percent complete


It doesn't complete neither throws an error. Any pointers on what the problem could be

Thanks

View 2 Replies View Related

Package Stuck On Pre-Execute Phase Is Beginning.

Jun 8, 2007

Hi all,



I have a monster SQL query (SQL Server connection) that I'm trying to export to flat file. My package appears to just stick on the "Pre-Execute phase is beginning" stage. (I left it running overnight, and it's still going... no error message, I think it's just hung. If I include a "Top 10" in the my source query it completes without a problem. I'm wondering if it's an out-of-memory issue, but when I've run into this in the past there have been error messages generated. I've tried using both a Data Reader and an OLEDB Datasource. Does anyone have any ideas of what's going on and how I might fix it?





Thanks!!!Jess

View 6 Replies View Related

Transact SQL :: Inserting Character At The Beginning And End Of A Field

Sep 17, 2015

How to modify values in a SQL Database. In the table PRDDEmpmaster there is a field called email_address, and for those fields that have a value I need to change that value to add { } opening/closing "curly braces" to that field. 

For example,

RPARSONS@YAHOO.COM becomes
{RPARSONS@YAHOO.COM} .  Nulls/empty fields remain as is.    

View 6 Replies View Related

Appending Text To The Beginning Of A Select Statement.

Mar 30, 2008

I wish I had a better idea about how to describe this but here goes. I'm trying to display a list of majors/minors/graduate programs for a particular user. Now, I've gotten it display perfectly and was able to append (Graduate), (Major), (Minor) to each of the 3 different sections. My question is is it possible to add like rows that don't actually exist in table to the beginning of the select? For instance I want to add All and General before the rest of the select. I was also wondering where I should do a group by cuz I'd like to keep it in blocks of like graduates then majors and finally minors but currently it is just doing it alphabetically...Anyways below are the tables and at the end the current stored procedure i'm using, which works great...just not to the degree I'm aiming for.





Code Snippet

USE [C:PROGRAM FILESMICROSOFT SQL SERVERMSSQL.1MSSQLDATACOLLEGE.MDF]
GO
/****** Object: Table [dbo].[GraduateDiscipline] Script Date: 03/30/2008 14:45:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GraduateDiscipline](
[GraduateDisciplineID] [int] IDENTITY(0,1) NOT NULL,
[DegreeID] [nchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[GraduateID] [nchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DisciplineName] [nchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Description] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Criteria] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_GraduateDiscipline] PRIMARY KEY CLUSTERED
(
[GraduateDisciplineID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
ALTER TABLE [dbo].[GraduateDiscipline] WITH CHECK ADD CONSTRAINT [FK_GraduateDiscipline_DegreeShortName] FOREIGN KEY([DegreeID])
REFERENCES [dbo].[Degree] ([DegreeID])
GO
ALTER TABLE [dbo].[GraduateDiscipline] CHECK CONSTRAINT [FK_GraduateDiscipline_DegreeShortName]
GO
ALTER TABLE [dbo].[GraduateDiscipline] WITH CHECK ADD CONSTRAINT [FK_GraduateDiscipline_GraduateName] FOREIGN KEY([GraduateID])
REFERENCES [dbo].[Graduate] ([GraduateID])
GO
ALTER TABLE [dbo].[GraduateDiscipline] CHECK CONSTRAINT [FK_GraduateDiscipline_GraduateName]

USE [C:PROGRAM FILESMICROSOFT SQL SERVERMSSQL.1MSSQLDATACOLLEGE.MDF]
GO
/****** Object: Table [dbo].[Student_Graduates] Script Date: 03/30/2008 14:46:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Student_Graduates](
[GraduateDisciplineID] [int] NOT NULL,
[StudentID] [int] NOT NULL,
CONSTRAINT [PK_Student_Graduates] PRIMARY KEY CLUSTERED
(
[GraduateDisciplineID] ASC,
[StudentID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[Student_Graduates] WITH CHECK ADD CONSTRAINT [FK_Student_Graduates_GraduateDisciplineID] FOREIGN KEY([GraduateDisciplineID])
REFERENCES [dbo].[GraduateDiscipline] ([GraduateDisciplineID])
GO
ALTER TABLE [dbo].[Student_Graduates] CHECK CONSTRAINT [FK_Student_Graduates_GraduateDisciplineID]
GO
ALTER TABLE [dbo].[Student_Graduates] WITH CHECK ADD CONSTRAINT [FK_Student_Graduates_StudentID] FOREIGN KEY([StudentID])
REFERENCES [dbo].[Students] ([StudentID])
GO
ALTER TABLE [dbo].[Student_Graduates] CHECK CONSTRAINT [FK_Student_Graduates_StudentID]

USE [C:PROGRAM FILESMICROSOFT SQL SERVERMSSQL.1MSSQLDATACOLLEGE.MDF]
GO
/****** Object: Table [dbo].[MajorDiscipline] Script Date: 03/30/2008 14:46:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MajorDiscipline](
[MajorDisciplineID] [int] IDENTITY(0,1) NOT NULL,
[DegreeID] [nchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[MajorID] [nchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DisciplineName] [nchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Description] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Criteria] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_MajorDiscipline] PRIMARY KEY CLUSTERED
(
[MajorDisciplineID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
ALTER TABLE [dbo].[MajorDiscipline] WITH CHECK ADD CONSTRAINT [FK_MajorDiscipline_DegreeID] FOREIGN KEY([DegreeID])
REFERENCES [dbo].[Degree] ([DegreeID])
GO
ALTER TABLE [dbo].[MajorDiscipline] CHECK CONSTRAINT [FK_MajorDiscipline_DegreeID]
GO
ALTER TABLE [dbo].[MajorDiscipline] WITH CHECK ADD CONSTRAINT [FK_MajorDiscipline_MajorID] FOREIGN KEY([MajorID])
REFERENCES [dbo].[Majors] ([MajorID])
GO
ALTER TABLE [dbo].[MajorDiscipline] CHECK CONSTRAINT [FK_MajorDiscipline_MajorID]

USE [C:PROGRAM FILESMICROSOFT SQL SERVERMSSQL.1MSSQLDATACOLLEGE.MDF]
GO
/****** Object: Table [dbo].[Student_Majors] Script Date: 03/30/2008 14:46:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Student_Majors](
[MajorDisciplineID] [int] NOT NULL,
[StudentID] [int] NOT NULL,
CONSTRAINT [PK_Student_Majors] PRIMARY KEY CLUSTERED
(
[MajorDisciplineID] ASC,
[StudentID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[Student_Majors] WITH CHECK ADD CONSTRAINT [FK_Student_Majors_MajorDisciplineID] FOREIGN KEY([MajorDisciplineID])
REFERENCES [dbo].[MajorDiscipline] ([MajorDisciplineID])
GO
ALTER TABLE [dbo].[Student_Majors] CHECK CONSTRAINT [FK_Student_Majors_MajorDisciplineID]
GO
ALTER TABLE [dbo].[Student_Majors] WITH CHECK ADD CONSTRAINT [FK_Student_Majors_StudentID] FOREIGN KEY([StudentID])
REFERENCES [dbo].[Students] ([StudentID])
GO
ALTER TABLE [dbo].[Student_Majors] CHECK CONSTRAINT [FK_Student_Majors_StudentID]

USE [C:PROGRAM FILESMICROSOFT SQL SERVERMSSQL.1MSSQLDATACOLLEGE.MDF]
GO
/****** Object: Table [dbo].[Minors] Script Date: 03/30/2008 14:46:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Minors](
[MinorID] [nchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Description] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Criteria] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_Minors] PRIMARY KEY CLUSTERED
(
[MinorID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

USE [C:PROGRAM FILESMICROSOFT SQL SERVERMSSQL.1MSSQLDATACOLLEGE.MDF]
GO
/****** Object: Table [dbo].[Student_Minors] Script Date: 03/30/2008 14:46:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Student_Minors](
[MinorID] [nchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[StudentID] [int] NOT NULL,
CONSTRAINT [PK_Student_Minors] PRIMARY KEY CLUSTERED
(
[MinorID] ASC,
[StudentID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[Student_Minors] WITH CHECK ADD CONSTRAINT [FK_Student_Minors_Minors] FOREIGN KEY([MinorID])
REFERENCES [dbo].[Minors] ([MinorID])
GO
ALTER TABLE [dbo].[Student_Minors] CHECK CONSTRAINT [FK_Student_Minors_Minors]
GO
ALTER TABLE [dbo].[Student_Minors] WITH CHECK ADD CONSTRAINT [FK_Student_Minors_StudentID] FOREIGN KEY([StudentID])
REFERENCES [dbo].[Students] ([StudentID])
GO
ALTER TABLE [dbo].[Student_Minors] CHECK CONSTRAINT [FK_Student_Minors_StudentID]

ALTER PROCEDURE [dbo].[Student_Deciplines]
@studid int
AS
BEGIN
SELECT RTRIM(gradDis.DisciplineName) + ' (Graduate)' FROM GraduateDiscipline gradDis, Student_Graduates sGrads WHERE gradDis.GraduateDisciplineID = sGrads.GraduateDisciplineID AND sGrads.StudentID = @studid
UNION
SELECT RTRIM(majDis.DisciplineName) + ' (Major)' FROM MajorDiscipline majDis, Student_Majors sMajors WHERE majDis.MajorDisciplineID = sMajors.MajorDisciplineID AND sMajors.StudentID = @studid
UNION
SELECT RTRIM(mins.MinorID) + ' (Minor)' FROM Minors mins, Student_Minors sMinors WHERE mins.MinorID = sMinors.MinorID AND sMinors.StudentID = @studid

END
Some sample data:
GraduateDiscipline
GraduateDisciplineID DegreeID GraduateID DisciplineName ....
0 M.B.A. 1 Master of Business Administration

Student_Graduates
GraduateDisciplineID StudentID
0 0

MajorDiscipline
MajorDisciplineID DegreeID MajorID DisciplineName
1 B.S. Computer Science Computer Science

Student_Majors
MajorDisciplineID StudentID
1 0

Minors
MinorID Description Criteria
Computer Science blah blah blah blah

Student_Minors
MinorID StudentID
Computer Science 0

Output I'd like for StudentID 0
All
General
Master of Business Administration (Graduate)
Computer Science (Major)
Computer Science (Minor)

Hope someone can help!

View 5 Replies View Related

Last Day Of Current Quarter + I Month

Feb 12, 2006

Hi there everbody,

i am trying to get the last day of the Q + 1 month

the first part i have succeeded (dateadd(ms,-3,DATEADD(qq, DATEDIFF(qq,0,getdate() )+1, 0))) ,but how do i add 1 more month ?

would appreciate any suggestion

regards

Yoav

View 2 Replies View Related

All Sales Reported After Quarter End

Apr 19, 2007

It's been a long time since I've built tough queries and need some help.

I need to report all sales that happened within a quarter but were reported after the quarter end.

Quarters

Q1 - 1/1 thru 3/31
Q2 - 4/1 thru 6/30
Q3 - 7/1 thru 9/30
Q4 - 10/1 thru 12/31

Sample Data

ticketid salespersonid saledate sale_entereddate
1234 bsmith 1/1/2006 2/1/2006
1235 jgarcia 3/31/2006 4/1/2006
1236 bsmith 1/1/2006 2/3/2006
1237 jdoe 6/23/2006 7/1/2006
1238 bsmith 8/5/2006 8/6/2006
1239 bsmith 10/1/2006 1/1/2007

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved