WHERE [AppraisalView_C].[AppraisalID_C] = 'APP-000006'
but I end up getting the dreaded "Msg 4104, Level 16, State 1, Line 1 The multi-part identifier "AppraisalView_C.AppraisalID_C" could not be bound." error....
I cant change the Query that is called, but i can change the view, what is wrong?
Hi all, Thanks in advance to any contributions to my question.Im running SQLServer 2000 in a Win 2000 Server env.Background:==========The database has many views that range from simple to complex joins ontables.The selection criteria is fixed eg. 'Where TaskTypeIdent = 2204 andOutcomeId = 123 or 2322 or 1222 andCicType = 87878 ... etc etcRequirement:===========Now what I would like to do is be able to change the 'where =' valuepart ie. 2204, dynamically if and when required, and it will berequired.In other words there won't be a DBA handy to do this when it changeshence I would like to write a front end UI to allow the user to easilymanage this.There are upwards of 200 views like this.Question:========Where in the system metadata can I access (if possible) the source ofthe View such that I can update it with the new values. eg. 'WhereTaskTypeIdent = 7627 and OutcomeId = 2322 or 94847 or 989 and CicType =1111 ... etc etcMany thanksPaul*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
I am trying to move my application (asp.net) from a non-paged select to a paged query.
I am having a problem. Below is my Stored Procedure. The first Query in the procedure works...the rest (which are commented out ALL work interactively, but fail when the program tries to access....The ONLY THING I change is the stored procedure I switch the comment lines to the non-paged procedure and it works, I try to use the any of the paged procedures and it fails with the same error (included below)
I can't see where any of the queries are returning different results. I have also included the program abort that happens, it is the same for all of the paged queries.
ALTER PROCEDURE dbo.puse_equipment_GetAllTypedEquipment ( @EquipmentTypeId int, @StartRowIndex int, @MaximumRows int ) AS
-- ************************************************************************************************ -- Non-Paged OUTPUT -- THIS WORKS!!!!! SET NOCOUNT ON SELECT Equipment.*, EquipmentType.Name as EquipmentType, EquipmentCategory.Name as Category FROM Equipment INNER JOIN EquipmentCategory ON EquipmentCategory.CategoryId = Equipment.CategoryId INNER JOIN EquipmentType ON EquipmentType.EquipmentTypeId = Equipment.EquipmentTypeId where Equipment.EquipmentTypeId = @EquipmentTypeId AND Equipment.IsDeleted = 0
/* -- ************************************************************************************************ -- Using a Temp Table --THIS WORKS INTERACTIVELY, But NOT When Called by the program SET NOCOUNT ON create table #PagedEquipment ( IndexId int IDENTITY(1,1) Not NULL, EquipId int )
-- Insert the rows from Equipment into the PagedEquipment table Insert INTO #PagedEquipment (EquipId) select EquipmentId From Equipment WHERE IsDeleted = 0
SELECT #PagedEquipment.IndexId, *,EquipmentType.Name as EquipmentType, EquipmentCategory.Name as Category FROM Equipment INNER JOIN #PagedEquipment with (nolock) on Equipment.EquipmentId = #PagedEquipment.EquipId INNER JOIN EquipmentCategory ON EquipmentCategory.CategoryId = Equipment.CategoryId INNER JOIN EquipmentType ON EquipmentType.EquipmentTypeId = Equipment.EquipmentTypeId Where #PagedEquipment.IndexId Between (@StartRowIndex) AND (@StartRowIndex + @MaximumRows +1) */
/* -- ********************************************************************************************** --Using the With to create a temp table (in memory)..works interactively but fails when --called by the application.. --THIS WORKS INTERACTIVELY, But NOT When Called by the program Set NOCOUNT ON; With PagedEquipment AS ( SELECT EquipmentId, ROW_NUMBER() OVER (Order by Equipment.EquipmentId) AS RowNumber FROM Equipment WHERE EquipmentTypeId = @EquipmentTypeId AND IsDeleted = 0 )
SELECT RowNumber, Equipment.*, EquipmentCategory.Name as Category, EquipmentType.Name as EquipmentType FROM PagedEquipment INNER JOIN Equipment ON Equipment.EquipmentId = PagedEquipment.EquipmentId INNER JOIN EquipmentCategory ON Equipment.CategoryId = EquipmentCategory.CategoryId INNER JOIN EquipmentType ON Equipment.EquipmentTypeId = EquipmentType.EquipmentTypeId WHERE PagedEquipment.RowNumber Between (@StartRowIndex+1) AND (@StartRowIndex+1+@MaximumRows) return -- ******************************************************************************************* */
/* -- ******************************************************************************************** --nested selects --THIS WORKS INTERACTIVELY, BUT NOT WHEN CALLED FROM THE PROGRAM SET NOCOUNT ON Select * From ( Select Row_Number() OVER (Order By Equipment.EquipmentId) as RowNumber, Equipment.*, EquipmentType.Name as EquipmentType, EquipmentCategory.Name as Category FROM Equipment INNER JOIN EquipmentCategory ON EquipmentCategory.CategoryId = Equipment.CategoryId INNER JOIN EquipmentType ON EquipmentType.EquipmentTypeId = Equipment.EquipmentTypeId where Equipment.EquipmentTypeId = @EquipmentTypeId AND Equipment.IsDeleted = 0 ) equip Where equip.RowNumber between (@StartRowIndex+1) AND (@StartRowIndex + 1 + @MaximumRows ) -- ************************************************************************************************ */
Server Error in '/pUse' Application. --------------------------------------------------------------------------------
Arithmetic overflow error converting expression to data type int. 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: Arithmetic overflow error converting expression to data type int.
Source Error:
Line 148: { Line 149: List<EquipmentDetails> equipment = new List<EquipmentDetails>(); Line 150: while (reader.Read()) Line 151: equipment.Add(GetEquipmentFromReader(reader)); Line 152: return equipment;
Source File: c:Documents and SettingsBrianDesktoppuseApp_CodeDALEquipmentEquipmentProvider.cs Line: 150
Stack Trace:
[SqlException (0x80131904): Arithmetic overflow error converting expression to data type int.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +925466 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800118 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932 System.Data.SqlClient.SqlDataReader.HasMoreRows() +150 System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) +212 System.Data.SqlClient.SqlDataReader.Read() +9 PredominantUse.DAL.Equipment.EquipmentProvider.GetEquipmentCollectionFromReader(IDataReader reader) in c:Documents and SettingsBrianDesktoppuseApp_CodeDALEquipmentEquipmentProvider.cs:150 PredominantUse.DAL.Equipment.SqlClient.SqlEquipmentProvider.GetTypedEquipmentList(Int32 EquipmentTypeId, Int32 StartRowIndex, Int32 MaximumRows) in c:Documents and SettingsBrianDesktoppuseApp_CodeDALEquipmentSqlClientSqlEquipmentProvider.cs:103 PredominantUse.BLL.Equipment.GetTypedEquipment(Int32 EquipmentTypeId, Int32 StartRowIndex, Int32 MaximumRows) in c:Documents and SettingsBrianDesktoppuseApp_CodeBLLEquipmentEquipment.cs:259 PredominantUse.BLL.Equipment.GetTypedEquipment(Int32 EquipmentTypeId) in c:Documents and SettingsBrianDesktoppuseApp_CodeBLLEquipmentEquipment.cs:238
-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
Hello, I've been developing a web application with a Java backend that connects to a SQL Server database with the JDBC driver 1.1 for a while now. Until now, everything was working fine. Now I had to add Windows authentication to the application. After reading through the JDBC online help, I added the property integratedSecurity=true to the connection string and copied the sqljdbc_auth.dll to the windowssystem32 directory of the system with the backend. Logging in works fine, but the problem is that SQL statements that work on views throw SQLServerException errors, the message is Invalid object name '(name of the view)'
It doesn't matter if a user is configured to log in via windows authentication or via SQL server authentication. I need to access those views instead of the real tables because this is part of my security concept, the database creates views for each user based on his role.
Is this a known problem with the JDBC driver or a configuration issue?
I have some Partitioned Views and on all queries using a table for the in clause, table elimination isn't happening.
Check Constraint is on the oid column
This works as expected, only goes to 2 tables; SELECT * FROM view_oap_all WHERE oid IN ( '05231416529481', '06201479586431' )
This works as expected, only goes to 2 tables; SELECT * FROM view_oap_all WHERE oid IN ( SELECT oid FROM owners WHERE oid IN ( '05231416529481', '06201479586431' ) )
This is checking all tables (headingnames are unique), ive tried this for the last 3 hours on many different tables containing the oid column.
Unless I write the oid as in the above queries it just doesn't work. SELECT * FROM view_oap_all WHERE oid IN ( SELECT oid FROM owners WHERE headingname = 'TestSystem' )
What specific permissions do you need to be able to view information_schema views? I thought public role had permissions to select on these views, but this is not the case? What do I do?
my developers have db_reader, db_writer, and db_ddladmin. They do not have db_owner. If I make them Sysadmin in sql they can view them, but that doens't fit in our security setup we have. THoughts?
I created a view V1 that uses an outer join with a table and calls a sub-view VS1 (ds_proj_report_date) which uses an inner join) and does an inner join with VS1. I also created another view V2 that uses inner join but does not call the sub-view VS1.
When I run the two views as below it works fine
Select * from V1 Union Select * from V2
I then created another view V3 of the above union as
Create view V3 As Select * from V1 Union Select * from V2
Now when I run select * from V3, I get the following error. Joined tables cannot be specified in a query containing outer join operators. View or function 'ds_proj_report_date' contains joined tables
what the program will do if we caught that exception .. i need some suggestions ... i got this exception(String or binary data would be truncated. The statement has been terminated.).. will it affect the functionality of the program...
i've been asked to re-write a sql view. the view itself contains several calls to other views (embedded). is there a way to get around using embedded views. I've written the same query up using temp. tables but obviously temp. tables can't be used in views?
Is there any special things I should be looking for?
guys, ive never worked with Views before so forgive me. i know how to create one, and that it creates a virtual table in memory, but i've got one small question.
if i create a view:
CREATE view dbo.myView as select Distinct FirstName,LastName from SomeTable
When ever i reference that view, such as Select FirstName,LastName from myView where LastName like 'Jo%'
does that View Refresh itself??
in other words does it run each time i Reference it??? or is it static from when i created it.
Wouldnt it be easier just to use a #TempTable or some other Table thats used to hold a few values?
I am creating a view for the table: bellus=# select * from host_application_definition; id | type_value | connection_value | group_value | application_value | host ----+------------+------------------+-------------+-------------------+----
From the table meta_host_types;
id | value | types | name ----+-------+-----------+-------- 1 | agm | host-type | Rencid
I would like to seperate value into type_value and connection_value, because it holds both values.
Hi guys,I've been asked to re-write a sql view. The view itself containsseveral calls to other views (embedded). Is there a way to get aroundusing embedded views. I've written the same query up using temp.tables but obviously temp. tables can't be used in views?Is there any special things I should be looking for?
I'd like to get results from ZTest_Contract being my result set, and would like to combine the subquery (which gets the Max) into the primary view ZTest_Contract.
CREATE VIEW [dbo].[ZTest_Contract] AS Select M.CUSTNMBR, M.ADRSCode, M.Contract_number, M.MaxWSCONTSQ, M.Equipment_id,
I have 2 views which contain the following fields: EVENT, WEEK, SUBSCRIPTION, QTY, GROSS_AMOUNT, SEASON
The 2 views differ by SEASON. I'm attempting to combine the 2 views in to a single view or table grouping by EVENT, WEEK and SUBSCRIPTION:
EVENT, WEEK, SUBSCRIPTION, Q6 (qty of season 1), A6 (gross_amount of season 1), Q7 (qty of season 2), A7 (gross_amount of season 2)
Below is my select command:
------
SELECT TOP 100 PERCENT dbo.vw_SEASON06.EVENT, SUM(dbo.vw_SEASON06.QTY) AS Q6, SUM(dbo.vw_SEASON06.GROSS_AMOUNT) AS A6, SUM(dbo.vw_SEASON07.QTY) AS Q7, SUM(dbo.vw_SEASON07.GROSS_AMOUNT) AS A7, dbo.vw_SEASON06.WEEK, dbo.vw_SEASON06.SUBSCRIPTION
FROM dbo.vw_SEASON06 FULL OUTER JOIN dbo.vw_SEASON07 ON dbo.vw_SEASON06.WEEK = dbo.vw_SEASON07.WEEK AND dbo.vw_SEASON06.SUBSCRIPTION= dbo.vw_SEASON07.SUBSCRIPTION AND dbo.vw_SEASON06.EVENT = dbo.vw_SEASON07.EVENT
GROUP BY dbo.vw_SEASON06.EVENT, dbo.vw_SEASON06.WEEK, dbo.vw_SEASON06.SUBSCRIPTION
ORDER BY dbo.vw_SEASON06.EVENT
-----
This creates the view but there are some issues. If an 'EVENT' exists in dbo.vw_SEASON07.EVENT and doesn't exist in dbo.vw_SEASON06.EVENT the value of the field 'EVENT' is set to NULL because the 'EVENT' name is returned from dbo.vw_SEASON06.EVENT. The same issue exists for 'SUBSCRIPTIONS' and 'WEEK'.
How can I create a single view/table that will include all the data from these 2 views without the NULL values in EVENT or SUBSCRIPTION?
I have a DB migrated from SQL Server 2000 to SQL Server 2005 and I have a strange problem that I don't find any reason.
I make a simple SQL Query with one table showing all the fields and everything goes well. But when I insert another auxiliar table and showing one field, then I can't change any field of the main table. SQL Server shows me the message Read Only Cell. Why this happens? This problem didn't happen in SQL Server 2000.
The select sentence that works:
SELECT Notas_Estructura.* FROM Notas_Estructura
The previous Select sentence modified that doesn't work:
SELECT Notas_Estructura.*, Alumnos.Apellido1, Alumnos.Apellido2, Alumnos.Nombre FROM Notas_Estructura INNER JOIN Alumnos ON Notas_Estructura.CodAlumno = Alumnos.CodAlumno
I need to create a new login with SELECT rights so the users can view all tables with no UPDATE, DELETE, OR INSERT rights. But this user needs to be able to CREATE VIEWS. I have assigned the user to the Public role and gone in and modified Securables for the Database to be able to CREATE VIEW. When I connect using my new user and try to create a view, I get the error message: CREATE VIEW permissions denied in database 'test01'.
Hi all, i have a very general question about databases. What is the advantage and disadvantage of using a heavily indexed database?
The advantage i could think is that search operations will be fast. The disadvantage (according to me who is a newbie) is that the size of the database will increase.
My teacher however is not very happy with this answer and wants me to research more. Any help will be greatly appreciated.
What are my options to find heavily accessed DBs on a server? I know I can do this by profiler and some counters. Is there any tool which gives me this information easily?
------------------------ I think, therefore I am - Rene Descartes
There is a view in our replicated SQL-2000 database, that returns all user tables and views with replication state (0 if not included into publication, 1 if included):
Code Snippet
CREATE VIEW [dbo].[ViewREPL_PublishedObjects]
AS
SELECT TOP 100 PERCENT
CASE [xtype]
WHEN 'U' THEN 'Table'
WHEN 'V' THEN 'View'
ELSE NULL END AS [Object Type],
[name] AS [Object Name],
CASE WHEN [replinfo] = 0
THEN 0 ELSE 1
END AS [Replicated]
FROM [sysobjects]
WHERE
[xtype] in ('U', 'V')
AND [status] > 0
ORDER BY
(CASE [xtype]
WHEN 'U' THEN 1
WHEN 'V' THEN 2
ELSE 10
END),
[name]
Now we need to upgrade our database to SQL-2005, but [sysobjects] table have been changed, so neither Replicated state could be determined according on [replinfo] column value, nor User/System object according on [status].
So, I need a view with same functionality, that will work under SQL-2005 and 2008.
I have the view below and if I use vwRouteReference as the rowsourcefor a combo box in an MS Access form or run "SELECT * FROMvwRouteReference" in SQL Query Analyzer, the rows don't come throughsorted by Numb.Everything I've read on the web suggests that including the TOPdirective should enable ORDERY BY in views. Does someone have an ideawhy the sorting is not working correctly for this particular view? thanks.CREATE VIEW vwRouteReferenceASSELECT TOP 100 PERCENT tblItem.ID,tblItem.Numb + ' - ' + tblQuestion.DescrPrimary AS FullName,tblItem.Numb, tblQuestion.DescrPrimary AS TypeFROM tblItem INNER JOIN tblQuestionON (tblItem.ID = tblQuestion.Item_ID)WHERE (((tblItem.Category_ID)>0))UNIONSELECT TOP 100 PERCENT tblItem.ID,tblItem.Numb + ' - ' + tblItem.Type + ' : ' + tblItem.Class AS FullName,tblItem.Numb, tblItem.Type + ' : ' + tblItem.Class AS TypeFROM tblItemWHERE (((tblItem.Type) = 'Assignment' OR (tblItem.Type) = 'Check' OR(tblItem.Type) = 'Route'))ORDER BY tblItem.Numb
I have a view created using the following code. The view works perfectly but does not order by the name column as I've asked it to do. In the view designer if I click on execute then the order is applied but if I save the view and run it externally (i.e. in an ASP page or within the management terminal) it does not order correctly and seems to order by the Id column.
Any help would be much appreciated. Here's the code:
SELECT TOP (100) PERCENT dbo.Members.DivisionID, COUNT(*) AS Members, dbo.Country.Name FROM dbo.Members INNER JOIN dbo.Country ON dbo.Members.DivisionID = dbo.Country.CountryID AND dbo.Members.CountryID = dbo.Country.CountryID GROUP BY dbo.Members.DivisionID, dbo.Country.Name ORDER BY dbo.Country.Name
And another, more simpler view, that doesn't sort as it's supposed to.
SELECT TOP (100) PERCENT CountryID, Name, RegionID, IsActive, HasFlag, URL, Comments FROM dbo.Country ORDER BY Name
I have a user who needs access to views like(dbo.viewnameabc1,dbo.viewnameabc2 and so on...) dbo.viewnameabc* and anytime the user creates the view he already have the permission to view those views....
Hi allWe have some tables with a couple of layers of very simple views built ontop. In the table are maybe 6 columns and about 15000 records. The firstview cobines the data in the table with some other data from a lookuptable. The second view does some sorting on the first view using certaindates . They have worked fine for well over a year now.Until this morning that is... the views stopped returning the full set ofresults- even the very simple one that sits just above the table. The viewreturned the core of the data from the main table, but nothing from thelookup table.In order to get them to work we had to delete each view (using access frontend to do this), and then recreate it with exactly the same SQL text. I amguessing this causes SQL Server to recompile it. As soon as view 1 had beenrecreated it worked, but view 2 still failed, again rebuilding view 2 itstarted working.The only thing I can think of is that this morning I added 2 new fields tothe base table, but I'm sure I've done this before without any (noticable)problems.any thoughts as to why it happened would be welcome, I am a bit nervousnow...thanksAndy
Hi, I'm rather new here, but I would like to add the question here since this project encompasses a lot of areas of ASP.NET (Visual Studio 2005). My project is about a site which is heavily based on Search Option. So basically, users will just have to fill in the forms, click search and it will search throughout the database. For example... The website is about a property listing. The database (based on SQL Server, can be created right through the Visual Studio 2005) consists of these attributes: ID, Property Name, Property Location, Property Cost. The user may search based on Name, Location and Cost. For the cost, there are two forms to fill: the lowest cost allowed and the highest cost allowed.All these are put on the Master Page (Located on the top). When the button Search is clicked, it will display the records that match the forms filled, in the main page located below the Master Page.If anyone can help me with this, I'll be very grateful. Thank you very much.
I am just starting with Sql Server reporting, but I can't get interactive sort to work for columns with aggregate fields.
I am using the following query for DataSet:
SELECT Store.ID as StoreID, Store.Name as StoreName, COUNT(*) as NumReservations, SUM(Appointment.TotalBeforeTaxes) as Revenue FROM Store LEFT JOIN Appointment ON Store.ID=Appointment.StoreID GROUP BY ALL Store.ID, Store.Name ORDER BY Store.Name ASC
For report, I am using tabular data view. Interactive sorting works great for StoreID, StoreName, but doesn't work for NumReservations and Revenue fields. I turned it on for all 4 columns.
We run a multiple database environment, with two of the databases receiving most of the user activity. (both write and read). These databases are roughly 25gb each and receive roughly the same amount of activity. Currently both of the .mdf files sit on the same drive shelf. Their log files are located on a separate drive shelf.
Debate: We have an extra fiber channel shelf available for us to use. We are not having too many problems related to performance, but we are always seeking for different ways to increase application/server performance. The debate centers on what to do with the extra shelf. There are two different suggestions on how best to use the shelf. They are:
1)Separate the .mdf files for two most utilized databases. This would separate the databases and the I/O associated with each across two different shelves
2)Break off the indexes for all 5 databases on to the extra shelf. This would leave all the .mdf files on the same shelf, but it would move the I/O associated with the indexes to a different shelf.
Can anyone provide the pros and cons of either suggestion? I would like to see arguements for either side.
Hi everyone, If I have a table with some indexes on the foriegn keys and these indexes are heavily fragmented (80%+), is it normal for queries to return incorrect results?
For example if I had a table called Customer( CustID, Name) and Orders (OrderID, CustID, Product, Date). Lets say I have a non clustered index on CustID in Orders table, and the clustered indexes are Customer.CustID and Orders.OrderID
If the non clusterd index on Orders.CustID becomes heavily fragmented and I am querying the Orders table with TSQL "SELECT * FROM Orders where CustID = @CustID" I sometimes get missing data or incorrect results. In one case all orders for a particular year were missing, but if I queried using OderID they were returned. Rebuilding the index fixed the problem.
I know the index should be rebuilt or reorganized depending on the fragmentation but if one happened to become this fragmented should it start returning incorrect data?