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

Sunday, March 25, 2012

Access Crosstab to an SQL Express PIVOT

I need some help in converting this crosstab SQL from an Access query to a View in SQL Server Express:

TRANSFORM First(tblPhones.PhoneNumber)AS FirstOfPhoneNumberSELECT tblPhones.ClientIDFROM tblPhonesGROUP BY tblPhones.ClientIDPIVOT tblPhones.PhoneType;

Hello:

You may need to change hardcoded phonetype in your case:

If this is not exact what you want, you can post some sample data and expected result here.

SELECT

ClientID,

MIN

(CASEWHEN PhoneType='office'THEN PhoneNumberEND)as OfficePhoneNumber,

MIN

(CASEWHEN PhoneType='home'THEN PhoneNumberEND)as HomePhoneNumber

FROM

(SELECT ClientID, PhoneType, PhoneNumberFROM tblPhones) p

WHERE

PhoneTypeIN('home','office')

GROUP

BY ClientID

--Or PIVOT solution:(SQL Server 2005)

SELECT

ClientID, office, home

FROM

(SELECT ClientID, PhoneType, PhoneNumberFROM tblPhones) p

PIVOT

(MIN(PhoneNumber)FOR PhoneTypeIN([office], [home]))AS pvt|||

I will give this try, but is it possible to do this without hard coding the phone type names? In the access query it just shows a gorup by list of used phonetypes.

|||

FYI. This is a version with dynamic pivot for your table.

SETNOCOUNTON

DECLARE @.TASTABLE(ynvarchar(10)NOTNULLPRIMARYKEY)

INSERTINTO @.TSELECTDISTINCT PhoneTypeFROM tblPhones

DECLARE @.T1ASTABLE(numintNOTNULLPRIMARYKEY)

DECLARE @.iASint

SET @.i=1

WHILE @.i<10

BEGIN

INSERTINTO @.T1SELECT @.i

SET @.i=@.i+1

END


DECLARE @.colsASnvarchar(MAX), @.yASnvarchar(10)

SET @.y=(SELECTMIN(y)FROM @.T)

SET @.cols= N''

WHILE @.yISNOTNULL

BEGIN

SET @.cols= @.cols+ N',['+CAST(@.yASnvarchar(10))+N']'

SET @.y=(SELECTMIN(y)FROM @.TWHERE y> @.y)

END

SET @.cols=SUBSTRING(@.cols, 2,LEN(@.cols))


DECLARE @.sqlASnvarchar(MAX)

SET @.sql= N'SELECT * FROM (SELECT ClientID, PhoneType, PhoneNumber FROM tblPhones) as t

PIVOT (min(PhoneNumber) FOR PhoneType IN('+ @.cols+ N')) AS pvt'

EXECsp_executesql @.sql

|||

You are obviously very good at this, I tried to test this and get a syntax error neer SET.

I tried to run the other PIVOT and received this type or message 'You must set your Compatibiltiy level higher (sp_dbcmptlevel)'. Does this mean that SQL Server 2005 Express does not support the PIVOT?

|||

Hello:

--You need to change the Compatibility level to SQL Server 2005 which is 90.

EXEC sp_dbcmptlevel yourDatabasename, 90;

--Or you can use SQL Server Management Studio (Express), right cilck on your database name to get the property window; under Options tab>> Compatibility level: ; you can choose from SQL Server 7.0(70), 2000(80), or 2005(90) from the dropdownbox.

|||

Ok, I set the compatibiltiy to 90, the first Pivot now works, but the dynamic PIVOT does not. I receive the following error:

The Set SQL construct or statement is not supported.

Syntax error near SET

Any thoughts.

|||

Here is one more piece that might help: I added the AS keyword to the start of the sproc and it saved (I really need it to be a view, but 1 thing at a time) it ran with the following error:

String or binary data would be truncated.

The statement has been terminated.

Incorrect syntax near ')'.

No rows affected.

|||I dont intend to steal limno's credit but to answer your question, you prbly have a variable that is beingset a value higher than what it can take. Increase the size of your string variable for which you are getting the error.|||

