Procedure For Modifying A Field In The Row Located Two Positions Before The Last One
Sep 15, 2006
I want to create a procedure where each time I add a new record to a table I want to set the field “Display” ( BIT ) to “false” in a position that is two rows before the last one. How to do that ?
I have a field called "assescode9" in a table called "Assessment" which has the length of "6" and I want to change this length to 7 or 8 in SQL. I tried right click on the field and modify but when I want to save it says you can not save the changes because it requires a Drop table and recreate or you do not have an option enabled to recreate the table, how do I do this?
I have never done dropping a table and recreate it?
I have about 200 records with a field (fileName) that have an ampersand(&) somewhere in them. I need to update the fileNames and remove all occurances of "&" and replace it with "-"; without modifying any other part of the file name.
Is there a SQL command I can use to update only part of a field?
Hi,Plz, I need some info (SQL2000) :)A stored procedure is like this:"Select table1.id, table1.txt, (select table2.nr from table2 wheretable2.fk_table1=table1.id) as nr where table1.id<>10"The essence here is that "select table2.nr from table2 wheretable2.fk_table1=table1.id" returns either the integer in table2.nr, or NULLif there isnt a match. The whole sentence runs EXTREMELY slow...3-4 sec.What is wrong?"select table2.nr from table2 where table2.fk_table1=table1.id" runs quicklyoutside the stored procedure. The original sentence without the "nr" (Selecttable1.id, table1.txt where table1.id<>10) runs quickly too...But together it slows down dramatically..why? I should mention that thesub-query could return NULL if theres no match in table2...But i cant seewhy that should slow things down (remember - it runs fine outside the SP)?Thx,PipHans---Outgoing mail is certified Virus Free.Checked by AVG anti-virus system (http://www.grisoft.com).Version: 6.0.518 / Virus Database: 316 - Release Date: 11-09-2003
I need help with modifying this procedure to join JobTypeGallery, Remodel on JobTypeGallery.TypeID and Remodel.TypeID. I would like for it the procedure to not allow deleting a record from JobTypeGallery if there are any records in Remodel Table that is associated with JobTypeGallery. Can someone please help me modify this stored procedure? Create PROCEDURE [dbo].[spDeleteJobTypeGallery] @typeid int AS delete from jobTypeGallery where typeID = @typeid GO
I have a sp that I need to modify and having some syntax issues: Here is my script:
SELECT dbo.Batch.ReportDate AS job_date, dbo.Job.CompanyJobId AS job_number, dbo.Item.CompanyItemId AS cost_code,
SUM(CASE dbo.SourceType.CompanySourceTypeId WHEN 'MA' then dbo.ProductionEvent.AlternateQuantity ELSE 0 END) AS qty_received, SUM(CASE dbo.SourceType.CompanySourceTypeId WHEN 'PR' THEN dbo.ProductionEvent.Quantity ELSE 0 END) AS qty_used, SUM(CASE dbo.SourceType.CompanySourceTypeId WHEN 'MA' then dbo.ProductionEvent.AlternateQuantity ELSE 0 END) - SUM(CASE dbo.SourceType.CompanySourceTypeId WHEN 'PR' THEN dbo.ProductionEvent.Quantity ELSE 0 END) AS qty_wasted, SUBSTRING(dbo.Job.CompanyJobId, 1 ,3) AS plant_id
FROM dbo.Batch INNER JOIN dbo.Event ON dbo.Batch.BatchGuid = dbo.Event.BatchGuid INNER JOIN dbo.Job ON dbo.Event.JobGuid = dbo.Job.JobGuid INNER JOIN dbo.ProductionEvent ON dbo.Event.EventGuid = dbo.ProductionEvent.EventGuid INNER JOIN dbo.Item ON dbo.Event.ItemGuid = dbo.Item.ItemGuid INNER JOIN dbo.Source ON dbo.ProductionEvent.SourceGuid = dbo.Source.SourceGuid INNER JOIN dbo.SourceType ON dbo.Source.SourceTypeGuid = dbo.SourceType.SourceTypeGuid left outer JOIN dbo.Product ON dbo.ProductionEvent.ProductGuid = dbo.Product.ProductGuid
WHERE dbo.Item.UnitOfMeasure = 'TN' and dbo.Batch.ReportDate >= @DateFrom and dbo.Batch.ReportDate <= @DateTo
GROUP BY dbo.Batch.ReportDate, dbo.Job.CompanyJobId,dbo.Item.CompanyItemId
Now I need to modify this line:
SUM(CASE dbo.SourceType.CompanySourceTypeId WHEN 'MA' then dbo.ProductionEvent.AlternateQuantity ELSE 0 END) AS qty_received
to include:
and dbo.Product.CompanyProductId LIKE 'ASPH%'
New line should be:
SUM(CASE dbo.SourceType.CompanySourceTypeId WHEN 'MA' and dbo.Product.CompanyProductId when LIKE 'ASPH%'then dbo.ProductionEvent.AlternateQuantity ELSE 0 END) AS qty_received,
I get error saying: Incorrect syntax near the keyword 'and'.
I have a stored procedure that is located in one database and I would like to have it execute against a different database. My problem is when I go to execute it, it is still executing against the database it is stored in. Is it possible to tell this stored procedure when it runs to execute its code against this second database?
This is what I have now, which isn't working:
Code Snippet
use [Database2] exec [Database1].[dbo].usp_SetupDatabaseUser
I have just started studying for an MCTS, to eventually get to MCITP for SQL Server 2k5. I am currently in an Application Support position, working with a large clinical Oracle Database, but mainly on a simple querying basis. The plan is obviously to get away from the Tech Support, towards the DBA and I have been researching the current job market and never once found a job offer that said "offering an entry level or Junior DBA position for those that are just starting"... There's always at least a few years of experience already as a DBA required!
I am wondering how one is supposed to get that experience if he doesn't get a beginners position to start off with?
Any stories from experience? Any hints where to look, how to apply and where maybe?
AA Guyz i want to calculate class position of students from a table.Sample data is as follows...Roll # - Name - Marks1 - ABC - 602 - DEF - 603 - GHI - 574 - JKL - 555 -MNO - 506 -PQR - 53The query should return the following result.Roll # - Name - Marks - POSITION1 - ABC - 60 - 12 - DEF - 60 - 13 - GHI - 57 - 34 - JKL - 55 - 45 -MNO - 50 - 56 -PQR - 53 - 6I want query in MS SQL Server 2000
PRINT cast(111 as decimal(38,35)) / 23 --> 4.82608695652173913043478260869565217
then here
DECLARE @Zähler decimal(38,35) , @Nenner decimal(38,35) SET @Zähler = 111.0 SET @Nenner = 23.0 PRINT cast(@Zähler as decimal(38,35)) / @Nenner --> 4.826086
Of course, in the upper part 23 is implicitly an integer, in the lower example it is declared as decimal. But what if I need to devide by 23.5? Why is dividing by an decimal reducing the results decimal positions?
/*Code below raises following errors:Server: Msg 245, Level 16, State 1, Line 6Syntax error converting the varchar value 'a' to a column of data typeint.*/create table #x (i integer, c char(1))create table #y (c char(1), i integer)insert into #x VALUES (1, 'a')insert into #y SELECT * from #xdrop table #xdrop table #y--CODE COMPLETEIs there a way to use the column names as the basis for the insert asopposed to column position? The key here is that I DO NOT want toSPECIFY COLUMN NAMES (i.e. 'insert into #y (i,c) SELECT * from #x')Regards,Ty
I'm in stage of manually populating a database that requires me to have about a dozen tables open simultaneously. It would be great to be able to save the tables, locations and sizing so that these can be recalled and opened automatically. Currently I do a screen capture, which is pretty lame.
Any suggestions would be welcome.
Config:
Microsoft SQL Server Management Studio 9.00.2047.00 Microsoft Analysis Services Client Tools 2005.090.2047.00 Microsoft Data Access Components (MDAC) 2000.085.1117.00 (xpsp_sp2_rtm.040803-2158) Microsoft MSXML 2.6 3.0 4.0 5.0 6.0 Microsoft Internet Explorer 6.0.2900.2180 Microsoft .NET Framework 2.0.50727.42 Operating System 5.1.2600
Hi,I am getting "Row cannot be located for updating. Some values may havebeen changed" error when I try to update from visual basic with ado.This happens only when set as default locale on the pc other languagethan English.Anybody can help on this¿Thanks*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
Hi! i'm dani, from spain. I´m looking for sombody to help me. The trouble is as i have indicated. I get the next error when my page aspx needs to acced to the SQL Bd: "Error of beginning of session of the user '(null)'. Reason: it is not associate to a connection of confidence SQL Server." I hope a reply. Thanks and greethings.
Hi, I have a asp.net website and bind it with sqlserver but this sqlserver is located another server different from the server my website is located. So how can i bind them with eachother. Thanks in advance...
I am creating a website. where the data to be stored in my server. I had my webspace from some service provider. How can i connect the website and thee database. --> website is deployed at webspace given by the provider. --> database is at my server( located in our office).
****************How can i connect these website and database.*******************
My company recently purchase a NetApp FS870 and we want to move the SQL data files for out production DB. The NetApp is a NAS. Without loggining in to the SQL Server and establishing a drive mapping.
Does anyone know how to connect SQL2K to the remote machine?
We would prefer to use UNC naming to access the share, as leaving servers logged in and open with a mapped drive is a huge secutrity hole, and presents a reliability issue too.
SET nocount ON DECLARE @fileNameNew VARCHAR(1024) -- filename of new error report DECLARE @fileNameOld VARCHAR(1024) -- filename of old error report DECLARE @out_fileDate CHAR(1024) DECLARE @fileDate DATETIME -- used for file name
Every time I try to edit a Control flow or Data flow task I am getting the following error. My toolbox options are all grayed out also.
TITLE: Microsoft Visual Studio ------------------------------
The service System.Windows.Forms.Design.IUIService could not be located.
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%u00ae+Visual+Studio%u00ae+2005&ProdVer=8.0.50727.42&EvtSrc=Microsoft.DataTransformationServices.Design.SR&EvtID=UnableToLocateService&LinkId=20476
Using SQL Express 2005. I want to attach some *.mdf files that are located in a folder other than the SQL Server Data folder (for example, D:MyData). If I do so, then I get an error message that the files can not be updated because they are read only. If I move the files to the SQL ServerData folder then they attach without errors and work fine.
Is there some way I can tell SQL Server to allow the attachments in my other folder as well?
Report A contains a textbox that should navigate to Report B using the Jump To option. Report A and Report B are located in separated folders on the Reporting Server.
SSRS looks for the rdl file within the same folder when using the Jump To option. Is there away to navigate to a report located in a different folder on the same server?
hi , I recently moved from SQL 2000 to SQL 2005. The client side is vb6 and using Dcom dll's hosted on the db server.
I have a table which has oninsert trigger When the recordset is updated in the com class it throws the foll error : "Row cannot be located for updating. Some values may have been changed since it was last read." The same code was working with SQL 2000 !!! Any clues.
i am getting this error when i execute the package in production environment
Source: Select Tickets DTS.Pipeline Description: The module containing "component "Conditional Split" (142)" cannot be located, even though it is registered. End Error Error: 2006-09-01 14:03:40.36 Code: 0xC004706E Source: Select Tickets DTS.Pipeline Description: The module containing "component "Data Conversion" (5863)" cannot be located, even though it is registered. End Error Error: 2006-09-01 14:03:40.36 Code: 0xC004706E Source: Select Tickets DTS.Pipeline Description: The module containing "component "OLE DB Source" (1)" cannot be located, even though it is registered. End Error Error: 2006-09-01 14:03:40.36 Code: 0xC004706E Source: Select Tickets DTS.Pipeline Description: The module containing "component "Excel Destination" (4516)" cannot be located, even though it is registered. End Error Error: 2006-09-01 14:03:40.36 Code: 0xC004706E Source: Select Tickets DTS.Pipeline Description: The module containing "component "Flat File Destination" (6486)" cannot be located, even though it is registered. End Error Progress: 2006-09-01 14:03:40.36 Source: Select Tickets Validating: 0% complete End Progress Error: 2006-09-01 14:03:40.37 Code: 0xC0048021 Source: Select Tickets Conditional Split [142] Description: The component is missing, not registered, not upgradeable, or missing required interfaces. The contact information for this component is "Conditional Split;Microsoft Corporation;Microsoft SqlServer v9; (C) 2005 Microsoft Corporation; All R ights Reserved; http://www.microsoft.com/sql/support;0". End Error Error: 2006-09-01 14:03:40.37 Code: 0xC0047017 Source: Select Tickets DTS.Pipeline Description: component "Conditional Split" (142) failed validation and returned error code 0xC0048021. End Error Progress: 2006-09-01 14:03:40.37 Source: Select Tickets Validating: 20% complete End Progress Error: 2006-09-01 14:03:40.37 Code: 0xC004700C Source: Select Tickets DTS.Pipeline Description: One or more component failed validation. End Error Error: 2006-09-01 14:03:40.37 Code: 0xC0024107 Source: Select Tickets Description: There were errors during task validation. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 2:03:39 PM
Consider a situation. There is a table of submitted 'documents'. They have some attributes. There are assignments to process the things, which have a date they were created. Finally there is a price list which specifies the price according to document features and date, so that the assignment to process a document created at different time will have a different cost. In other words, there is a relation (assignment->document.attribute(s) + assignment.date) -> pricelist.price
Creating relations has the integrity advantages: it is not possible to create an assignment, which price is not defined in the pricelist; precludes the pricelist entry removal if it is referred by any assignments.
Should a view, which combines all the foreign fields into one virtual table, be created to make establishing the reference possible?
I would like to know if is possible copy data from a database located in my hosting to my database located in my pc,but using a store procedure,how can i do that ?.What tool i have to use?