Showing posts with label view. Show all posts
Showing posts with label view. Show all posts

Friday, March 30, 2012

No Lock

Lets say i have a view.

vuTestingNoLocks

this view looks like this...

Create View vuTestingNoLocks as

SElect *

From dbo.Employees

inner Join dbo.EmployeeTerritories on EmployeeTerritories.EmployeeID = Employees.EmployeeID

If I select from this view using Select * From vuTestingNoLocks (NOLOCK)

Does the (nolock) command propegate down through the tables? Meaning will it scan tables that are locked still ignoring their locks?

I think you should be able to test it out and come to your own conclusions. Let me know what you are going to interpret from this.

In one window, create these tables, populate dummy data and create the view

Code Snippet

--Start of window1

create table t1 (t1id int identity(10,10),

t1code char(2)

)

create table t2 (t2id int,

t2name varchar(10)

)

insert t1 select 'AB'

insert t1 select 'BC'

insert t1 select 'CD'

insert t2 select 10, 'Group AB'

insert t2 select 20, 'Group BC'

insert t2 select 30, 'Group CD'

create view vw_t1_t2 as

select t1id, t1code, t2name

from t1 join t2

on t1.t1id = t2id

--End of window1

--start of window2

--we are setting up to take exclusive lock

begin tran

update vw_t1_t2

set t1code = 'KK'

--end of window2

--start of window3

--Issue this once

select * from vw_t1_t2 (nolock)

--and this later

select * from vw_t1_t2

--end of window3

|||

Yes, NOLOCK table hint will be propageted to the tables in view defination.

It is also very usefull for indexed views as they are treated as tables as well.

Please see following article for more detail.

http://msdn2.microsoft.com/en-us/library/ms190237.aspx

Hope this will answer your question.

Thanks,

FB

|||

I appeciate you taking the time to help me test the theory myself. I didn't think of Opening a transaction and not comitting it to Lock the table..

To answer your question it does propogate down..

|||

THank you for that answer it was very helpful...

No Lock

Lets say i have a view.

vuTestingNoLocks

this view looks like this...

Create View vuTestingNoLocks as

SElect *

From dbo.Employees

inner Join dbo.EmployeeTerritories on EmployeeTerritories.EmployeeID = Employees.EmployeeID

If I select from this view using Select * From vuTestingNoLocks (NOLOCK)

Does the (nolock) command propegate down through the tables? Meaning will it scan tables that are locked still ignoring their locks?

I think you should be able to test it out and come to your own conclusions. Let me know what you are going to interpret from this.

In one window, create these tables, populate dummy data and create the view

Code Snippet

--Start of window1

create table t1 (t1id int identity(10,10),

t1code char(2)

)

create table t2 (t2id int,

t2name varchar(10)

)

insert t1 select 'AB'

insert t1 select 'BC'

insert t1 select 'CD'

insert t2 select 10, 'Group AB'

insert t2 select 20, 'Group BC'

insert t2 select 30, 'Group CD'

create view vw_t1_t2 as

select t1id, t1code, t2name

from t1 join t2

on t1.t1id = t2id

--End of window1

--start of window2

--we are setting up to take exclusive lock

begin tran

update vw_t1_t2

set t1code = 'KK'

--end of window2

--start of window3

--Issue this once

select * from vw_t1_t2 (nolock)

--and this later

select * from vw_t1_t2

--end of window3

|||

Yes, NOLOCK table hint will be propageted to the tables in view defination.

It is also very usefull for indexed views as they are treated as tables as well.

Please see following article for more detail.

http://msdn2.microsoft.com/en-us/library/ms190237.aspx

Hope this will answer your question.

Thanks,

FB

|||

I appeciate you taking the time to help me test the theory myself. I didn't think of Opening a transaction and not comitting it to Lock the table..

To answer your question it does propogate down..

|||

THank you for that answer it was very helpful...

Wednesday, March 28, 2012

No history information for jobs

Hi All,
When I right click on some jobs in sql server and select view job history, s
ometimes I get "There is no history information for this job". I was able to
see job history few hours/days back. I have not cleared logs nor restarted
the box. But still i am not
able to see any history information. I can however see history information o
n other jobs. Can you tell me why is sql server wiping of job history inform
ation for some jobs. What can i do to prevent it?
Regards,
PROHave you tried increasing the values in SQLAgent-->Properties-->Job
System tab? Look at the Maximum job history log size(rows) and Maximum
job history rows per job values. See if that works for you.
Mark Allison, SQL Server MVP
PRashanth wrote:

> Hi All,
> When I right click on some jobs in sql server and select view job history, sometim
es I get "There is no history information for this job". I was able to see job histo
ry few hours/days back. I have not cleared logs nor restarted the box. But still i a
m n
ot able to see any history information. I can however see history information on other jobs
. Can you tell me why is sql server wiping of job history information for some jobs. What c
an i do to prevent it?
> Regards,
> PRO|||Hi Mark,
Thank you very much for your reply. The current setting of my sql server
is Max. job history log size(rows): 500000
max job history rows per job: 1000
Also, i dont understand why there is no job history for only some of the
jobs
Regards,
PRO
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!|||--
|
| Hi Mark,
|
| Thank you very much for your reply. The current setting of my sql server
| is Max. job history log size(rows): 500000
| max job history rows per job: 1000
|
| Also, i dont understand why there is no job history for only some of the
| jobs
|
| Regards,
| PRO
--
It is possible that the job history of more frequently running jobs are
overwriting those of the less frequently running jobs. To address this,
increase your max job history log size and decrease your max job history
rows per job.
Hope this helps,
Eric Cardenas
SQL Server support

Monday, March 26, 2012

No Databases in Enterprise Manager

SQL - 2000 running on Win2k Server
I am unable to view my databases in enterprise manager but can see them in Query Analyzer/ODBC. I had deleted a bunch of unused databases last night and after reboot this morning Enterprise manager will not display any of my databases. What have I done?
rwjohn1@.sbcglobal.net
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Try deleting the registered server and then register it
again in Enterprise Manager.
In Enterprise Manager, right click on the server, select
Delete SQL Server Registration. Then right click on the
server group and select new server registration to register
the server again.
-Sue
On Thu, 28 Oct 2004 12:04:36 -0700, SqlJunkies User
<User@.-NOSPAM-SqlJunkies.com> wrote:

>SQL - 2000 running on Win2k Server
>I am unable to view my databases in enterprise manager but can see them in Query Analyzer/ODBC. I had deleted a bunch of unused databases last night and after reboot this morning Enterprise manager will not display any of my databases. What have I done
?
>rwjohn1@.sbcglobal.net
>--
>Posted using Wimdows.net NntpNews Component -
>Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.

No Databases in Enterprise Manager

SQL - 2000 running on Win2k Server
I am unable to view my databases in enterprise manager but can see them in Q
uery Analyzer/ODBC. I had deleted a bunch of unused databases last night an
d after reboot this morning Enterprise manager will not display any of my da
tabases. What have I done?
rwjohn1@.sbcglobal.net
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine sup
ports Post Alerts, Ratings, and Searching.Try deleting the registered server and then register it
again in Enterprise Manager.
In Enterprise Manager, right click on the server, select
Delete SQL Server Registration. Then right click on the
server group and select new server registration to register
the server again.
-Sue
On Thu, 28 Oct 2004 12:04:36 -0700, SqlJunkies User
<User@.-NOSPAM-SqlJunkies.com> wrote:

>SQL - 2000 running on Win2k Server
>I am unable to view my databases in enterprise manager but can see them in Query An
alyzer/ODBC. I had deleted a bunch of unused databases last night and after reboot
this morning Enterprise manager will not display any of my databases. What have I d
one
?
>rwjohn1@.sbcglobal.net
>--
>Posted using Wimdows.net NntpNews Component -
>Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports P
ost Alerts, Ratings, and Searching.

Friday, March 23, 2012

No compatibility view for sysproperties

Is there a reason that there isn't a compatiblity view for sysproperties.Try searching for sysproperties in SQL Server 2000 Books Online and you'll see why. There is a

reason why we don't recommend to use undocumented features... :-)

--

Tibor Karaszi, SQL Server MVP

http://www.karaszi.com/sqlserver/default.asp

http://www.solidqualitylearning.com/

Blog: http://solidqualitylearning.com/blogs/tibor/

wrote in message

news:de2325cd-c357-4bf7-8f97-79553d33a82b@.discussions.microsoft.com...

> Is there a reason that there isn't a compatiblity view for

> sysproperties.

>|||

Yes I know,

However the policy for 2005 seems to have been to lay the cards on the table and finally state that it won't be supported in next release.

Its a shame because the system function is just a bit clunky. Nice to see sys.extendedproperties (of something like that).

|||

Fair enough, so what is the official supported way of reading extended properties defined on the database WITHOUT needing excessive permissions like db_owner or db_ddladmin?

I used select name, value from sysproperties where id=0 under SQL2K as these were not returned by fn_listextendedproperty when running as an application user, but I needed to read custom information from each database available to the user.

It would seem that sys.extended_properties does not show these either, so I am going to have great fun getting our application to a state where it can run under both SQL2K and SQL2K5!

|||

The official way of reading extended properties in sql server 2005 is to use the catalog view sys.extended_properties or the system function sys.fn_listextendedproperty.

In SQL Server 2000, we only support the system function fn_listextendedproperty

|||Ok, so I take it that the answer is that there is no way to do what I am trying to do ie read db level extended properties without db_owner or db_ddladmin.|||

By db level extended properties do you mean extended properties on the database itself or extended properties on database objects like tables, procedures , etc.

If it is the latter you only need to have some permission (select, insert, references, etc) on the object to view its extended properties. if it is the former you can grant the VIEW DEFINITION permission to the user to view the extended properties on the database. Either case, you do not need to be db_owner or db_ddladmin

|||

Thanks Asvin,

I am talking about extended properties defined at the database level ie id=0 under sql2k and class=0 under sql2k5.

VIEW DEFINITION works a treat under 2005 but I am struggling to find an equivalent under 2000. Unfortunately at this stage I have to find a solution that works for both.

|||OK. If the solution needs to work on sql2k then you are right; the user needs to be member of db_ddladmin or db_owner to view extended properties on the database. Unfortunately, the permission model in sql2k is not fine grained enough.

No compatibility view for sysproperties

Is there a reason that there isn't a compatiblity view for sysproperties.Try searching for sysproperties in SQL Server 2000 Books Online and you'll see why. There is a reason why we don't recommend to use undocumented features... :-) -- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ Blog: http://solidqualitylearning.com/blogs/tibor/ wrote in message news:de2325cd-c357-4bf7-8f97-79553d33a82b@.discussions.microsoft.com...
> Is there a reason that there isn't a compatiblity view for
> sysproperties.
>|||

Yes I know,

However the policy for 2005 seems to have been to lay the cards on the table and finally state that it won't be supported in next release.

Its a shame because the system function is just a bit clunky. Nice to see sys.extendedproperties (of something like that).

|||

Fair enough, so what is the official supported way of reading extended properties defined on the database WITHOUT needing excessive permissions like db_owner or db_ddladmin?

I used select name, value from sysproperties where id=0 under SQL2K as these were not returned by fn_listextendedproperty when running as an application user, but I needed to read custom information from each database available to the user.

It would seem that sys.extended_properties does not show these either, so I am going to have great fun getting our application to a state where it can run under both SQL2K and SQL2K5!

|||

The official way of reading extended properties in sql server 2005 is to use the catalog view sys.extended_properties or the system function sys.fn_listextendedproperty.

In SQL Server 2000, we only support the system function fn_listextendedproperty

|||Ok, so I take it that the answer is that there is no way to do what I am trying to do ie read db level extended properties without db_owner or db_ddladmin.|||

By db level extended properties do you mean extended properties on the database itself or extended properties on database objects like tables, procedures , etc.

If it is the latter you only need to have some permission (select, insert, references, etc) on the object to view its extended properties. if it is the former you can grant the VIEW DEFINITION permission to the user to view the extended properties on the database. Either case, you do not need to be db_owner or db_ddladmin

|||

Thanks Asvin,

I am talking about extended properties defined at the database level ie id=0 under sql2k and class=0 under sql2k5.

VIEW DEFINITION works a treat under 2005 but I am struggling to find an equivalent under 2000. Unfortunately at this stage I have to find a solution that works for both.

|||OK. If the solution needs to work on sql2k then you are right; the user needs to be member of db_ddladmin or db_owner to view extended properties on the database. Unfortunately, the permission model in sql2k is not fine grained enough.

No comments allowed where creating a view?

I have a fairly complex view that I would like to annotate with some
comments. It seems that whenever I save the view, the comments are
stripped out. I find this rather annoying. Don't suppose there is
anyway around this?
Thanks,
MarcusRight views don't allow comments, I don't think there is a work around for
that.
But in 2005, you can add extended property to the view, and store all the
documentation for the view in that property. Hopefully that gives you some
ideas.
Thanks!
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCTS: SQL Server 2005
"Marcus" wrote:

