Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQL Beginner Expand / Collapse
Author
Message
Posted Wednesday, August 9, 2006 10:05 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, August 11, 2006 11:17 AM
Points: 4, Visits: 1

Hi everyone,

I'm a beginner with SQL Server 2005 and trying to complete a project with the following question, can someone please help?

Use AdventureWorks database and HumanResources.Department table.

 

Create a stored procedure called spDepartmentAddUpdate.  This procedure accepts two parameters: Name, and GroupName.  The data types are VarChar(50), and VarChar(50) respectively.  Define logic in this procedure to check for an existing Department record with the same Name.  If the department record exists, update the GroupName and ModifiedDate. Otherwise, insert a new department record.

 

  1. Execute your stored procedure to show that the insert logic works.
  2. Execute your stored procedure to show that the update logic works.

  Note:

 

1.        DepartmentID is an identity column.

2.        You may use GETDATE() to insert or update the modified date.

Thanks in advance!

Post #300762
Posted Thursday, August 10, 2006 10:09 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, December 5, 2013 12:21 PM
Points: 265, Visits: 164
Are you making us do your homework for you?

Why dont you make an attempt and we can guide you through?


******************
Dinakar Nethi
Life is short. Enjoy it.
******************
Post #300959
Posted Thursday, August 10, 2006 9:15 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, August 11, 2006 11:17 AM
Points: 4, Visits: 1
Sorry Dinakar, I was only trying to get some help not a complete solution.  Thanks anyways...
Post #301094
Posted Friday, August 11, 2006 5:35 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 4:03 PM
Points: 42,485, Visits: 35,554

The SQL 2005 books online conain a lot of information for beginners. The sections on create procedure, insert statements, update statements and if - else statements will probably be of most use for this problem

If you are stuck, we'll be happy to give advice and assistance

So what, specifically, do you need help with?




Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #301153
Posted Friday, August 11, 2006 7:09 AM
SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: Moderators
Last Login: Tuesday, April 22, 2014 1:22 PM
Points: 8,369, Visits: 734

As stated before your going to use update and insert of course but look at the keyword

EXISTS

and the functions

SCOPE_IDENTITY, IDENT_CURRENT, and @@IDENTITY (hint triggers and other events can affect the results of one or more of these)

 




Post #301178
Posted Friday, August 11, 2006 11:19 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, August 11, 2006 11:17 AM
Points: 4, Visits: 1
Thank you, I used NOT EXIST with the IF...ELSE statement and it worked!
Post #301294
Posted Wednesday, March 16, 2011 12:34 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, March 18, 2011 5:47 AM
Points: 2, Visits: 6
That person is probably in the same scenario as me. How does one speak Japanese when all they grew up with is African. There is no clue as to how to begin coding or what is required in code lines. I am in a SQL class and the problem I am having is beginning to write the coding. The text is variable and I cannot tell what the lines look like when they are typed. Is there anywhere that I can learn SQL like I am in kindergarten and specifically this is SQL server? I have three sets of information that I have to enter into and SQL format but not preset table to reference from. There is employee_id with its variable information, Job title with a few components, SQL_insert for a list of names; and with all of this I am to enter these records into a list of supplied job titles. I could do this layout in Cobol and develop a table in excel or word but there is not hint anywhere on basic SQL development. Can you help or do you have a resource?
Post #1079213
Posted Wednesday, March 16, 2011 1:57 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 5:13 PM
Points: 33,100, Visits: 15,210
Please start a new thread if you have a new question.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1079273
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse