SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Beginner


SQL Beginner

Author
Message
Sean Anderson
Sean Anderson
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 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!


Dinakar Nethi-176633
Dinakar Nethi-176633
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1103 Visits: 188
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.
******************
Sean Anderson
Sean Anderson
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 1
Sorry Dinakar, I was only trying to get some help not a complete solution. Thanks anyways...
GilaMonster
GilaMonster
SSC Guru
SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)

Group: General Forum Members
Points: 221239 Visits: 46279

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, MVP, M.Sc (Comp Sci)
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


Antares686
Antares686
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: Moderators
Points: 26540 Visits: 785

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)





Sean Anderson
Sean Anderson
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 1
Thank you, I used NOT EXIST with the IF...ELSE statement and it worked!
Tech greenie
Tech greenie
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 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?
Steve Jones
Steve Jones
SSC Guru
SSC Guru (144K reputation)SSC Guru (144K reputation)SSC Guru (144K reputation)SSC Guru (144K reputation)SSC Guru (144K reputation)SSC Guru (144K reputation)SSC Guru (144K reputation)SSC Guru (144K reputation)

Group: Administrators
Points: 144724 Visits: 19424
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
My Blog: www.voiceofthedba.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search