> I have a fairly complex view that I would like to annotate with some
> comments. It seems that whenever I save the view, the comments are
> stripped out. I find this rather annoying. Don't suppose there is
> anyway around this?
> Thanks,
> Marcus
>|||Thanks, Mohit. I reposted this thread as I misspelled the title (tried
to delete the post but guess it didn't work). Apparently comments are
allowed. See Dan Guzman's response to my repost.
Marcus
On Jul 5, 10:42 am, Mohit K. Gupta <mohitkgu...@.msn.com> wrote:[vbcol=seagreen]
> Right views don't allow comments, I don't think there is a work around for
> that.
> But in 2005, you can add extended property to the view, and store all the
> documentation for the view in that property. Hopefully that gives you som
e
> ideas.
> Thanks!
> --
> Mohit K. Gupta
> B.Sc. CS, Minor Japanese
> MCTS: SQL Server 2005
> "Marcus" wrote:
>

No comments allowed where creating a view?

I have a fairly complex view that I would like to annotate with some
comments. It seems that whenever I save the view, the comments are
stripped out. I find this rather annoying. Don't suppose there is
anyway around this?
Thanks,
MarcusRight views don't allow comments, I don't think there is a work around for
that.
But in 2005, you can add extended property to the view, and store all the
documentation for the view in that property. Hopefully that gives you some
ideas.
Thanks!
--
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCTS: SQL Server 2005
"Marcus" wrote:
> I have a fairly complex view that I would like to annotate with some
> comments. It seems that whenever I save the view, the comments are
> stripped out. I find this rather annoying. Don't suppose there is
> anyway around this?
> Thanks,
> Marcus
>|||Thanks, Mohit. I reposted this thread as I misspelled the title (tried
to delete the post but guess it didn't work). Apparently comments are
allowed. See Dan Guzman's response to my repost.
Marcus
On Jul 5, 10:42 am, Mohit K. Gupta <mohitkgu...@.msn.com> wrote:
> Right views don't allow comments, I don't think there is a work around for
> that.
> But in 2005, you can add extended property to the view, and store all the
> documentation for the view in that property. Hopefully that gives you some
> ideas.
> Thanks!
> --
> Mohit K. Gupta
> B.Sc. CS, Minor Japanese
> MCTS: SQL Server 2005
> "Marcus" wrote:
> > I have a fairly complex view that I would like to annotate with some
> > comments. It seems that whenever I save the view, the comments are
> > stripped out. I find this rather annoying. Don't suppose there is
> > anyway around this?
> > Thanks,
> > Marcus

No comments allowed where creating a view?

I have a fairly complex view that I would like to annotate with some
comments. It seems that whenever I save the view, the comments are
stripped out. I find this rather annoying. Don't suppose there is
anyway around this?
Thanks,
Marcus
Right views don't allow comments, I don't think there is a work around for
that.
But in 2005, you can add extended property to the view, and store all the
documentation for the view in that property. Hopefully that gives you some
ideas.
Thanks!
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCTS: SQL Server 2005
"Marcus" wrote:

> I have a fairly complex view that I would like to annotate with some
> comments. It seems that whenever I save the view, the comments are
> stripped out. I find this rather annoying. Don't suppose there is
> anyway around this?
> Thanks,
> Marcus
>
|||Thanks, Mohit. I reposted this thread as I misspelled the title (tried
to delete the post but guess it didn't work). Apparently comments are
allowed. See Dan Guzman's response to my repost.
Marcus
On Jul 5, 10:42 am, Mohit K. Gupta <mohitkgu...@.msn.com> wrote:[vbcol=seagreen]
> Right views don't allow comments, I don't think there is a work around for
> that.
> But in 2005, you can add extended property to the view, and store all the
> documentation for the view in that property. Hopefully that gives you some
> ideas.
> Thanks!
> --
> Mohit K. Gupta
> B.Sc. CS, Minor Japanese
> MCTS: SQL Server 2005
> "Marcus" wrote:

No comments allowed when creating a View?

I have a fairly complex view that I would like to annotate with some
comments. It seems that whenever I save the view, the comments are
stripped out. I find this rather annoying. Don't suppose there is
anyway around this?
Thanks,
Marcus
I assume you are using a designer to create the view? Instead, create the
view directly using a Query Analyzer or SQL Serve Management Studio query
window.
Hope this helps.
Dan Guzman
SQL Server MVP
"Marcus" <holysmokes99@.hotmail.com> wrote in message
news:1183656714.354511.114570@.g37g2000prf.googlegr oups.com...
>I have a fairly complex view that I would like to annotate with some
> comments. It seems that whenever I save the view, the comments are
> stripped out. I find this rather annoying. Don't suppose there is
> anyway around this?
> Thanks,
> Marcus
>
|||On Jul 5, 10:37 am, "Dan Guzman" <guzma...@.nospam-
online.sbcglobal.net> wrote:
> I assume you are using a designer to create the view? Instead, create the
> view directly using a Query Analyzer or SQL Serve Management Studio query
> window.
> --
> Hope this helps.
Thanks, Dan. I see now. If I right click on the view in SQL Server
Management Studio and then select "modify", it brings up the designer
which strips out the comments. However, if I right click on the view
and select "script view as-->alter to--> new query editor window"
then the comments are there. Don't really care for these extra steps,
but can live with that.
Cheers,
Marcus
[vbcol=seagreen]
> Dan Guzman
> SQL Server MVP
> "Marcus" <holysmoke...@.hotmail.com> wrote in message
> news:1183656714.354511.114570@.g37g2000prf.googlegr oups.com...
>
sql

No comments allowed when creating a View?

I have a fairly complex view that I would like to annotate with some
comments. It seems that whenever I save the view, the comments are
stripped out. I find this rather annoying. Don't suppose there is
anyway around this?
Thanks,
MarcusI assume you are using a designer to create the view? Instead, create the
view directly using a Query Analyzer or SQL Serve Management Studio query
window.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Marcus" <holysmokes99@.hotmail.com> wrote in message
news:1183656714.354511.114570@.g37g2000prf.googlegroups.com...
>I have a fairly complex view that I would like to annotate with some
> comments. It seems that whenever I save the view, the comments are
> stripped out. I find this rather annoying. Don't suppose there is
> anyway around this?
> Thanks,
> Marcus
>|||On Jul 5, 10:37 am, "Dan Guzman" <guzma...@.nospam-
online.sbcglobal.net> wrote:
> I assume you are using a designer to create the view? Instead, create the
> view directly using a Query Analyzer or SQL Serve Management Studio query
> window.
> --
> Hope this helps.
Thanks, Dan. I see now. If I right click on the view in SQL Server
Management Studio and then select "modify", it brings up the designer
which strips out the comments. However, if I right click on the view
and select "script view as-->alter to--> new query editor window"
then the comments are there. Don't really care for these extra steps,
but can live with that.
Cheers,
Marcus
> Dan Guzman
> SQL Server MVP
> "Marcus" <holysmoke...@.hotmail.com> wrote in message
> news:1183656714.354511.114570@.g37g2000prf.googlegroups.com...
> >I have a fairly complex view that I would like to annotate with some
> > comments. It seems that whenever I save the view, the comments are
> > stripped out. I find this rather annoying. Don't suppose there is
> > anyway around this?
> > Thanks,
> > Marcus

No comments allowed when creating a View?

I have a fairly complex view that I would like to annotate with some
comments. It seems that whenever I save the view, the comments are
stripped out. I find this rather annoying. Don't suppose there is
anyway around this?
Thanks,
MarcusI assume you are using a designer to create the view? Instead, create the
view directly using a Query Analyzer or SQL Serve Management Studio query
window.
Hope this helps.
Dan Guzman
SQL Server MVP
"Marcus" <holysmokes99@.hotmail.com> wrote in message
news:1183656714.354511.114570@.g37g2000prf.googlegroups.com...
>I have a fairly complex view that I would like to annotate with some
> comments. It seems that whenever I save the view, the comments are
> stripped out. I find this rather annoying. Don't suppose there is
> anyway around this?
> Thanks,
> Marcus
>|||On Jul 5, 10:37 am, "Dan Guzman" <guzma...@.nospam-
online.sbcglobal.net> wrote:
> I assume you are using a designer to create the view? Instead, create the
> view directly using a Query Analyzer or SQL Serve Management Studio query
> window.
> --
> Hope this helps.
Thanks, Dan. I see now. If I right click on the view in SQL Server
Management Studio and then select "modify", it brings up the designer
which strips out the comments. However, if I right click on the view
and select "script view as-->alter to--> new query editor window"
then the comments are there. Don't really care for these extra steps,
but can live with that.
Cheers,
Marcus
[vbcol=seagreen]
> Dan Guzman
> SQL Server MVP
> "Marcus" <holysmoke...@.hotmail.com> wrote in message
> news:1183656714.354511.114570@.g37g2000prf.googlegroups.com...
>
>

Wednesday, March 21, 2012

No checkboxes on the Server Roles page for Logins

Hi,

There are no checkboxes when I view the Server Roles page under Security --> Login properties.

The page does work.If I highlight a role and click OK, the role is granted.

I have uninstalled and re-installed SQL Server 2005 Developer Edition, but there was no change.

Any help would be appreciated. Thank you.

Hi,

this does work for me. Are you sure that you are connected with a user which has the appropiate permissions to set the values ? Make sure that you are running the lastest service pack on your box, there have been some improvement (also in the UI) which might have caused the problem in the passed (don′t know about all the bugs being reported) The curretn version I am running on is 9.00.2047 (which is SP1 + posthotfixes)

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

|||

Hi,

Thank you for replying. We do not have approval to load the service pack and hot fixes, so I am running 9.0.1399.

This is a problem on the workstations where the standard edition was installed for testing purposes and then removed. Then the developer edition was installed. Workstations that did not initially have the standard edition installed do not have the problem. This could be totally coincidental, but worth noting.

I can work with it as it is for now and will try re-installing it again when I can apply the service pack and hot fixes.

Thank you.

Wednesday, March 7, 2012

NEWBY question - filtering dates

Im not sure how to explain this or if this is the correct forum but here it goes.

I have created a report from a view that gives me court hearing dates on a defendent. When I run the report/view I get two different dates for the person such as, 12/14/2006 and 12/15/2006. How can I get it to show only the later date (12/15/2006)? I pull information from a mainframe that almost always gives me 2 different dates, but we only need the most recent date.

Here is my query for the view

SELECT dbo.CASES.CaseID, dbo.CASENUMBERS.CaseNumber AS Arrest_Number, dbo.CASENUMBERTYPES.CaseNumTypeCode AS Arrest_NumType,
CASENUMBERS_1.CaseNumber AS JN_Number, CASENUMBERTYPES_1.CaseNumTypeCode AS JN_NumType, dbo.ROLETYPES.RoleTypeDesc,
dbo.ACTORS.SIDNum, dbo.ACTORLOCATIONS.ActorLocDesc, dbo.CHARGENUMBER.ChargeDescription, dbo.DEFCHARGES.OffenseDate,
dbo.fnNameReverse(dbo.ACTORNAMES.LastName, dbo.ACTORNAMES.FirstName, dbo.ACTORNAMES.MiddleName, dbo.ACTORNAMES.Suffix)
AS NameRev, dbo.EVENTS.ev_StartDate AS PreHearingSetDate, dbo.OFFENSELEVELS.OffenseLevelDesc, dbo.CASES.UnitID
FROM dbo.CASES INNER JOIN
dbo.CASENUMBERS ON dbo.CASES.CaseID = dbo.CASENUMBERS.CaseID INNER JOIN
dbo.CASENUMBERTYPES ON dbo.CASENUMBERS.CaseNumTypeID = dbo.CASENUMBERTYPES.CaseNumTypeID INNER JOIN
dbo.CASENUMBERS AS CASENUMBERS_1 ON dbo.CASES.CaseID = CASENUMBERS_1.CaseID INNER JOIN
dbo.CASENUMBERTYPES AS CASENUMBERTYPES_1 ON CASENUMBERS_1.CaseNumTypeID = CASENUMBERTYPES_1.CaseNumTypeID INNER JOIN
dbo.CASEPARTIES ON dbo.CASES.CaseID = dbo.CASEPARTIES.CaseID INNER JOIN
dbo.ROLETYPES ON dbo.CASEPARTIES.RoleTypeID = dbo.ROLETYPES.RoleTypeID AND
dbo.CASEPARTIES.RoleTypeID = dbo.ROLETYPES.RoleTypeID INNER JOIN
dbo.ACTORNAMES ON dbo.CASEPARTIES.ActorNameID = dbo.ACTORNAMES.ActorNameID INNER JOIN
dbo.ACTORS ON dbo.ACTORNAMES.ActorID = dbo.ACTORS.ActorID INNER JOIN
dbo.ACTORLOCATIONS ON dbo.ACTORS.ActorLocationID = dbo.ACTORLOCATIONS.ActorLocationID INNER JOIN
dbo.DEFCHARGESUMMARY ON dbo.CASES.CaseID = dbo.DEFCHARGESUMMARY.CasesCaseID INNER JOIN
dbo.DEFCHARGES ON dbo.DEFCHARGESUMMARY.DefChargeID = dbo.DEFCHARGES.DefChargeID INNER JOIN
dbo.CHARGENUMBER ON dbo.DEFCHARGES.ChargeNumberID = dbo.CHARGENUMBER.ChargeNumberID INNER JOIN
dbo.COURTS ON dbo.CASES.CaseCourtID = dbo.COURTS.CourtID INNER JOIN
dbo.EVENTS ON dbo.CASES.CaseID = dbo.EVENTS.CaseID INNER JOIN
dbo.EVENTTYPES ON dbo.EVENTS.EventTypeID = dbo.EVENTTYPES.EventTypeID INNER JOIN
dbo.OFFENSELEVELS ON dbo.CHARGENUMBER.OffenseLevelID = dbo.OFFENSELEVELS.OffenseLevelID
WHERE (dbo.CASENUMBERTYPES.CaseNumTypeCode = 'NM' OR
dbo.CASENUMBERTYPES.CaseNumTypeCode = 'MC' OR
dbo.CASENUMBERTYPES.CaseNumTypeCode = 'CM' OR
dbo.CASENUMBERTYPES.CaseNumTypeCode = 'JP') AND (CASENUMBERTYPES_1.CaseNumTypeCode = 'JN') AND
(dbo.ROLETYPES.RoleTypeDesc = 'Defendant') AND (dbo.EVENTTYPES.EventTypeDesc = 'PRE-HEARING SET') AND
(dbo.DEFCHARGES.OffenseDate > CONVERT(DATETIME, '2006-01-01 00:00:00', 102))

In the 'PRE-HEARING SET' table is where I receive the two dates. Is there a way to filter out the first date? I just want to show the most recent date.

Hi,

as you do not SELECT anything from the events table what about:

--dbo.EVENTTYPES ON dbo.EVENTS.EventTypeID = dbo.EVENTTYPES.EventTypeID INNER JOIN

dbo.OFFENSELEVELS ON dbo.CHARGENUMBER.OffenseLevelID = dbo.OFFENSELEVELS.OffenseLevelID

WHERE (dbo.CASENUMBERTYPES.CaseNumTypeCode = 'NM' OR

dbo.CASENUMBERTYPES.CaseNumTypeCode = 'MC' OR

dbo.CASENUMBERTYPES.CaseNumTypeCode = 'CM' OR

dbo.CASENUMBERTYPES.CaseNumTypeCode = 'JP') AND (CASENUMBERTYPES_1.CaseNumTypeCode = 'JN') AND

(dbo.ROLETYPES.RoleTypeDesc = 'Defendant') AND

(dbo.DEFCHARGES.OffenseDate > CONVERT(DATETIME, '2006-01-01 00:00:00', 102))

AND EXISTS(SELECT * FROM dbo.EVENTTYPES WHERE EVENTS.EventTypeID = dbo.EVENTTYPES.EventTypeID AND dbo.EVENTTYPES.EventTypeDesc = 'PRE-HEARING SET')

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

Saturday, February 25, 2012

newbie: viewing data in SQL Server 7.0

I am embarassed even to ask this question here, but I truly don't know.
I can't find a way to graphically view the databases on my server. It is
running Back Office SBS 4.5, which includes SQL Server 7.0. I didn't set up
the server, someone else did, but I do have the installation disks.
I don't know much about SQL Server, but I've had some experience with mySQL
(which I've used phpMyAdmin to view/edit).
I've looked around for applications in the start menu, but nothing is shown
relating to SQL Server. Can anyone please help?
Thanks for the help.
SarahIf the SQL Server administrative tools have been installed, look for an Ente
rprise Manager icon in the Programs\Microsoft SQL Server folder.
If they haven't, rerun the installation and add the admin tools. You will a
lso have to reapply any service packs and hotfixes.
Sincerely,
Anthony Thomas
--
"Sarah S" <psusarah@.ncx.com> wrote in message news:%23bIsDGqzEHA.2192@.TK2M
SFTNGP14.phx.gbl...
I am embarassed even to ask this question here, but I truly don't know.
I can't find a way to graphically view the databases on my server. It is
running Back Office SBS 4.5, which includes SQL Server 7.0. I didn't set u
p
the server, someone else did, but I do have the installation disks.
I don't know much about SQL Server, but I've had some experience with mySQ
L
(which I've used phpMyAdmin to view/edit).
I've looked around for applications in the start menu, but nothing is show
n
relating to SQL Server. Can anyone please help?
Thanks for the help.
Sarah|||Thanks! Does this mean to re-run the OS installation? I'm assuming it does.
No SQL tools were installed originally.
"AnthonyThomas" <Anthony.Thomas@.CommerceBank.com> wrote in message news:%23O
5w9q0zEHA.3120@.TK2MSFTNGP12.phx.gbl...
If the SQL Server administrative tools have been installed, look for an Ente
rprise Manager icon in the Programs\Microsoft SQL Server folder.
If they haven't, rerun the installation and add the admin tools. You will a
lso have to reapply any service packs and hotfixes.
Sincerely,
Anthony Thomas
--
"Sarah S" <psusarah@.ncx.com> wrote in message news:%23bIsDGqzEHA.2192@.TK2MSF
TNGP14.phx.gbl...
I am embarassed even to ask this question here, but I truly don't know.
I can't find a way to graphically view the databases on my server. It is
running Back Office SBS 4.5, which includes SQL Server 7.0. I didn't set up
the server, someone else did, but I do have the installation disks.
I don't know much about SQL Server, but I've had some experience with mysql
(which I've used phpMyAdmin to view/edit).
I've looked around for applications in the start menu, but nothing is shown
relating to SQL Server. Can anyone please help?
Thanks for the help.
Sarah

newbie: viewing data in SQL Server 7.0

I am embarassed even to ask this question here, but I truly don't know.
I can't find a way to graphically view the databases on my server. It is
running Back Office SBS 4.5, which includes SQL Server 7.0. I didn't set up
the server, someone else did, but I do have the installation disks.
I don't know much about SQL Server, but I've had some experience with mySQL
(which I've used phpMyAdmin to view/edit).
I've looked around for applications in the start menu, but nothing is shown
relating to SQL Server. Can anyone please help?
Thanks for the help.
SarahThis is a multi-part message in MIME format.
--=_NextPart_000_0014_01C4D0C3.B586D890
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Thanks! Does this mean to re-run the OS installation? I'm assuming it =does. No SQL tools were installed originally.
"AnthonyThomas" <Anthony.Thomas@.CommerceBank.com> wrote in message =news:%23O5w9q0zEHA.3120@.TK2MSFTNGP12.phx.gbl...
If the SQL Server administrative tools have been installed, look for =an Enterprise Manager icon in the Programs\Microsoft SQL Server folder.
If they haven't, rerun the installation and add the admin tools. You =will also have to reapply any service packs and hotfixes.
Sincerely,
Anthony Thomas
-- "Sarah S" <psusarah@.ncx.com> wrote in message =news:%23bIsDGqzEHA.2192@.TK2MSFTNGP14.phx.gbl...
I am embarassed even to ask this question here, but I truly don't =know.
I can't find a way to graphically view the databases on my server. =It is running Back Office SBS 4.5, which includes SQL Server 7.0. I didn't =set up the server, someone else did, but I do have the installation disks.
I don't know much about SQL Server, but I've had some experience =with mySQL (which I've used phpMyAdmin to view/edit).
I've looked around for applications in the start menu, but nothing =is shown relating to SQL Server. Can anyone please help?
Thanks for the help.
Sarah
--=_NextPart_000_0014_01C4D0C3.B586D890
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Thanks! Does this mean to re-run the OS =installation? I'm assuming it does. No SQL tools were installed originally.
"AnthonyThomas" wrote in message news:%23O5w9q0zEHA.=3120@.TK2MSFTNGP12.phx.gbl...
If the =SQL Server administrative tools have been installed, look for an Enterprise =Manager icon in the Programs\Microsoft SQL Server folder.

If they =haven't, rerun the installation and add the admin tools. You will also =have to reapply any service packs and hotfixes.

Sincerely,


Anthony = Thomas

--
"Sarah S" wrote in =message news:%23bIsDGqzEHA.=2192@.TK2MSFTNGP14.phx.gbl...I am embarassed even to ask this question here, but I truly don't know.I can't find a way to graphically view the databases on =my server. It is running Back Office SBS 4.5, which includes SQL =Server 7.0. I didn't set up the server, someone else did, but I do have =the installation disks.I don't know much about SQL Server, but =I've had some experience with mySQL (which I've used phpMyAdmin to view/edit).I've looked around for applications in the start =menu, but nothing is shown relating to SQL Server. Can anyone please help?Thanks for the help.Sarah

--=_NextPart_000_0014_01C4D0C3.B586D890--

newbie: viewing data in SQL Server 7.0

I am embarassed even to ask this question here, but I truly don't know.
I can't find a way to graphically view the databases on my server. It is
running Back Office SBS 4.5, which includes SQL Server 7.0. I didn't set up
the server, someone else did, but I do have the installation disks.
I don't know much about SQL Server, but I've had some experience with mySQL
(which I've used phpMyAdmin to view/edit).
I've looked around for applications in the start menu, but nothing is shown
relating to SQL Server. Can anyone please help?
Thanks for the help.
Sarah
If the SQL Server administrative tools have been installed, look for an Enterprise Manager icon in the Programs\Microsoft SQL Server folder.
If they haven't, rerun the installation and add the admin tools. You will also have to reapply any service packs and hotfixes.
Sincerely,
Anthony Thomas

"Sarah S" <psusarah@.ncx.com> wrote in message news:%23bIsDGqzEHA.2192@.TK2MSFTNGP14.phx.gbl...
I am embarassed even to ask this question here, but I truly don't know.
I can't find a way to graphically view the databases on my server. It is
running Back Office SBS 4.5, which includes SQL Server 7.0. I didn't set up
the server, someone else did, but I do have the installation disks.
I don't know much about SQL Server, but I've had some experience with mySQL
(which I've used phpMyAdmin to view/edit).
I've looked around for applications in the start menu, but nothing is shown
relating to SQL Server. Can anyone please help?
Thanks for the help.
Sarah
|||Thanks! Does this mean to re-run the OS installation? I'm assuming it does. No SQL tools were installed originally.
"AnthonyThomas" <Anthony.Thomas@.CommerceBank.com> wrote in message news:%23O5w9q0zEHA.3120@.TK2MSFTNGP12.phx.gbl...
If the SQL Server administrative tools have been installed, look for an Enterprise Manager icon in the Programs\Microsoft SQL Server folder.
If they haven't, rerun the installation and add the admin tools. You will also have to reapply any service packs and hotfixes.
Sincerely,
Anthony Thomas

"Sarah S" <psusarah@.ncx.com> wrote in message news:%23bIsDGqzEHA.2192@.TK2MSFTNGP14.phx.gbl...
I am embarassed even to ask this question here, but I truly don't know.
I can't find a way to graphically view the databases on my server. It is
running Back Office SBS 4.5, which includes SQL Server 7.0. I didn't set up
the server, someone else did, but I do have the installation disks.
I don't know much about SQL Server, but I've had some experience with mySQL
(which I've used phpMyAdmin to view/edit).
I've looked around for applications in the start menu, but nothing is shown
relating to SQL Server. Can anyone please help?
Thanks for the help.
Sarah

Monday, February 20, 2012

Newbie: Modifying table = wrong data in view?

Hi there,

Completely new to the world of databases. I'm a designer who works primarily in Flash. In any case, I'm trying to manage an application that uses MS SQL and learn about the wonderful world of databases.

Ok, I modified a table (e.g. I added a column called "Rate") that had associated views (created by another developer). Noticed that my application went a little wonky as some of my variables within my app took on the value of the data in the "Rate" column. I checked one of the views and noticed that a column within the view (e.g. TutorID) was assuming the values in the "Rate" column. Note: The column TutorID had been blank before the change to the table. I'm completely lost as to why this is happening. Do I need to rebuild the view? Can I just reset the original view?

Thanks.

Oh yeah, I'm using SQL4X Manager J from Mac Guru (if that helps).Scott, where are you? This is a prime example of what you were talking about at the bar, remember?|||Hey RD STEP BACK! nothing to see here....
Novian,
give us some DDL on your view and your table

DDL(object definitions) = a list of all of the cols in the view and in the underlying table

Perform the following steps:

Execute sp_helptext against the view to copy it's code.
Execute sp_depends against your view to obtain the name of the tables that the view depends on
right click your table in the object browser in the query analyzer and select "script object to new window as create"
copy the table script and the view code and reply here and paste them in here and we'll hook you up.

if you dont know how to run any of these commands, type them in the query analyzer and then select them and press SHIFT+F1 on your keyboard. Books Online will open to the helpfile for the appropriate procedure|||Hey guys,

Thanks for your help. Here's the info:

Results of sp_texthelp:

Text
CREATE VIEW dbo.GetUsers
AS
SELECT dbo.getUsersAndTutors.*,dbo.Students.StudentsID AS StudentID
FROM dbo.getUsersAndTutors LEFT OUTER JOIN
dbo.Students ON dbo.getUsersAndTutors.UID = dbo.Students.UID

Results of sp_depends:

dbo.getUsersAndTutors

Unfortunately, I can't seem to make the "script object to new window as create" work. I can't right click since I'm on a Mac. Any suggestions?

Thanks.|||For starters, get rid of SELECT *

On a MAC?|||Hi Brett,

Yeah, I'm using a db management software for the Mac. As such, "right-click" doesn't exist.

What do you mean by "get rid of Select *" ?

I know I can type this into the query analyzer and add the name of a table in order to see the table but I'm not sure how this fits in with what Ruprect has asked me to do.

Thanks.|||Okay, doing a little reading and I "think" I know what's going on...

As far as I understand, you can use shortcuts to insert data into tables. If you make a change to the table, you could run into problems if your values don't match up with the new table.

With that being said, I'm wondering if my 'view' which depends on the table that I changed is accepting data into the wrong field because the original table was created using a shortcut?

I guess the question still remains...how do I see the script that describes how my table was created? More specifically, how do I do this with a Mac-based MS SQL manager?

One last question: Is there a query that will allow me to see this script?|||Hey Ruprect,

Figured out that command. Here's what I got...

CREATE TABLE [dbo].[Users] (
[UID] int IDENTITY(1,1) NOT NULL,
[Firstname] nvarchar(255) NOT NULL,
[Lastname] nvarchar(255) NOT NULL,
[Nickname] nvarchar(50) NOT NULL,
[Password] nvarchar(50) NOT NULL,
[Gender] int NULL DEFAULT (0),
[EmailAddr] nvarchar(255) NOT NULL,
[City] nvarchar(255) NULL,
[ProvID] int NULL DEFAULT (0),
[CurrentSecurityLevel] int NULL DEFAULT (0),
[DesiredSecurityLevel] int NULL DEFAULT (0),
[ATID] int NULL DEFAULT (0),
[AFID] int NULL DEFAULT (0),
[SystemStatus] int NULL DEFAULT (0),
[isOnline] bit NOT NULL DEFAULT (0),
[isAvailISM] bit NOT NULL DEFAULT (0),
[UserInfo] ntext NULL,
[DOB] datetime NULL,
[RegistrationDate] datetime NOT NULL,
[LastLoginDate] datetime NULL,
[stat_TimesLoggedin] int NOT NULL DEFAULT (0),
[stat_ISMRecvBytes] int NULL DEFAULT (0),
[stat_ISMSentBytes] int NULL DEFAULT (0),
[stat_Apptsmade] int NULL DEFAULT (0),
[stat_MsgPosted] int NULL DEFAULT (0),
[TutorRate] nvarchar(18) NULL,
CONSTRAINT [aaaaaUsers_PK] PRIMARY KEY([UID])
)
GO
ALTER TABLE [dbo].[Users]
ADD CONSTRAINT [Users_FK05]
FOREIGN KEY([CurrentSecurityLevel])
REFERENCES [dbo].[Type_SecurityLevel]([SecurityLevel])
GO
ALTER TABLE [dbo].[Users]
ADD CONSTRAINT [Users_FK03]
FOREIGN KEY([ProvID])
REFERENCES [dbo].[Type_Province]([ProvID])
GO
ALTER TABLE [dbo].[Users]
ADD CONSTRAINT [Users_FK01]
FOREIGN KEY([ATID])
REFERENCES [dbo].[Type_Avatar]([ATID])
GO
ALTER TABLE [dbo].[Users]
ADD CONSTRAINT [Users_FK04]
FOREIGN KEY([DesiredSecurityLevel])
REFERENCES [dbo].[Type_SecurityLevel]([SecurityLevel])
GO
ALTER TABLE [dbo].[Users]
ADD CONSTRAINT [Users_FK00]
FOREIGN KEY([AFID])
REFERENCES [dbo].[Type_Affiliation]([AFID])
GO
ALTER TABLE [dbo].[Users]
ADD CONSTRAINT [Users_FK02]
FOREIGN KEY([Gender])
REFERENCES [dbo].[Type_Gender]([GID])
GO

Thanks, again.

Newbie: how to make a datatypeconversion in a view

Hello,

I'm making a view in SQL Server EM. In this view I want to generate a field
which combines 3 other fields simply together.
I have the fields: lngNumber (numeric), txtOpdrachtgever (string) and
txtAfdeling (string) which I want to combine (with a space between each
field). In Access reporting the string would be.
NameOutputField: lngNumber & " " & txtOpdrachtgever & " " & txtAfdeling
How does this work within SQL server. I get messages of datatype errors when
I use + or &. I don't now the syntaxis to convert fields.

So can anyone give a suggestion on how to make the above string and also
give a little bit information on the conversion of fields within views. I
didn't find it in the SQL help files.

Thanks,

Remco Groot beumer"Remco Groot Beumer" <nospam@.nospam.com> wrote in message
news:d6n28q$acb$1@.news1.zwoll1.ov.home.nl...
> Hello,
> I'm making a view in SQL Server EM. In this view I want to generate a
> field
> which combines 3 other fields simply together.
> I have the fields: lngNumber (numeric), txtOpdrachtgever (string) and
> txtAfdeling (string) which I want to combine (with a space between each
> field). In Access reporting the string would be.
> NameOutputField: lngNumber & " " & txtOpdrachtgever & " " & txtAfdeling
> How does this work within SQL server. I get messages of datatype errors
> when
> I use + or &. I don't now the syntaxis to convert fields.
> So can anyone give a suggestion on how to make the above string and also
> give a little bit information on the conversion of fields within views. I
> didn't find it in the SQL help files.
> Thanks,
> Remco Groot beumer

See CAST, CONVERT and "String Concatenation Operator" in Books Online - you
need to make sure everything is in a character data type when you
concatenate the string, eg.

create view dbo.MyView
as select 'Output: ' + cast(NumberColumn as char(10)) + ' ' + CharColumn
from dbo.MyTable

You might find it's easier to do this in your front end - presentation and
formatting are usually done there, and not in the database.

Simon|||Select convert(varchar(30),lngNumber) +' ' + txtOpdrachtgever +' ' +
txtAfdeling + ' ' from tbl

"Remco Groot Beumer" <nospam@.nospam.com> wrote in message
news:d6n28q$acb$1@.news1.zwoll1.ov.home.nl...
> Hello,
> I'm making a view in SQL Server EM. In this view I want to generate a
field
> which combines 3 other fields simply together.
> I have the fields: lngNumber (numeric), txtOpdrachtgever (string) and
> txtAfdeling (string) which I want to combine (with a space between each
> field). In Access reporting the string would be.
> NameOutputField: lngNumber & " " & txtOpdrachtgever & " " & txtAfdeling
> How does this work within SQL server. I get messages of datatype errors
when
> I use + or &. I don't now the syntaxis to convert fields.
> So can anyone give a suggestion on how to make the above string and also
> give a little bit information on the conversion of fields within views. I
> didn't find it in the SQL help files.
> Thanks,
> Remco Groot beumer