Ok, that helped I can save and run it as a sproce. I increased all of the nvarchars to (20).

I have tried to save it as a view and I get: 'The Set SQL construct or statement is not supported.' Then I get a incorrect syntax near keyword SET.

Any thoughts on this?

|||

Hello,

Could be this line?

@.TASTABLE(ynvarchar(10)NOTNULLPRIMARYKEY)

Please change the nvarchar(10) to nvarchar(50) or something bigger and try again.

If you have some sample data, I can test them from my end too.

|||

I set them to 20 and it works. Do you know how I could change this to allow me to save it as a view?

I very much appreciate your help,

|||Try to create the view from the query in the dynamical sql command, for example:

.
DECLARE @.sql AS nvarchar(MAX)

SET @.sql = N'CREATE VIEW v_test AS SELECT * FROM (SELECT ClientID, PhoneType, PhoneNumber FROM tblPhones) as t

PIVOT (min(PhoneNumber) FOR PhoneType IN(' + @.cols + N')) AS pvt'

SELECT * FROM v_Test|||

I tried your suggestion, but I get a SET not supported message and then a vw_DYPhoneList is an invalid name.

Any thoughts?

SETNOCOUNT ON DECLARE@.TAS TABLE(ynvarchar(20)NOT NULLPRIMARY KEY)INSERTINTO @.TSELECT DISTINCT Phone_TypeFROM tblPhonesDECLARE@.T1AS TABLE(numintNOT NULLPRIMARY KEY)DECLARE@.iAS int SET@.i=1WHILE@.i <20BEGININSERTINTO @.T1SELECT @.iSET@.i=@.i+1END--select * from @.T1DECLARE@.colsAS nvarchar(MAX), @.yAS nvarchar(20)SET@.y = (SELECT MIN(y)FROM @.T)SET@.cols = N''WHILE@.yISNOT NULLBEGINSET@.cols = @.cols + N',['+CAST(@.yAS nvarchar(20))+N']'SET@.y = (SELECT MIN(y)FROM @.TWHERE y > @.y)ENDSET@.cols =SUBSTRING(@.cols, 2,LEN(@.cols))DECLARE@.cols1AS nvarchar(MAX), @.numAS nvarchar(20)SET@.num = (SELECT MIN(num)FROM @.T1)SET@.cols1 = N''WHILE@.numISNOT NULLBEGINSET@.cols1 = @.cols1 + N',['+CAST(@.numAS nvarchar(20))+N']'SET@.num = (SELECT MIN(num)FROM @.T1WHERE num > @.num)ENDSET@.cols1 =SUBSTRING(@.cols1, 2,LEN(@.cols1))DECLARE@.cols2AS nvarchar(MAX), @.num2AS nvarchar(20)SET@.num2 = (SELECT MIN(num)FROM @.T1)SET@.cols2 = N'[1]+'WHILE@.num2ISNOT NULLBEGINIF@.num2>1SET@.cols2 = @.cols2 + N'coalesce('','''+ N'+['+CAST(@.num2AS nvarchar(20))+N'],'''')+ 'SET@.num2 = (SELECT MIN(num)FROM @.T1WHERE num > @.num2)ENDSET@.cols2 =SUBSTRING(@.cols2, 0,LEN(@.cols2))DECLARE @.sqlAS nvarchar(MAX)SET @.sql = N'CREATE VIEW vwDYPhoneList AS SELECT * FROM (SELECT ClientID, Phone_Type, Phone_Number FROM tblPhones) as tPIVOT (min(Phone_Number) FOR Phone_Type IN(' + @.cols + N')) AS pvt'SELECT *FROM vwDYPhoneList
|||

You need to execute the @.sql.

Do this at the end.

.....

DECLARE

@.sqlASnvarchar(MAX)

SET

@.sql= N'CREATE VIEW vwDYPhoneList AS SELECT * FROM (SELECT ClientID, PhoneType, PhoneNumber FROM tblPhones) as t

PIVOT (min(PhoneNumber) FOR PhoneType IN('

+ @.cols+ N')) AS pvt'EXECsp_executesql @.sql

SELECT

*FROM vwDYPhoneList

Tuesday, March 20, 2012

Access 2003 Project Connecting to SQL 2000 & 2005 Servers

We have an Access 2003 Project that it's primary server is a SQL 2000 server. When I link a table to the 2000 server and execute the view, I get data with no problem. I link a table to the 2005 server and execute the view...once again, no problem. However, if I try to write a query to pull data from both views......times out. I have changed the timeout value to "0" and never returns the data.

So then I created a new Access 2003 Project to use the 2005 as the primary server. Once again I create a linked table and execute the view on the SQL 2000 server and it works just fine. Then create a linked table to the 2005 server and the view works just fine. However, here's the difference. When I try to create a query to pull data from both views, I get:

  1. This version of Microsoft Office Access doesn’t support design changes with the version of Microsoft SQL Server your Access project is connected to. See the Microsoft Office Update Web site for the latest information and downloads. Your design changes will not be saved.

  2. You have connected to a version of SQL Server later than SQL Server 2000. The version of Visual Studio or Access that you are using was released before the version of SQL Server to which you are connected. For this reason, you might encounter problems. Please check with Microsoft to see if there is a service pack that you should apply to Visual Studio or Office in order to get support for the version of SQL Server to which you are connected. You can continue but any new object types might not be enumerated, and it will not be possible to save any objects or database diagrams that you create using the Visual Database Tools.

Any assistance would be GREATLY appreciated. I'm stuck and wish I could make this happen.

PS:....

The version of Access 2003 specifically is: Microsoft ? Office Access 2003 (11.6566.6568) SP2

I've even made two linked tables to the 2005 server and executed each view by themselves and it worked fine. However, if I try to create a query off of those linked tables, same errors just posted above.

I'm afraid that Access ADPs aren't going to work all that smoothly with SQL Server 2005--they are created for SQL Server 2000 and earlier. If you're creating a new app, it's recommended that you use an mdb with linked tables because it gives you more flexibility. ADPs were designed around the scenario that you would connect to *one* SQL Server database, not multiple databases. One option if you must use ADPs is to create views to access data in another database. You can then use those views in your Access FE.

--Mary

sql

Access 2000 upsizing trouble

I am upgrading an Access 2000 database to SQL Server 7.0 and 2000. When I
run the upsizing wizard it works great, but when I view the tables within
SQL only the first two tables appear to have data. I deleted the SQL
database and tried again. I tried upsizing one table (has 3500 records) and
it worked.
I have many tables of varying record size but the entire database is around
6MB. I don't find any information about why it works when I do one table at
a time and doesn't work when I try to upsize all the tables. Any help is
greatly appreciated.
WB"WB" <none> wrote:
>I am upgrading an Access 2000 database to SQL Server 7.0 and 2000. When I
>run the upsizing wizard it works great, but when I view the tables within
>SQL only the first two tables appear to have data. I deleted the SQL
>database and tried again. I tried upsizing one table (has 3500 records) and
>it worked.
Dates outside the range which SQL Servers default date formats can
cause problems. For more details and other items see the Random
Thoughts on SQL Server Upsizing from Microsoft Access Tips page at my
website.
Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm|||Hi WB,
This problem is wired. I would like you to provide more information so that
I can narrow down it?
1. Do you mean that there is not any error message?
2. Does this problem occur on SQL Server 7.0 or SQL Server 2000? What is
the Service Pack of the SQL Server?
3. I would like you to try to upsize all the tables of the Access 2000
database to SQL Server separately. Does the same problem occur again?
4. Please try to transform data from Access to SQL Server using DTS. For
additional information regarding DTS, please refer to the following article
on SQL Server Books Online:
Topic:" DTS Basics".
Thanks for using MSDN newsgroup.
Regards,
Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.|||Hi Michael,
During this upsize I did have some errors. The problem (errors) weren't
specifically with the tables that didn't upsize the data.
I have experienced this with both versions.
Yes, after I posted the message I went back and upsized each table, fixed
the errors and everything upsized correctly.
I will look into the DTS.
Thanks for your response and interest.
I am unsure as to why the data isn't converting on tables that don't have
errors?
WB
"Michael Shao [MSFT]" <v-yshao@.online.microsoft.com> wrote in message
news:HN61VeSfDHA.1544@.cpmsftngxa06.phx.gbl...
> Hi WB,
> This problem is wired. I would like you to provide more information so
that
> I can narrow down it?
> 1. Do you mean that there is not any error message?
> 2. Does this problem occur on SQL Server 7.0 or SQL Server 2000? What is
> the Service Pack of the SQL Server?
> 3. I would like you to try to upsize all the tables of the Access 2000
> database to SQL Server separately. Does the same problem occur again?
> 4. Please try to transform data from Access to SQL Server using DTS. For
> additional information regarding DTS, please refer to the following
article
> on SQL Server Books Online:
> Topic:" DTS Basics".
> Thanks for using MSDN newsgroup.
> Regards,
> Michael Shao
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>|||Hi WB,
Thanks for your feedback. I glad to here that everything upsized correctly
now. Based on the information you provided, I am also unsure why the data
hasn't converted. To help me find out why, I would like you to provide more
information.
1. Do you mean the same problem occurs on both versions of SQL Server? If
so, what is the version of your Service Pack on both SQL Server (SQL Server
7.0 or SQL Server 2000)?
2. As I understand, the all structures of the tables have been upsized.
Only two of the tables have data and the other tables do not have any data.
If I have misunderstood, please feel free to let me know.
3. You wrote: "During this upsize I did have some errors. The problem
(errors) weren't specifically with the tables that didn't upsize the data."
Why do you think these errors are not related to this issue? Could you
please provide me with more details about the error message? If it is
possible, please provide me with a screenshot. You can send it to me
directly at v-yshao@.microsoft.com as an attachment.
4. I am not sure if this problem is machine specific. If it is possible,
could you upsize the MDB database from another machine? Can this problem be
reproduced on another machine? If this problem cannot be reproduced on my
side, it will be hard to find the cause.
Also, I found some useful articles regarding the issues with Upsizing
Wizard, could you check to see if your database has the same problem?
225993 ACC2000: Data Not Upsized in Table with Index
http://support.microsoft.com/?id=225993
325019 ACC2000: Issues with the Access 2000 Upsizing Wizard
http://support.microsoft.com/?id=325019
Thanks for using MSDN newsgroup.
Regards,
Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Monday, March 19, 2012

Access 2000 Frontend MS SQL 2000 backend - Locking Problems

We are using an Access 2000 project to view our SQL Tables and using Access 2000 Runtime to Access the forms in the project. We have written in a locking system in VB and removed the video controls to prevent users from accessing the same records. But of course now we need to make the video controls available. This has now thrown up the problem of multiple users accessing the same records. We have tried to write code to lock records when then video controls are used but this is not working as well as we hoped. Can anyone please suggest any way of setting up locking on SQL using triggers from the Access frontend? or any other types of locking systems that could be written in the Access front end.

The safest and easiest way to use locks having to do with SQL Server in a distributed application is to use SQL Server locks themselves. See the links below for information on how SQL Server locks work and how to use them.

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

http://www.informit.com/articles/article.aspx?p=26657&rl=1

http://www.mssqlcity.com/Articles/Adm/SQL70Locks.htm

http://www.databasejournal.com/features/mssql/article.php/3289661

http://www.sql-server-performance.com/articles/per/advanced_sql_locking_p1.aspx

http://blog.sqlauthority.com/2007/04/27/sql-server-2005-locking-hints-and-examples/

Hope that helps,

John

Access 2000 Frontend MS SQL 2000 backend - Locking Problems

We are using an Access 2000 project to view our SQL Tables and using Access 2000 Runtime to Access the forms in the project. We have written in a locking system in VB and removed the video controls to prevent users from accessing the same records. But of course now we need to make the video controls available. This has now thrown up the problem of multiple users accessing the same records. We have tried to write code to lock records when then video controls are used but this is not working as well as we hoped. Can anyone please suggest any way of setting up locking on SQL using triggers from the Access frontend? or any other types of locking systems that could be written in the Access front end.

The safest and easiest way to use locks having to do with SQL Server in a distributed application is to use SQL Server locks themselves. See the links below for information on how SQL Server locks work and how to use them.

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

http://www.informit.com/articles/article.aspx?p=26657&rl=1

http://www.mssqlcity.com/Articles/Adm/SQL70Locks.htm

http://www.databasejournal.com/features/mssql/article.php/3289661

http://www.sql-server-performance.com/articles/per/advanced_sql_locking_p1.aspx

http://blog.sqlauthority.com/2007/04/27/sql-server-2005-locking-hints-and-examples/

Hope that helps,

John

Sunday, March 11, 2012

Accesing Oracle from an assembly!

Hi Group!
Iâ've a big problem with MS Reporting Services, i try to access an oracle
database from a custom assembly, in desing view all work nice, but in
production environment, the call to the class fail!.
What i can do to correct this problem?
I added the dll file to de bin folder or reportserver and report designer,
but donâ't work.
Really I need help.
Thanks for the helpCarlos,
It sounds like a CAS issue (Code Access Security)
Make sure you define (in the RS Policy file) definitions of the location and
the name of the Custome Assembly DLL's and what Rights you want to assign to
it.
RS provides very limited default "trust" of Custom Assemblies, you'll need
to define specific additions to this to allow access to the database.
Btw: Although it can be done, it's a little unusual to access the database
from a Custom Assembly - I normally see it done as an extension like a data
procesing extension.
HTH
- peteZ
"Carlos López." <CarlosLpez@.discussions.microsoft.com> wrote in message
news:A591ABD5-0838-4B99-88A3-43FBBE27FD49@.microsoft.com...
> Hi Group!
> I've a big problem with MS Reporting Services, i try to access an oracle
> database from a custom assembly, in desing view all work nice, but in
> production environment, the call to the class fail!.
> What i can do to correct this problem?
> I added the dll file to de bin folder or reportserver and report designer,
> but don't work.
> Really I need help.
> Thanks for the help
>|||You will need to assert FullTrust permissions to use the Oracle data
provider from a custom assembly. Below is an example of how to assert full
trust in your custom assembly using an attribute on the method that opens an
Oracle connection:
[PermissionSet(SecurityAction.Assert, Unrestricted=true)]
public foo()
{
// your code
strConn = "Data Source=TSD01;User ID=SchemaName;password=password;";
OracleConnection cn = new OracleConnection(strConn);
cn.Open();
// ...
}
Note: in addition to changing the code in the custom assembly, you will need
to modify the code policy config files to give your custom assembly full
trust permissions.
http://msdn.microsoft.com/library/?url=/library/en-us/dnsql2k/html/dngrfCodeAccessSecurityInSQLServer2000ReportingServices.asp
There is a reason why you will need to assert FullTrust permissions: If you
read the MSDN documentation for the OraclePermission class and the
SqlClientPermission class and compare them, you will notice the following
statement:
"This class [i.e. OraclePermission] is intended for future use when the .NET
Framework Data Provider for Oracle is enabled for partial trust scenarios.
The provider currently requires FullTrust permission."
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoracleclientoraclepermissionclasstopic.asp
I.e. asserting the OraclePermission won't help you get around the Security
exception, because the .NET data provider for Oracle _must_ have full trust
and does not work in a partially trusted environment. This is inherit to the
current design of the data provider and the Oracle client. Note: The managed
provider for SQL Server is enabled for partial trust scenarios, therefore it
is sufficient (and advisable) to just assert the SqlClientPermission when
using it in custom assemblies.
HTH,
--
Robert M. Bruckner
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"PeteZ" <peteZ@.aol.com> wrote in message
news:OyiJok40EHA.3584@.TK2MSFTNGP11.phx.gbl...
> Carlos,
> It sounds like a CAS issue (Code Access Security)
> Make sure you define (in the RS Policy file) definitions of the location
and
> the name of the Custome Assembly DLL's and what Rights you want to assign
to
> it.
> RS provides very limited default "trust" of Custom Assemblies, you'll need
> to define specific additions to this to allow access to the database.
> Btw: Although it can be done, it's a little unusual to access the database
> from a Custom Assembly - I normally see it done as an extension like a
data
> procesing extension.
> HTH
> - peteZ
>
> "Carlos López." <CarlosLpez@.discussions.microsoft.com> wrote in message
> news:A591ABD5-0838-4B99-88A3-43FBBE27FD49@.microsoft.com...
> > Hi Group!
> >
> > I've a big problem with MS Reporting Services, i try to access an oracle
> > database from a custom assembly, in desing view all work nice, but in
> > production environment, the call to the class fail!.
> > What i can do to correct this problem?
> >
> > I added the dll file to de bin folder or reportserver and report
designer,
> > but don't work.
> >
> > Really I need help.
> >
> > Thanks for the help
> >
>

Thursday, March 8, 2012

about XML View Function.

I Know that we can show the view that it is made by Singleton XML Schema.

But I want to show a view what it is made by NO Singleton XML Schema.

Please let me know that if you have any knowledges.

Thanks for you.

just try it like this

Content of XML-Field:

<MyParameters>

<Parameter>

<ParaNr></ParaNr>

<ParaText></ParaText>

</Parameter>

<Parameter>

<ParaNr></ParaNr>

<ParaText></ParaText>

</Parameter>

<Parameter>

<ParaNr></ParaNr>

<ParaText></ParaText>

</Parameter>

</MyParameters>

Statement for the Query (My_ID is just another nonXML column of the table):

SELECT MY_ID

ref.value('./ParaNr', 'nvarchar(2)') AS [PARA_NR],

ref.value('./ParaText', 'nvarchar(200)') AS [PARA_TEXT]
FROM MY_SCEMA.MY_TABLE

CROSS apply MY_XMLCOLUMN.nodes('/MyParameters/Parameter') AS T (ref)

I Hope this helps

best regards

Raimund

about XML View Function.

I Know that we can show the view that it is made by Singleton XML Schema.

But I want to show a view what it is made by NO Singleton XML Schema.

Please let me know that if you have any knowledges.

Thanks for you.

just try it like this

Content of XML-Field:

<MyParameters>

<Parameter>

<ParaNr></ParaNr>

<ParaText></ParaText>

</Parameter>

<Parameter>

<ParaNr></ParaNr>

<ParaText></ParaText>

</Parameter>

<Parameter>

<ParaNr></ParaNr>

<ParaText></ParaText>

</Parameter>

</MyParameters>

Statement for the Query (My_ID is just another nonXML column of the table):

SELECT MY_ID

ref.value('./ParaNr', 'nvarchar(2)') AS [PARA_NR],

ref.value('./ParaText', 'nvarchar(200)') AS [PARA_TEXT]
FROM MY_SCEMA.MY_TABLE

CROSS apply MY_XMLCOLUMN.nodes('/MyParameters/Parameter') AS T (ref)

I Hope this helps

best regards

Raimund

Tuesday, March 6, 2012

About Trace Flag 1204 report

Hi Guys,
I want to ask a simple question,where can I get Trace Flag 1204 report, from
event view or somewhere else? ThanksYou find it in the SQL Server errorlog file.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Iter" <Iter@.discussions.microsoft.com> wrote in message
news:F495BD05-8568-4F87-8994-5F26892359D9@.microsoft.com...
> Hi Guys,
> I want to ask a simple question,where can I get Trace Flag 1204 report, fr
om
> event view or somewhere else? Thanks

About Trace Flag 1204 report

Hi Guys,
I want to ask a simple question,where can I get Trace Flag 1204 report, from
event view or somewhere else? ThanksYou find it in the SQL Server errorlog file.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Iter" <Iter@.discussions.microsoft.com> wrote in message
news:F495BD05-8568-4F87-8994-5F26892359D9@.microsoft.com...
> Hi Guys,
> I want to ask a simple question,where can I get Trace Flag 1204 report, from
> event view or somewhere else? Thanks

About the value of each week

I have an rpt in crosstab that view the total sales of each salesman in every week. This is the rpt looks like:

Week 35 Week 36 Week 37 Week 38
Eric 100 200.25 300 500
Vlad 320 400 0 400

My problem is, if a salesman sales in a week is equal to zero, the sales that must be viewed will be the sale last week.

Here's the rpt must look like this..

Week 35 Week 36 Week 37 Week 38
Eric 100 200.25 300 500
Vlad 320 400 340 400use a formula for displaying value

something like

if sales>0 then
sales
else
previous(sales)|||Thanx! i will try

About the value of each week

I have an rpt that view the total sales of every week in crosstab design
Week 35 Week 36 Week 37 Week 38Do you have any specific question?

Friday, February 24, 2012

about sql server 2005

hi friends,
i'm a new user to sql server 2005 express edition. just now i've installed this server edition. i dont know how to view the server name. i've mentioned that to use windows authentication during installation.
please help me for :
1.how to view the server name in sql server 2005?(it shows only configuration manager and surface area configuration in the all programs menu)

2.how to add new database in this server 2005?(it has no enterprise manager like sql server 2000)

3.when i tried to install MSDE 2000 Release A for SQL SERVER 2005, it throws an error that "A strong SA password is required for security reasons.please use SAPWD switch to supply the same. refer to readme for more details.setup will now exit".

its urgent please........................................

1. The default SQL Server Express name is: [ (local)\SQLExpress ]

2. Download SQL Server Management Studio Express here. A tutorial here.

3. There is a README.TXT file included with the MSDE installation files. You will find instructions about using the command line switches in the README.TXT.

|||marvelous reply.............i didn't expect like this............(for sudden reply)...........thank you......
i've one doubt which is i heard that SQL SERVER 2005 express edition has own inbuilt MSDE 2005. but i've installed the MSDE 2000A. will it override the existing MSDE? and What is the procedure to view the server name?
|||

SQL Server Express can coexists with MSDE. They are very similar (different versions of the same product).

You can verify what instances of SQL Server (MSDE, Express, REgular -they all look the same to the OS) by going to the [Control Panel], select [Administrative Tools], then [Services].

SQL Server(s) will be listed under 'MSSQL'.

If there is one listed as MSSQLSERVER, it's name is the same as your computer name, and it is also know as (local).

Other Instances will be listed as MSSQL$SQLEXPRESS, etc. It's name is the computer name, backslash, and the Instance Name (the part after the dollar sign).

So, SQL Express will be know as: (local)\SQLEXPRESS, or if your computer name is 'Bob, it would be: Bob\SQLEXPRESS

And the same for MSDE and other Instances of SQL Server. It is not at all unusual to find multiple SQL Server Instances -many third party applications install SQL Server Instances for their own use.

About SQL Profiler and query

Hi
i have enable SQL Profiler for my SQL2000 DB and view a "SQLTransaction" but
the TextData is always empty and my application name is JSQL.
This transaction duration is : 10516
The question are :
1- It's a normal that the "textdata" is always empty ?
2- The application name "JSQL" maybe JBOSS on my Apache server?
3- The duration of this transaction is too much ?
Thanks.
What are you expecting to see in the TextData column for the SQLTransaction
event? It's documented behaviour is to display "The savepoint or rollback
name, if provided.", according to SQL Server Books Online:
http://msdn.microsoft.com/library/en..._perf_79tf.asp
Given that it's not common to name savepoints or rollbacks, it's probably a
little unusual to expect to see much in SQLTransaction:TextData. Perhaps you
should be profiling a different event - if you post back with what you're
hoping to see, we can perhaps help by recommending a different event to
profile?
Regards,
Greg Linwood
SQL Server MVP
<io.com> wrote in message news:eu8ETkNnEHA.2764@.TK2MSFTNGP10.phx.gbl...
> Hi
> i have enable SQL Profiler for my SQL2000 DB and view a "SQLTransaction"
> but
> the TextData is always empty and my application name is JSQL.
> This transaction duration is : 10516
> The question are :
> 1- It's a normal that the "textdata" is always empty ?
> 2- The application name "JSQL" maybe JBOSS on my Apache server?
> 3- The duration of this transaction is too much ?
>
> Thanks.
>

About SQL Profiler and query

Hi
i have enable SQL Profiler for my SQL2000 DB and view a "SQLTransaction" but
the TextData is always empty and my application name is JSQL.
This transaction duration is : 10516
The question are :
1- It's a normal that the "textdata" is always empty ?
2- The application name "JSQL" maybe JBOSS on my Apache server?
3- The duration of this transaction is too much ?
Thanks.What are you expecting to see in the TextData column for the SQLTransaction
event? It's documented behaviour is to display "The savepoint or rollback
name, if provided.", according to SQL Server Books Online:
http://msdn.microsoft.com/library/en-us/adminsql/ad_mon_perf_79tf.asp
Given that it's not common to name savepoints or rollbacks, it's probably a
little unusual to expect to see much in SQLTransaction:TextData. Perhaps you
should be profiling a different event - if you post back with what you're
hoping to see, we can perhaps help by recommending a different event to
profile?
Regards,
Greg Linwood
SQL Server MVP
<io.com> wrote in message news:eu8ETkNnEHA.2764@.TK2MSFTNGP10.phx.gbl...
> Hi
> i have enable SQL Profiler for my SQL2000 DB and view a "SQLTransaction"
> but
> the TextData is always empty and my application name is JSQL.
> This transaction duration is : 10516
> The question are :
> 1- It's a normal that the "textdata" is always empty ?
> 2- The application name "JSQL" maybe JBOSS on my Apache server?
> 3- The duration of this transaction is too much ?
>
> Thanks.
>

Sunday, February 19, 2012

About Security between views and tables

Hi,

I've got a table T1 and a view V1 based on T1's rows (but not all rows).


I've granted users to do update and select on my View V1.
But i don't want users directly update my table T1.

then, i log as a standard user in Enterprise mgr, and open my view V1. I modify a value in a field, and when i validate, an error occurs saying i'm not allowed to make Select neither Update on table T1.

Is there a way of doing this ? (sql 2000).

You can't update a view. A view isn't a table. It's just a select statement.|||

Yes i can. I did it many times, as the select is not too complex, you can do it.

For insance, if you got a table T1 with fields (ID, f1,f2,f3,f4) and a view V1 as select id, f1,f2 from t1, you 'll be allowed to make updates.

this feature works fine with many views i wrote.

|||Well, I'll be...

Have you read through this document to see if you have met the criteria for updateable views? http://msdn2.microsoft.com/en-gb/library/ms187956.aspx|||

thanks for the link. yes my view is updateable, and when there's no grant restrictions, it works fine.

My problem is the following : I'm working on an ms access migration to sql 2000.
Then, i use my view as an attached table in access, an users can modify some values.
But i don't wan basic users have a direct access to the table, only to the view.
That's why i tried to restrict select and update on the table, whereas select and updates are allowed to the view.

But i'm afraid i won't be able to do this...

|||If you have the base table restricted, I'm wondering if the view can supercede that security. I'm thinking not.|||

i'm afraid you're right. so i'll have to manage my own security... :-(

Monday, February 13, 2012

About Index And View

hi,i am a beginner, i want to know
what is the different between index and view?
in my option,i think they do one job:let the select quickly!index: http://www.odetocode.com/Articles/70.aspx

view: http://www.odetocode.com/Articles/299.aspx|||thank you for your kindly help!
but how to use index?
need write sql? or DBMS can AUTOEXE index that exist?

Thursday, February 9, 2012

about catalog view

I can find all databases i created from sys.databases view

but i could not find tables info under relevant database by sys.tables view? and I do not know why sys.tables,sys.columns and other views do not have database_id attribute? any idea? thanks

As the sys.tables and sys.columns are catalog views within a database, they are only relevant to THAT database. Therefore, you don't need a database_id attribute. There are instances of these views in every database.

If you do want to return that attribute when querying the table, just add db_id() to your select statement.

However, if you want to list all tables on an instance, try using the undocumented proc sp_MsForEachDB.

sp_msforeachdb 'select * from ?.sys.tables'

Hope this helps!

|||

thanks in advance

but i could not find any instruction about this from books online?

any advice about useful undocumented proc in MSSQL? thanks