Hey I've Got A Homework Problem I'm Working On And Am Stumped.
Aug 10, 2006
It goes like the following:
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.
A.Execute your stored procedure to show that the insert logic works.
B.Execute your stored procedure to show that the update logic works.
Any hints from the wizards out there would be greatly appreciated!
*** Sent via Developersdex http://www.developersdex.com ***
I'm just going to put this.... I have no idea what SQL is and I'm in my 5th week of my into to Sql course. My teacher is terrible, and I havent learned a thing. sooo yah... answer this question if you like...you'll be doing a good deed for me ;)
Here's the question:
Name 2 examples of digital or electronic databases, one which is a relational database, and one that isn’t.
For each of your examples: a. Describe the thing or topics that the database is about. b. Give the location of the database e.g. provide the URL for databases available on the Web. c. Explain in detail why the database is or isn’t a relational database.
I really don't expect any replies, but hey its worth a try!
Hey guys, I am stuck on a homework question and I was hoping someone could help point me in the right direction.
the question is:
"find the book code and book title for each book whose price is greater than the book price of every book that has the type HOR"
now, I know how to find the book price of every book that has the type HOR but how do i minimize the results to show all books that have greater prices that the HOR books?
Im stumped on my SQL connection string when using the "SQLGridSelectedView" module. The tables im accessing reside in the same database as DNN on the local machine. My current string is "Provider=SQLOLEDB;Server=ADVANCED02;DATABASE=XP;Trusted_Connection=TRUE"My SQL statement as a test was a simple select all ...... "SELECT * FROM atm info"The error im getting is that ASPNET is not a trusted user"System.Data.OleDb.OleDbException: Login failed for user 'ASPNET'. Reason: Not associated with a trusted SQL Server connection. at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) at System.Data.OleDb.OleDbConnection.InitializeProvider() at System.Data.OleDb.OleDbConnection.Open() at DNNAdditional.SQLGridSelectedView.DisplayGrid(String psSortExpr, Boolean pbExport)"/TIA
I am migrating from MS Access and MySql to MS SQL 2000. I guess the first step is to load MSDE on my computer. My platform is Win XP Office
I am not sure what to expect, but this sure appears to be one of the most complicated procedures I have ever encountered. So I assume that I some how got off on a tangent.
Basically I just want a simple ability to create databases on Websites and transfer the data from existing databases on another Website.
What am I doing wrong?
What am I missing here?
Here is what I have done.
I downloaded the MSDE file MSDE2000A.exe
When I executed MSDE2000A.exe that installed a files in a directory MSDERelA
When I tried to run setup.exe in the directory MSDERelA, the process was aborted with the following comment
"A strong password is required for security reasons."
Then following the instructions on "How to Chane Your SA Password" I received the following.
'osql' is not recognized as an internal or external command, operable program or batch file.
This one has the expert in SQL Express stumped and he suggested I try posting here. My problem is that I am trying to load SQL Express and can not do so.
Mike Wachal - MSFT wrote:
mnn2501 wrote:
I am having a similar problem, I first used the uninstall program which failed, then went to add remove programs finding nothing, then went to windows explorer and deleted what looked to be obvious choices. I still can't get sql express to install - any idea's?
Here are the logs:
Product "{2AFFFDD7-ED85-4A90-8C52-5DA9EBDC9B8F}" versioned 9.00.1116 is not compatible with current builds of SQL Server.Expected at least version: 9.00.1399.00 The Product Name is "Microsoft SQL Server 2005 Express Edition CTP"
Message displayed to user SQL Server 2005 Setup has detected incompatible components from beta versions of Visual Studio, .NET Framework, or SQL Server 2005. Use Add or Remove Programs to remove these components, and then run SQL Server 2005 Setup again. For detailed instructions on uninstalling SQL Server 2005, see the SQL Server 2005 Readme.
This error indicates that you have a pre-RTM CTP version of Express on your computer that you did not remove correctly. You will need to remove all pre-release software before you can install the released software. Try to remove components from Add/Remove programs first. If that fails, or if nothing is listed, manually remove the product using the product id listed in the log like this:
Thank you for your answer, I tried doing the msiexec.exe /x {2AFFFDD7-ED85-4A90-8C52-5DA9EBDC9B8F} but came up with this pop up error message when I did and I am lost.
The setup has encountered an unexpected error in datastore. The action is RestoreSetupParams. The error is" Failed to read property "Installlds" {"MachineConfiguration","","BEAST"} from cache Unable to write property into cache. IsClustered
Unable to write property in cache:"IsClustered": XmlRW Error: Failure loading xmlre.dll CheckAllProcedures() returned:2
Any more ideas?
That one has me stumpt. I would suggest that you post this question into the Setup and Upgrade forum so the folks that specialize in the technology can offer suggestions.
Here is the table:CREATE TABLE [child]([pk_child_id] [int] NOT NULL ,[fk_parent_id] [int] NOT NULL ,[code] [char] (2)NOT NULL ,[dt] [datetime] NOT NULL ,[newcode] [int] NULL)There is a situation where there will be more than one record with thesame [fk_parent_id] value, but different values for the [code]field.If one of those records has a [code]= 5, but the [dt] is AFTER asimilar record where [code]= 6 or [code]= 7 (but same [fk_parent_id]value), I need to set [newcode] = 10. How can I pull this off? Again,the group of records can have different [code] values, different [dt]values, but a common [fk_parent_id].Help!
SCENARIO:SQL Server 2000 Back End.The customer calls in with a problem and a QUERY is raised. The dateof creation of the record is in the fldDateQuery column.The user responds to the customer and a RESPONSE is raised. Itcontains the ID of the associated QUERY and the date of creation ofthe RESPONSE record is in the fldDateResponse column.The user wishes to know how many queries in the last month wereresponded to on the same day.CANDIDATE SQL:SELECT COUNT(*) AS NumResponsesFROM tblQueryINNER JOIN tblResponses ON tblQuery.fldQueryID =tblResponses.fldQueryIDWHERE (tblQuery.fldDateQuery < CONVERT(DATETIME,'2003-9-8 00:00:00',102))AND (tblQuery.fldDateQuery > CONVERT(DATETIME,'2003-8-8 00:00:00',102))AND (DATEDIFF(Day, tblQuery.fldDateQuery,tblResponses.fldDateResponse) <= 1)PROBLEM:If a query has more than one response raised on it within a day of thequery being logged, it counts all those responses. In other words,the SQL counts the number of matching RESPONSES, and not the number ofQUERIES.TIAEdward
Hi there...I am having a whole bunch of trouble trying to design a certain query. Ihave two tables (see a representation of them here:http://www.plankmeister.org.uk/tables.html ) one called menu_data and onecalled page_data.menu_data contains a list of defined menus (menu_group) which may be sortedaccording to the menu_group_display_order column.page_data contains a list of page definitions. Each page belongs to amenu_group. All the pages in a given group may be sorted according to thepage_display_order column. (for instance, a query to order all pages with amenu_group equal to 1 in ascending order would produce:CatsDogsFishSquirrels)What I am trying to do is to design a query that will tell me thepage_user_name of all the pages that sit at the 'top' of their menu group,but ordered by the menu_group_display_order column.So basically, it will order the data in menu_data by themenu_group_display_order colum, then comparing menu_data.menu_group topage_data.menu_group, will return the 'first' row after being ordered bypage_display_order, so that in the case of the data given, the return wouldbe:HorsesCatsBirdsRabbitsI've tried UNION, GROUP BY, TOP 1, INNER JOIN, OUTER JOIN, SLIGHTLY TO THELEFT JOIN, ONLY IF ITS A WEDNESDAY JOIN... etc etc... But I just can't getit to work! It either returns 40 rows, or one. I've spent a total of about10 hours trying to design this query, and am losing what precious littlehair I have left at an alarming rate.Hope someone can provide some insight!Plankmeister.
Because of the single quotation mark in YEAR'S the insert fails. I know this has got be one helluva dumb question. but I'm still learning. How is it done??
Hi, I'm getting the error Syntax error (missing operator) in query expression 'dbPWork.id = dbPWorkWord.work_id LEFT JOIN words ON dbPWorkWord.word_id = words.id'." on the query below. Everything looks in place to me. Do you see anything that shouldn't work?
Query:
Code:
Code:
SELECT DISTINCT dbPWork.id, description_e as description, w_id , dateStart, dateEnd FROM dbPWork LEFT JOIN dbPWorkW ON dbWork.id = dbPWorkW.work_id LEFT JOIN words ON dbPWorkW.word_id = words.id
Everything works fine until I add the second LEFT JOIN statement. Any ideas? I'm stumped.
create table holding ( id1 int, id2 int, datefield datetime, holding int, quantity int ) go
insert into holding select 1,1,'20031210',10,null union select 1,1,'20031211',30,null union select 1,1,'20031212',70,null union select 1,1,'20031213',60,null union select 1,2,'20031210',100,null union select 1,3,'20031210',100,null union select 1,3,'20031210',10,null
go
Quantity is based on Holding for the day - Holding for the previous transaction involving same id1 ,id2.
I was hoping somebody could help me out with a query I've been trying to solve.
My Table Structure:
[UserMessages]
MessageID int ToUserID int FromUserID int Subject varchar(200) Message varchar(max) isNew bit
[UserMessageReplies]
ReplyMessageID int MessageID int ToUserID int FromUserID int Message varchar(max) isNew bit
Sample Data:
[UserMessages]
MessageID | ToUserID | FromUserID | Subject | Message | isNew ------------------------------------------------------------------------------------------------------------- 1 1 2 test subject Message Body 0 2 2 1 test subject Message Body 0 3 1 4 test subject Message Body 1 4 1 5 test subject Message Body 1
[UserMessageReplies]
ReplyMessageID | MessageID | ToUserID | FromUserID | Message | isNew --------------------------------------------------------------------------------------------------------------------------- 1 1 2 1 re: Message Body 0 2 1 1 2 re: Message Body 0 3 1 2 1 re: Message Body 0 4 1 1 2 re: Message Body 0 5 1 2 1 re: Message Body 1 6 2 1 2 re: Message Body 1
Explanation:
ReplyMessageID = 1-4 signfies that there is a thread response to MessageID 1 but they have been opened (isNew =0). ReplyMessageID = 5 signfies that there is a new thread response to MessageID 1. ReplyMessageID = 6 signifies that there is a reply from a message UserID=1 sent out (MessageID 2)
There needs to be a filter to check UserMessages.TOUserID=1 OR UserMessageReplies.ToUserID=1 to ensure that we can capture a msg that UserID=1 had sent out but now there is a reply to the Message by the User (in this example data i've setup MessageID = 2 to handle that possibility)
My Goal:
To select all messages for a ToUserID and order them by UserMessages.isNew or UserMessageReplies.isNew. This must include a message the user has sent but now has received a reply. (This means the first filter; UserMessages.ToUserID, must be overwritten with UserMessageReplies.ToUserID)
I have been looking at this for over a day now. I cannot see why this procedure does not work, its so simple. No matter what happens it always returns 0. If it locates a record, it doesnt update it, yet it still returns 0. It should not be returning 0 if its not updating so I can't figure out why it does. Why does this always return 0? [pre]Create Procedure CreateNewCategory @title nvarchar(100), @description nvarchar(1000), @displayOrder intAS DECLARE @Result as int IF EXISTS(SELECT categoryTitle FROM categories WHERE categoryTitle = @title) BEGIN SELECT @Result = 1 ENDELSE BEGIN INSERT INTO categories(categoryTitle, categoryDescription, displayOrder) VALUES(@title, @description, @displayOrder) /* If no error was encountered, 0 will be returned. */ SELECT @Result = @@Error ENDGO[/pre] Thanks!
I need to produce a result that has 1 column that is the concatenation of each COORD separated by a '.' by increasing LEVEL
EX: The result should look like this 1.1.1 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5
Please note that the answer must be flexible enough to handle any number of levels and coordinates (although levels will most likely be less than 5 and coordinates less than 100)
Here is the situation I'm trying to set-up a package to ftp some files down if that part fails email me but if successful rename the 2 files to something else.
so what I set-up was a FTP tasks with the remote path set as a expresion since I needed to Download todays files. no problem there have that part working.
so then I set a notifaction event with failure constraint to email me. pretty easy so far.
then I set 2 tasks to rename the 2 files downloaded I'm sure I could do this part with a loop but what seperate tasks so I knew if any failed or could set-up notifaction tasks if I wanted. in the 2 rename tasks I set the sourcepath to an expression so it would know to read todays files and they could change from day to day.
then the destination part is hard coded for now to a file name.
now here is were the issue comes in I go to save it and it says the files don't exist from the rename piece. well of course not they haven't been FTPed yet.
so I tried delayevaluation on both the file system tasks but a no go still errors.
What I need it to do is basically say wait till the ftp is run these files won't be there. any help in the right direction would be appreciated.
I've seem some good posts similair to this, but I haven't been able to find my exact issue.
I have the following table:
ID Name Location Start End
1 Joe NY 2000 2001
1 Joe CA 2002 2004
1 Joe MA 2005 2008
2 Sue NJ 2003 2004
2 Sue FL 2004 2008
3 Bob CA 1999 2000
3 Bob WA 2001 2004
3 Bob OR 2005 2006
3 Bob MI 2007 2008
As you can see, the Location, Start and End dates can vary for each person and I don't know how many rows a single person might have.
The result I want, is a "pivot like" table.
ID Name Location1 Start1 End1 Location2 Start2 End2 Location3 Start3 End3 Location4 Start4 End4
1 Joe NY 2000 2001 CA 2002 2004 MA 2005 2008
2 Sue NJ 2003 2004 FL 2004 2008
3 Bob CA 1999 2000 WA 2001 2004 OR 2005 2006 MI 2007 2008
I assume I can first do a count of the maximum rows for an individual and that is greatest number of columns I would need. But doing that and trying to figure out the rest has really stumped me.
Any thoughts, ideas and suggestions would be greatly appreciated.
I had a view in which I did something like this isnull(fld,val) as 'alias'
when I assign a value to this in the client (vb 6.0) it works ok in sql2000 but fails in 2005. When I change the query to fld as 'alias' then it works ok in sql 2005 . why ?? I still have sql 2000 (8.0) compatability.
Also some queries which are pretty badly written run on sql 2000 but dont run at all in sql 2005 ???
any clues or answers ?? it is some configuration issue ?
I am writing a pgm that attaches to a SQL Server database. I have an Add stored procedure and an Update stored procedure. The two are almost identical, except for a couple parameters. However, the Add function works and the Update does not. Can anyone see why? I can't seem to find what the problem is...
This was my test:
Dim cmd As New SqlCommand("pContact_Update", cn) 'Dim cmd As New SqlCommand("pContact_Add", cn)
Catch ex As Exception Label1.Text = ex.Message End Try
When I use the Add procedure, a record is added correctly and I receive the "done" message. When I use the Update procedure, the record is not updated, but I still receive the "done" message.
I have looked at the stored procedures and the syntax is correct according to SQL Server.
Original suggestion for my problem was - Select * from TableA where ID not in ( Select ID from TableB) When I run the query below using the IN operator I get 227 records returned but when I use NOT IN I get zero records when I expect well over 10,000. What am I missing? using SQL 2000 server SELECT LinksInfo.L_ID, LinksInfo.C_ID, Companies.C_CompanyName, Companies.C_Email, Companies.C_CompanyEmailFROM LinksInfo INNER JOIN Companies ON LinksInfo.C_ID = Companies.C_IDWHERE (LinksInfo.L_ID IN (SELECT ZL_ID FROM Location_Zip)) ZL_ID is not a primary key in Location_Zip
Hello again, I think im missing something here, i just cant find out what it is. I have a temp table: CREATE TABLE #tempSearch(tempID BIGINT IDENTITY(1,1) PRIMARY KEY,username NVARCHAR(20) COLLATE Finnish_Swedish_CI_AS,lastlogin DATETIME,signupdate DATETIME) Now i am trying to retrieve some data for each user that is inside this tempSearch list and have an id over xxx (xxx = the value of the parameter @first_id): SELECT @sql = 'SELECT profile_publicinfo.username, profile_publicinfo.gender, profile_publicinfo.signupdate, profile_profilephoto.imageurl, profile_profilephoto.alttext, settings_username.color, profile_publicinfo.lastloginFROM #tempSearch INNER JOIN dbo.profile_publicinfo ON profile_publicinfo.username = #tempSearch.usernameINNER JOIN dbo.settings_privateinfo ON settings_privateinfo.username = profile_publicinfo.usernameFULL OUTER JOIN dbo.profile_coolfacts ON profile_coolfacts.username = profile_publicinfo.username FULL OUTER JOIN dbo.profile_profilephoto ON profile_profilephoto.username = profile_publicinfo.usernameFULL OUTER JOIN dbo.settings_username ON settings_username.username = profile_publicinfo.usernameWHERE (profile_publicinfo.username IN (SELECT username FROM #tempSearch))AND #tempSearch.tempID >= @first_id' SELECT @paramlist = '@first_id int'EXEC sp_executesql @sql, @paramlist, @first_id I need to get the tempID from the tempSearch table in order to compare it with @first_id When i run this i get the same username repeated like 30 times then it moves over to the next, when i debug the #tempSearch it looks fine, just the users that are suppose to be there.
Hi I think I have installed MSDE sucessfully. The new servie is running, but how can I test ifit is working? Can I place my files anywhere on the system? All help appreciated
OK so I'm using dynamic sql to enable me to have a variable for the order by, but now it's giving me the following error
Syntax error converting character string to smalldatetime data type.
Any help is very much appreciated
Code follows
CREATE PROCEDURE spBattingAve1 @cid datetime, @cid1 datetime, @sid nvarchar(10) AS
DECLARE @query nvarchar(4000)
SET @query = 'SELECT MAX(t_batting.runs) AS BestRuns, COUNT(t_batting.dnb) AS DidNotBat, t_player.surname, t_player.firstname, t_batting.player_id, Sum(t_batting.runs) as SumOfruns, COUNT (*) AS Games, COUNT (t_batting.notout) as nout, (Sum(runs)/(COUNT(*)-(COUNT(notout)+COUNT(dnb)))) as AverageRun, (COUNT(*)-COUNT(dnb)) AS Innings, (SELECT COUNT(*) FROM t_batting inner join t_game on t_batting.game_id = t_game.game_id WHERE (t_batting.player_id = t_player.player_id) AND runs >= 50 AND runs <100 and t_game.date >= '+@cid+' And t_game.date <= '+@cid1+' GROUP BY t_batting.player_id) AS Overfifty, (SELECT COUNT(*) FROM t_batting inner join t_game on t_batting.game_id = t_game.game_id WHERE (t_batting.player_id = t_player.player_id) AND runs >= 100 and t_game.date >= '+@cid+' And t_game.date <= '+@cid1+' GROUP BY t_batting.player_id) AS Overton FROM t_batting INNER JOIN t_game ON t_batting.game_id = t_game.game_id INNER JOIN t_player ON t_batting.player_id = t_player.player_id WHERE t_batting.player_id = t_player.player_id AND t_game.date >= '+@cid+' And t_game.date <= '+@cid1+'
GROUP BY t_batting.player_id, t_player.surname, t_player.firstname, t_player.player_id HAVING (COUNT(*)-(COUNT(notout)+COUNT(dnb))) <> 0 order by '+@sid+' DESC'
In SQL 7.0, when i use the below query in query analyzer, I got an error message. why? ======================
Set Identity_insert on
UPDATE Table1 SET no = 3 WHERE no = 4
Set Identity_insert off go
Error message ============= Server: Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'on'. Server: Msg 156, Level 15, State 1, Line 7 Incorrect syntax near the keyword 'off'.
I am on a box with 4 GB of memory that only runs SQL Server. SQL Server is using 1.7 GB as per task manager. There are a lot of databases on this box. I looked at the boot.ini and /3GB was not set. I have done this at least 50 times before: turn on the /3GB switch and SQL Server will use up to 2.7 GB per task manager. (I know it is actually 2GB and 3GB but it seems that in task manager it shows up as 1.7-1.8 and 2.7-2.8)
Anyway back to the story. So I set /3GB, rebooted the server and SQL Server still only consumes up to 1.7GB. I realize that SQL Server might not actually need more memory, but I have a distinct feeling that it wants more but is being constrained; that is, the the /3GB switch is not working. More relevant information:
1) the boot.ini line: multi(0)disk(0)rdisk(0)partition(1)WINNT="Microsoft Windows 2000 Advanced Server" /fastdetect /3GB
2) max server memory (MB) = 3000
3) min server memory (MB) = 3000
4) awe enabled = 0
5) @@version = 8.00.2039 which is SQL Server 2000 SP4
Has anyone seen this before? Any ideas on how to troubleshoot this?