Working With Views
Mar 6, 2001
Does anyone know how effective views work?
I have data in three tables I want to merge, my main condition is I want it to run very fast becasue there will be about 300,000 records.
Should I use a view to merger the information? Or is there a better way
Thanks.
Sola
View 1 Replies
ADVERTISEMENT
Jun 25, 2007
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?
Thanks for the help.
View 3 Replies
View Related
Oct 11, 2007
This is my first post, so if i have not posted things in the best manner please lemme know how to be more informative,clear, so that i can learn.
So i have made a view with the following command
GO
/****** Object: View [dbo].[AppraisalView_C] Script Date: 10/11/2007 12:10:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER VIEW [dbo].[AppraisalView_C]
AS
SELECT a.Counter
,a.DateCreated
,a.DateModified
,a.UserCreated
,a.UserModified
,a.AppraisalDate_C
,a.TypeID_C
,a.Customer_C
,a.Employee_C
,b.Notes_C
,b.Value_C
,b.AppraisalLineItemID_C
,b.AppraisalID_C
FROM dbo.Appraisal_C AS a
INNER JOIN dbo.AppraisalLineItem_C AS b ON a.AppraisalID_C = b.AppraisalID_C
---------------------------------------------------------------------------------------
the program im working on creates the SQL call to read from this view and creates
the following query
SELECT A.[AppraisalDate_C], A.[AppraisalID_C], A.[AppraisalLineItemID_C], A.[Customer_C], A.[Employee_C], A.[Notes_C], A.[TypeID_C], A.[Value_C]
FROM AppraisalView_C A
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?
View 4 Replies
View Related
Jul 7, 2015
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' )
View 6 Replies
View Related
Apr 3, 2006
Fellow database developers,I would like to draw on your experience with views. I have a databasethat includes many views. Sometimes, views contains other views, andthose views in turn may contain views. In fact, I have some views inmy database that are a product of nested views of up to 6 levels deep!The reason we did this was.1. Object-oriented in nature. Makes it easy to work with them.2. Changing an underlying view (adding new fields, removing etc),automatically the higher up views inherit this new information. Thismake maintenance very easy.3. These nested views are only ever used for the reporting side of ourapplication, not for the day-to-day database use by the application.We use Crystal Reports and Crystal is smart enough (can't believe Ijust said that about Crystal) to only pull back the fields that arebeing accessed by the report. In other words, Crystal will issue aSelect field1, field2, field3 from ReportingView Where .... eventhough "ReportingView" contains a long list of fields.Problems I can see.1. Parent views generally use "Select * From childview". This meansthat we have to execute a "sp_refreshview" command against all viewswhenever child views are altered.2. Parent views return a lot of information that isn't necessarilyused.3. Makes it harder to track down exactly where the information iscoming from. You have to drill right through to the child view to seethe raw table joins etc.Does anyone have any comments on this database design? I would love tohear your opinions and tales from the trenches.Best regards,Rod.
View 15 Replies
View Related
Sep 6, 2007
Which is more efficient? One large view that joins >=10 tables, or a few smaller views that join only the tables needed for individual pages?
View 1 Replies
View Related
Jun 28, 2007
Hello.
Newbie here. I've only been using SQL for about a year now and have some minor questions about sql objects that reference other objects.
We have some views which reference other views in the joins. I will call one the primary view and the one being referenced in the joins as the secondary view.
Recently we made changes to the secondary view.
After which the primary views which referenced it would not work because of this change and had to be 'refreshed' by using drop/create scripts which essentially just dropped it and recreated the exact same view. I do not recall the exact error message that was returned other than it seemed to suggest that it could no longer see the secondary view since it had been changed. Nothing in the primary view was changed in any way, just the secondary.
Some here where I work have suggested off hand that this was a recompile of the primary view because the contents of the secondary changed.
My questions are:
1. Exactly why did this happen and is there a proper name for it when it does?
2. The same problem does not seem to occur when we have stored procedures referencing views in the joins which had just been changed. Why is that?
Thanks for any help on the matter. I greatly appreciate it.
View 3 Replies
View Related
Feb 22, 2007
Hello,
to make a report easier I'm developing it using a view of joined views of joined views.
Is there any significant performance penalty as opposed to just having one big select?
Cheers.
View 1 Replies
View Related
Mar 3, 2006
hi
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 ?
Thanks in advance.
View 5 Replies
View Related
Mar 14, 2006
Hello There,I'm trying to create a view that has calculations dependent oncalculations, where the problem resides is that each time I make acalculation I must create an intermediate view so I can reference aprevious calculation.for example lets say I have my_table that has columns a & b. now I wanta view that has a & b, c = a + b, and d = c + 1.this is grossly simplified, the calculations I actually use are fairlycomplex and copying / pasting them is out of the question.so what I have is my_view_a which makes column c, and my my_view_finalwhich makes column d (however, in my real application I have 5 of theseviews, a/b/c/d/e/)is there anyway I can consolidate all these views into one? I wasthinking of using a stored procedure with temp tables or somethingalong those lines.I just which I can use the aliases that I create for c in d in onestep.any insight would be greatly appreciated.
View 5 Replies
View Related
Jan 7, 2004
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)
Try
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@UserId", SqlDbType.VarChar).Value = UserId
cmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = TextBox1.Text
[...etc more parameters...]
cmd.Parameters.Add("@Id", SqlDbType.VarChar).Value = ContactId
cn.Open()
cmd.ExecuteNonQuery()
Label1.Text = "done"
cn.Close()
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.
Please I would appreciate any advice...
View 2 Replies
View Related
Apr 15, 2008
Hi everyone, I have a problem like this . I have tables Coursegroupcode, which has groupname, codeI have Courses That has Coursename, its code(group code),Term, Course Number Enrollment table which has Foreign keys Term,Course NUmber , SSN I need to get a view like thisI should list all the coursecodes and people enrolled for each course code for selected terms Course Table Primary keys(TERM,COUSE Number)Enrollment Table(Foreign keys) TERM ,COURSE NUMBER, SSNplease help
View 9 Replies
View Related
Apr 7, 2005
Hi!
I need to know if i can build an aspx file on top of an sql view? I
can only see my tables when i connect to the database....
Collette.
View 3 Replies
View Related
Oct 18, 2005
Can SQL Views insert to the tables they are created from?I have a database that is not well structured. It has a lot of redundency. What I want to do is create a SQL View that brings in all the data I need and have my application use that new SQL View instead of the data tables. Then I want to be able to insert new information to a SQL View that actualy gets inserted into the tables that the SQL Viewer is created from.Can this be done?Does this make any sense?
View 1 Replies
View Related
Mar 26, 2001
I have a query which unions the four select statements.....
the select statements are joined with other tables and views.....
When i execute the query i get ODBC timeout error........
But the strange thing is that if i execute the view individually once and again execute the query it works fine.......and later it justs works fine....
Can anyone tell why is it like that.......
Thanks,
Sajai.
View 1 Replies
View Related
May 23, 2000
Is there a performance hit running a sp against a view versus a base table. The view just excludes
several of the records based on some criteria, and all the data I will be retreiving is included in
the view. Or should I just stick my criteria in the SP to exclude the data?
View 1 Replies
View Related
Jun 19, 2000
Is there a way to imbed "iif"-like logic in a SQL view? "case when" works in regular queries, but apparently is not supported in views...
View 1 Replies
View Related
Aug 14, 2002
I have some rather complex views to work with. Do they slow you down? Would it be better to move a view into a stored procedure? Is there any difference between these three solutions?
<B>1.Using views:</b>
Create view X
As
Select Col1, Col2, Col3 from Table1
Go
Create view Y
As
Select Col1, Col2, Col3 from Table2
Go
Create proc Z
As
Select X.Col2, X.Col3, Y.Col2, Y.Col3
From X inner join Y on X.Col1 = X.Col1
GO
<b>2.Using just a stored proc:</b>
Create proc Z
As
Select X.Col2, X.Col3, Y.Col2, Y.Col3
from
(Select Col1, Col2, Col3 from Table1) X inner join
(Select Col1, Col2, Col3 from Table2) Y on X.Col1 = Y.Col1
<b>.Joining tables</b>
Create proc Z
As
Select Table1.Col2, Table1.Col3, Table2.Col1, Table2.Col3
FromTable1 inner join Table2 on Table1.Col1 = Table2.Col1
go
Thank you!
View 1 Replies
View Related
Aug 1, 2001
I am struggling with setting up views in SQL Server 7.0 and 2000. What types of views are available.
I have one database with 112 tables and 2308 fields.
Thanks in Advance
View 1 Replies
View Related
Jun 9, 2004
I have created a database connected to a GUI using VB 6.0. When editing the views from the front end, do the tables also get updated
Thanks
View 3 Replies
View Related
Aug 17, 2004
Hi,
Is there a way to create a view with read only option. i.e the view should not allow the user to perform insert, update or delete action on it.
Please advise,
Thanks,
Sam
View 1 Replies
View Related
Dec 23, 2004
Is there any kind of lock on a view in ms sql database?
what happens if one of my users is looking at the view and another one is adding something to the database?
Thanks.
View 3 Replies
View Related
Sep 26, 2005
My First time building "Views" in SQL...... I'm trying to figure out how to return a 1 instead of a two when I Count the number of records that return inn my view.
here's what I have;
SELECT TOP 100 PERCENT dbo.tbl_ProcTimesheet.idCalendar, dbo.tbl_ProcTimesheet.erNum, dbo.tbl_ProcTimesheet.PayDate,
COUNT(dbo.tbl_ProcTimesheet.TransAmt) AS Shifts, dbo.tbl_ProcTimesheet.[Employee Number], dbo.tbl_ProcTimesheet.YCode,
dbo.tbl_ProcTimesheet.XCode, dbo.tbl_ProcTimesheet.ZCode, dbo.tbl_ProcTimesheet.eeLink
FROM dbo.tbl_ProcTimesheet INNER JOIN
dbo.tbl_SysVarRestEeShiftPayCodes ON dbo.tbl_ProcTimesheet.Code = dbo.tbl_SysVarRestEeShiftPayCodes.PayCode INNER JOIN
dbo.tbl_SysVarRestEeShiftRules ON dbo.tbl_ProcTimesheet.YCode = dbo.tbl_SysVarRestEeShiftRules.YCode AND
dbo.tbl_ProcTimesheet.ZCode = dbo.tbl_SysVarRestEeShiftRules.ZCode
WHERE (dbo.tbl_ProcTimesheet.Sequence <> N'0') AND (dbo.tbl_ProcTimesheet.Week < 3)
GROUP BY dbo.tbl_ProcTimesheet.idCalendar, dbo.tbl_ProcTimesheet.erNum, dbo.tbl_ProcTimesheet.PayDate, dbo.tbl_ProcTimesheet.TransAmt,
dbo.tbl_SysVarRestEeShiftRules.DailyHours, dbo.tbl_ProcTimesheet.[Employee Number], dbo.tbl_ProcTimesheet.XCode,
dbo.tbl_ProcTimesheet.YCode, dbo.tbl_ProcTimesheet.ZCode, dbo.tbl_ProcTimesheet.eeLink, dbo.tbl_ProcTimesheet.Sequence,
dbo.tbl_ProcTimesheet.Week
HAVING ('IIf' > '1,1,0') AND ('if' > '1,1') AND (dbo.tbl_ProcTimesheet.erNum LIKE N'5648 ') AND (SUM(dbo.tbl_ProcTimesheet.TransAmt)
>= dbo.tbl_SysVarRestEeShiftRules.DailyHours) AND (dbo.tbl_ProcTimesheet.PayDate = CONVERT(DATETIME, '2005-09-06 00:00:00', 102)) AND
(COUNT(dbo.tbl_ProcTimesheet.TransAmt) > 0)
ORDER BY dbo.tbl_ProcTimesheet.PayDate, dbo.tbl_ProcTimesheet.[Employee Number]
When it counts shifts, I only want to return a maximum of i, as in either you had a shoft that day, or not. I gave up trying to figure out the "IF" string in SQL, and for the life of me I can not figure this out.
Does anyone know a good site with info on how to construct an SQL View?
View 12 Replies
View Related
Jun 1, 2004
Hi,
I'm creating a stored procedure that will Drop all views when executed, this is what i have...
DECLARE crsViews CURSOR FOR
SELECT
name AS strViews
FROM
__________ <what do i put here?
WHERE
type ='U'
AND NAME LIKE'V%'
Thanks for any help!
View 2 Replies
View Related
Apr 21, 2008
MS SQL Server 2005
What happens if 2 or more users use the same View at the same time or while other user is using it, normally from Crystal Reports 10
It rebuilds again? Or?
Thanks
View 2 Replies
View Related
Apr 25, 2008
Hi,
I have a SQL server: SQL2005
2 databases
db_repl: contains replicated data from mainframe
db_my: my database
db_my.vwRepl_WorkOrders: Select 1,2,3 from db_repl.dbo.WorkOrders
db_my.vwWorkOrdersOpen: select 1,2,3 from db_my.vwRepl_WorkOrders where Status=1
which approach is more optimal to do in order to find open work orders from Texas:
[select 1,2,3
from db_repl.dbo.workOrders where Status=1 and State=1
or
select 1,2,3
from db_my.vwWorkOrdersOpenwhere where State=1]
Is it best practice to use 'subviews' that acess db_repl directly or acess views in my_db that acess db_repl (2 hops or more if views call other views that call other views) Answer might be the obvious but just in case I am missing something here .
Thanks!
View 2 Replies
View Related
Apr 17, 2007
Can someone tell me when I would get an error like the one below:
"Update or insert of view or function failed because it contains a derived or constant field."
Here is how I create a VIEW
CREATE VIEW vSample
AS
SELECT ilm.ITEM_ID,
CAST (ilm.CURRENT_QUANTITY AS INT) CURRENT_QUANTITY
FROM SAMPLE_1 AS ilm INNER_JOIN SAMPLE_2 AS ilm2
on ilm.ID = ilm2.ID
Now, I am trying to update data using the view
UPDATE [vSample] SET [CURRENT_QUANTITY] = 598.00 WHERE (1 = 1)
I have tried casting the number 598.00 as int and no luck.
Can someone please help or guide me on this problem?
Thanks,
Javid
View 4 Replies
View Related
Nov 6, 2007
Hello,
I am kind of new to using views. What types of queries can i use with view (i.e. select, insert, update, delete) in mssql 2000?
DigitalSolvers
Yahoo: DigitalSolvers
MSN Live: lew26@msn.com
Skype: DigitalSolvers
View 4 Replies
View Related
Nov 17, 2007
I've created views ProductsSold that will list all the products- ProductID and quantity, that were ordered (OrderDate) in last twenty four hours between getdate()-1 and getdate().
create view ProductsSold
as
select orderdetails.ProductID, orderdetails.OrderQty, orders.OrderDate
from OrderDetails inner join Orders
on OrderDetails.salesOrderID = Orders.salesOrderID
where OrderDate > dateadd(d, -1, getdate()) and OrderDate < getdate()
i just wonder if there is a more simpler way to query it?
View 17 Replies
View Related
Sep 11, 2006
Hi all,We have a big table connected to a web server, and I want the number ofrows to be limited that get returned.So I could do something like this:select top 10 *from objectorder by codeI then realised looking at the help file, because the "order by" clauseis set the SQL Server has to build the complete dataset, do the orderby and then filter it to the first ten rows.So I was wondering if I put the query into a view like so :create view vw_object asselect top 10 *from objectThen ran the query like so:select *from vw_objectorder by codewould the SQL server just get the top 10 rows from the view first, thenapply other order by on it afterwards?
View 7 Replies
View Related
Jul 20, 2005
I've searched for information on this but so far have not been able tofind any advice.We have several databases running on SQL Server 7.0 that areessentially identical in structure but are used for different data.There are several tables that are identical in all databases.Currently, we make updates to those tables in one database andpropogate the new versions of those tables to the other databases.The maintenance to keep after this is somewhat problematic in that theuser, or dba, has to initiate some action to apply the update to alltables anytime a change is made. An idea I have to simplify thisprocess is create views that access the data in a central location.I would create a database for these shared tables, and replace thetables in each individual database with a view of the same name. Theother nice thing about this solution is it is transparent toapplications that rely on this data. I contemplated using the shareddatabase by making code changes to change all the references to thosetables to DB..table, but that would take considerable man hours. Cananyone give me a reason why this would not be a good idea? Thanks.
View 3 Replies
View Related
Apr 26, 2006
I am supposing that SQL Mobile 2005 does not support views in its database? It is odd that all development tools show the tab of Views, but I cannot seem to find how someone would create one there. Is there a reference someone can point me to, or just reply to the forum to set me straight.
Thanks.
View 4 Replies
View Related
Oct 25, 2006
Hi
In acces i have make a view witkh this code
<> #15:30:00#
How can i write this in a view on the sql sever
I have try with <> '15:30:00'
But it dosn't work , my field i a datetime( maybe i shal change that??
Hope someone can help
Regards
alvin
View 3 Replies
View Related