I'm trying to write a delete trigger that copies the information to a table when some one deletes information. this is what i have so far
CREATE TRIGGER DJObCandidate ON HumanResources.JobCandidate
AFTER DELETE
AS BEGIN
set nocount on;
exec INSERT INTO HumanResources.JobCandidateHistory(JobCandidateID,Resume,
ModifiedDate)
END;
I am migrating a access dbase to SQL. I have two tables, the first is a buffer table that collects data from various sources, the second table is an indexed version of the first table (to eliminate duplicate records etc. etc.)
I am currently using the DTS packaage to transfer data between them, would a trigger be a better solution?
I am migrating a access dbase to SQL. I have two tables, the first is a buffer table that collects data from various sources, the second table is an indexed version of the first table (to eliminate duplicate records etc. etc.)
I am currently using the DTS packaage to transfer data between them, would a trigger be a better solution?
I have two tables. One is a parameter-table which has info of all allowed ID-values in different tables, ie Table ID ----- --- tbl_a 123 tbl_a 125 tbl_b 100 tbl_b 110 ...
Then I have the data tables 'tbl_a' and 'tbl_b' which has following structure: ID Datafields --- -------- ---- ---- 123 aaa 123 bbb 125 bbb
I want not to use unique-keys since there could be several rows with same ID (but the data is of course different).
I have tried to write a trigger to check that a correct key is inserted in data tables. The code I wrote is
CREATE TRIGGER trig1 ON tbl_a FOR INSERT, UPDATE AS declare @a char(3) select @a = ID from inserted if @ not in (select ID from Parameter where Table = 'tbl_a') RAISERROR ('ID is false', 16,1)
When inserting the trigger works fine, but when updating with allowed value I get error "Key column information is insufficent or incorrect. Too many rows were affected by update" and when updating with not-allowed value the message is "Another user has modified the contents of this table or view; the database row you are modifuing no longer exists in the database. ID is false (ie my errortext).
This should be easy. What goes wrong? How to manage this situation? I'm using triggers since check-constraint cannot use values from different tables, I guess. I'm using SQL Server 2000
Hi, I´m familiar with Firebird and PostgreSQL DBMSs, and now I'm exploring SQL Server Express 2005. In other products you have both BEFORE and AFTER events arround INSERT, DELETE, UPDATE. I'm not sure if I understood well INSTEAD OF triggers, but these would be equivalent to BEFORE triggers ?
Can you give me an example on when I'd use INSTEAD OF triggers?
Hi there I sorry if I have placed this query in the wrong place. I'm getting to grips with ASP.net 2, slowly but surely! When i try to access my site which uses a Sql Server 2005 express DB i am receiving the following error:
Server Error in '/jarebu/site1' Application.
Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'.Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
This is the connection string that I am using: <connectionStrings> <add name="ConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;Initial Catalog=ASPNETDB;User Instance=True" providerName="System.Data.SqlClient"/> </connectionStrings>
The database is definitly in the folder that the error message relates to. What I'm finding confusing is that the connection string seems to be finding "aranga"s database. Is it something daft?
This isn€™t an problem as such, it€™s more of a debate.
If a table needs a number of update triggers which do differing tasks, should these triggers be separated out or encapsulated into one all encompassing trigger. Speaking in terms of performance, it doesn€™t make much of an improvement doing either depending upon the tasks performed. I was wondering in terms of maintenance and best practice etc. My view is that if the triggers do totally differing tasks they should be a trigger each on their own.
Hopefully this is the right place to post this, I am trying to learn ADO.Net programming using VWD Express with SQL Express... I tried to do the walk-through tutorial on ADO.Net through the asp.net tutorial. The walk-through asked you to download and install a script (check) then it said to open a command window with sql server running (check) and then to copy all of this special script code into to bind the database to the web page (not check). Everything pretty much went down hill after that part. I couldn't get the Update/Cancel/Delete buttons. After that dissapointing attempt at learning I decided to just try and make my own database. All was going pretty well until I try to add the UPDATE/DELETE fields after adding the WHERE clause. No go. So, I don't know if I'm just totally flubbing this up or if this is a common problem. Do I need the two or three pages of custom script like the Microsoft example to make a database work?
1 Hi, I'm a complete newbie at this, and need some help I want to import a text file into a DB. I know how to set it up in the DTS, however when I check the DB each line from the text file is in a seperate row. What have I missed? I want the file just in one row, like its a memo.
2 What do I use to connect to a SQL DB on the web so i can see the DB and all the tables
3 Also if I want to add data to a DB is that done on the server, or do I change my copy of the DB and re-upload
I've imported an access .mbd table into SQL 7.0, and need to know the best way to overwrite my SQL 7.0 table with the new Updated information that is contained in the access table. I've read a little bit about update tables, but is there an easy way to overwrite an entire table without having to specify each row and column?
Ok, not sure if this is where i should post this, but here goes.
I am trying to setup a database to handle RMA stuff at work. I need to be able to access the DB from numerous systems at once. Now i know NOTHING about SQL or any other DB for the most part. Messed around with Access some, but nothing major.
Is there anyone that could help me, explain how, or at least point me in the right direction?
I have MS SQL server 2000. Any help, ideas, or suggestions would be great!!
Hey! I',m totally new to Ms SQL Server. I'm currently trying to import a database from LINUX using SQL+ (Oracle) to MS SQL Server. Any suggestions on how this could be achieved would be most helpful
I need to know how to write a sql statement for VB to Microsoft Access for the following criteria.
TblEmployees only Field to be concerned with is EmployeeID -Its PK TblEmpAttendane has these fields: EntryID - Pk EmployeeID - Fk Date- A text form date validated through vb to avoid hassle Value-A single digit value that can be alpha OR numeric
To get the Date range for the current month I use variables to store the First and last day of the month(in a CUSTOM calendar control).
I have been trying to use this Sql statement(that wont work): SqlString = "SELECT * FROM TblEmpAttendance WHERE Date BETWEEN '" & FirstDay & "' AND '" & LastDay & "'"
I need to: 1.)using the current EmployeeID (from TblEmployees) 2.) find the same EmployeeID in TblEmpAttendance 3.)Get the date range for the current month and year(valid days currnt mo.) -these date are supplied by the variables "FirstDay" AND "LastDay" as seen in above SqlString
4.) Find the Values associated with the dates and EmployeeID
I have a table with 10 records: 10, 9, 8, 7 ... and so on. I want to SELECT the top 3 records starting with the second record on the list (which in this case is 9.) So the result should be 9, 8, and 7. What would be the correct SQL statement for this?
I tried "SELECT TOP 3 * FROM tableXXX WHERE (FieldID<>(SELECT TOP 1 * FROM tableXXX ORDER BY FieldID DESC) ORDER BY FieldID DESC" but sure as heck it didn't work. Can anyone help?
just for understanding a simple iif statement: I like to set a numeric value to 0, if it is smaller than 0. This expression shall be valid over all dimensions for a specific measure
like Iif([Measures].[Provision Ankauf]<0,0,[Measures].[Provision Ankauf] )
it's not working, Pivottable returns ##VALUE everywhere
I have two problems. I am currently using SQL Server express and SQL Server Management Studio Express locally. i have a DotNetNuke website running on the web with IHostASP.Net
Story:
I noticed that my SQL Server 2005 database with IHostASP.net was 350MB. It was only 22 2 months ago and I have had about 100 users sign up. I then connected to my live database via SQL Server Management Studio Express and shrunk the database. No errors and the database was reduced to 24MB - Great I thought!
I went and checked the website and all was great for about an hour then the site went down with the following error:
Error The transaction log for database 'classcampers' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases
Anyone know what to do.
Anyway, I have downloaded a .bak of my database as supplied by my host. However I cant figure out to restore this file back to my live database. What are the steps involved?
Do I create a new local database from the .bak and then somhow restore this back to my live one, or do i apply this .bak file strainght to my live database using SQLMSE. Any tutorials becuase I have been trying to apply this restore all day
Thansk for any advice in advance cheers Albertramsbottom:eek:
Hi, which is current running mostly used version of sql server and what was the previous version? how can we track down a query bad performance in sql server(like explain plan,stats..etc..in oracle)
Ive been learning SQL slowly and I need help for a projet I am doing.
I currently would like to compare identical files in a 2 seperate folder. Not only would I like to compare if the files are the same name, but when they are I would like to compare the file contents.
SO basically this is what I need to do: -Compare file names in folder A with files in folder B -If a match is found, compare file contents -If file contents are same, do nothing. If file contents are different, move file to folder C.
I finally decided to do our ASP application using VB, .NET and MSSQL.
My questions are simple, but I cannot find all the answers, so anything you can offer will be greatly appreciated.
Please explain how licenses (CALS) work with regard to Windows Server and MSSQL. For example, suppose we have 200 clients all logged into our application, but only say 40 are currently active (meaning they are adding data, running reports, etc....), but they are not all clicking the "DO" button at the same time. So how many Windows server and/or MSSQL seats, licenses, CALS, cpu's etc.... (whatever they are called) will I need?
How many users do you think a "well designed" ASP application built using AJAX, ActiveX, VB, .NET and MSSQL can a single cpu reasonably support? This application will serve east coast to west coast with heavy traffic from say 7am to 9am and 2pm to 4pm in each time zone. At what point (or what should I look for) to say, you need more memory, more processors, more servers, etc......????
How does one protect (or build in) a method to deal with index corruptions, etc???? Does that occur in MSSQL? If so, generally, what are causes and fixes?
The application will serve many chapters. Many chapters will be solo (by themselves), but we also expect district wide, where multiple chapters (25 to 75) in one district will use the application. We can expect, during time frames mentioned above, that each chapter will have 200 to 400 transactions per am time and same per pm time.
has anyone had great success with IronSpeed?
Lastly, can anyone suggest some good windows web hosting companies?
Hi i have 2 columns in the same table.....one column retrieves all registered students, the other column retrieved registered students but who have not completed a required survey.
The 2 sql statements are almost the same except that the 2nd one does another comparison at another table....(i.e. where student_id not in (select student_id from other_t).
I am trying to combine the 2 sql statements into a derived table where results will be displayed as follows:
registered students | students(incomplete surveys)
I have a database and in my database there are 5 different tables....
One of the tables is called "dvds" and another one is calles "reports"
What I want to do is, I would like to copy and paste everything in "reports" (column name: dvd) to "dvds" table (column name: name).
And I wan the SQL parameter to check everytime before it writes to "name" column in case that entry is already there. If the entry is already there then ignore and do not write, if it is not there then write it.
I am very sorry about my english and my knowledge on SQL.
Can anyone please help me to product this SQL command?
I have questions regarding theses files TRN, LDF, MDF and BAK.
I have a maintenance plan that backups the .TRN and .BAK everynight in a folder e:/mssqlsrv/MSSQL/Bakup. When I look at the date modified in windows explorer they are exactly like I programmed it in the maintenance plan.
Now when I look in the folder e:/mssqlsrv/MSSQL/Data I see the .LDF and .MDF files and they are way out of date. How do they get copied there? With the maintenance plan? What is the difference between the TRN and the LDF?
How does a restore work? I am so confused? Please explain to me?
I just went through Steve Lasker's slide show on Everywhere (which was very informative) and noticed that when he setup the connection to the Everywhere database it had a .sdf extension. However, when I look at my database using SQL Server Management Studio Express it shows me as having the standard .mdf and .ldf files and *no* sdf file. I thought for a moment that I might be using Express but when I look at the connection properties of my (or what I think is my Everywhere) database I see:
Product Name: Microsoft SQL Server Desktop Engine
Product Version: 8.0.818 SP3
Instance Name: MICROSOFTBCM
If I look at an Express database, I see connection properties of:
Product Name: Microsoft SQL Server Express Edition with Advanced Services
Product Version: 9.0.2047 SP1
Instance Name: SQLEXPRESS
So it appears that I am not use Express but yet, no .sdf files. Can someone tell me about the different file extensions and which ones I might be using? I would assume with the product name of "Microsoft SQL Server Desktop Engine" I am using Everywhere - but maybe not. Please advise.
I'm really new to SQL Server 2K5 and SSIS. I have a task that seems very simple, but being that I'm very rusty with visual studio and SQL, I'm having all sorts of problems.
Here's the scenario:
I have a text file that has 2 columns. AD LOCATION and UPC, I get the text file by combining two spreadsheets in Excel. I need to examine the rows of the flat file and output that data to multiple files. It's a parent child relationship and the output would simply be the children of the parent in it's own text file. It looks something like this: TEXT FILE 1.TXT ADLOCATION UPC 101 XXXXXXXXX1 101 XXXXXXXXX2
I had ms sql server 2000 in my PC. I am very new to ASP.NET as i have been working on PHP n MySQL for the past 3 years. Now i am moving to .NET framework 2. I installed visual studio express 2005 and then sql server 2005. But now that i run sql 2000, it does connect me to localhost. but on sql 2005 i cant. can some one shade some light to this.I have not used SQL server before and am just starting to learn it with ASP.NET 2. I am programmer that likes to code each and every line of codes but ASP.NET is a bit different. Well anyway, cheers
I have a form that submits to multiple tables. After insertion into the first table I need to access the identity key from the record and use is to associate a record in another table. The form element I'm inserting into the second table however, is not a required field so I think I need to check IS NOT NULL first. In my code below I have copied the insert statement for the first table and the conditional and subsequent insert into the 2nd table. I am uncertain where and how I get and use @@identity. The error I'm getting when I run the Check Syntax button is: 'incorrect syntax near @@identity.'I appreciate someone telling me how to correct my syntax. INSERT INTO GPRA_Activities(SubmitDate,StaffId,GPRAId,FreedomID,DocumentDesc,ActivityTitle,ActivityDesc)VALUES (getDate(),@StaffId,@GPRAId,@FreedomID,@DocumentDesc,@ActivityTitle,@ActivityDescSELECT @@identity )if @KeywordId1 IS NOT NULL @@identity smallint, INSERT INTO GPRA_KeywordsUsed ( ActivityId, KeywordId ) VALUES ( @@identity, @KeywordId1 )GO
Hey all, i'm having a bit of an issue with an SQL query i'm trying to make. I'm developing an online video store page, and at the homepage I want to display the top 10 movies rented I have the tables rental and movies, the movies table has moviename and all that stuff, while the rental table has the movieID as a FK, all I want it to do is simply count the movieIDs in the rental table and display that in order.. when I try I'm trying the query.. SELECT movies.movieName, COUNT(rental.movieID) FROM movies INNER JOIN rental ON movies.movieID = rental.movieID GROUP BY movies.movieNameThat works, but it orders by the moviename obviously. When I try to get it to GROUP BY the Count it gives me errors.. How do I get this to work? Thanks
Hi guys, Your help please. First off, I have searched the Forum for answers using the keywords and tried those clues first but with no luck. This one for example: http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q282254
I had a copy of MSDE installed on my machine about 12 month ago but never used it so I uninstalled it. Then I downloaded and installed SQL Server 120-day Evaluation edition a few days ago. When I tried to run SQL Server I get An error 1069 – (The service did not start due to logon failure)…
I’m using Windows XP.
How can I find out what the password is or how can I reset it so the SQL Server logon works?
There is 1 error when i tried to install msde into my window 2003 server web edition. 1. I use command prompt to enter c:\sql2ksp3>setup SAPWD=aA1234567 the errors is "go to the control panel to install and configure system components" How do i install ?
Sql client for 2003 server web edition 2. i tried to install sql client in window 2003 web edition but the msdn cd could not start after i double click on the setupsql.exe. I thought the sql client can be install but not the server on web edition ?