Showing posts with label below. Show all posts
Showing posts with label below. Show all posts

Friday, March 30, 2012

How can i connect to sql sever 2005 express from the command prompt.

Iam trying to connect to local copy of sql sever express from the command prompt with this command(sqlcmd) but i get the error below. What should i do to overcome the error. Basically what i want to do is to try out some commandline backup utilities and i deadly want to know how to do a backup from the command prompt. Help is greatly appreciated.

HResult 0x2, level 16, state 1

Named pipes provider: could not open a connection to sql sever [2]

sqlcmd: Error: Microsft sql native client: An error has occurred while estarblishing a connection to the sever. When connecting to sql sever 2005, this failure may be caused by the fact that under the default settings SQL sever does not allow remote connections..

Sqlcmd: Error: Microsoft sql native client: Login time out expired.

Assuming you have the server name correct I would check in the control panel --> administrative tools --> Services and make sure that sql express is running|||I got it right. Looks like it was a typing mistake. But i have one question here, backingup a database from the command prompt to me looks tiresome. What is likely to go wrong if i just copied my projects folder from the production sever to a nother machine where i want the backup to be insteady of going through all these good but confusing steps. I i just copied the folder to a nother location or computer, are the end results not the same with if i had follwed all these database backup procedures. Dont laugh at me, iam still new to this stuff.|||

Hi,

This might be caused since SQL Server 2005 does not allow remote connection under default configuration. Please enable this according to the following KB article.

http://support.microsoft.com/kb/914277/en-us

HTH. If this does not answer your question, please feel free to mark the post as Not Answered and reply. Thank you!

Wednesday, March 21, 2012

How can I Associate DataSource with Report using Code

hi,
Thx. in advance.
How can I Associate DataSource with Report using Code.I'm using Reporting
Service Web Serivice
I tried this below code but it is giving error
like
"The data source 'DS_Code_002' cannot be found in this report. --> The data
source 'DS_Code_002' cannot be found in this report"
DataSourceReference reference = new RS.DataSourceReference();
reference.Reference = txtDSPath.Text;
DataSource[] dataSources = new RS.DataSource[1];
DataSource ds = new RS.DataSource();
ds.Item = (RS.DataSourceDefinitionOrReference) reference;
ds.Name = txtDSPath.Text.Substring(txtDSPath.Text.LastIndexOf("/")+1);
dataSources[0] = ds;
rs.SetReportDataSources(txtReportPath.Text, dataSources);
Please help me to resolve the issue.
Thx. again.
regards,
Krishna.MIt took me 2 months to code this after hounding people and digging through
books. I look back and shake my head... :)
Note: FolderPath is the path of where the report root lives... i.e. if your
report was here and called "Top 50 Financial Statements" then the full path
is:
/reports/business/quarterly/Top 50 Financial Statements
and ReportRoot = "/reports/business/quarterly"
RSReports is my reference to the Reporting Service WSDL file (the variable
name you create when reference the reporting services web service)
MyDatasourceName is the name of your datasource. Be sure you specify where
it is exactly. :)
rsDeliverTo is just a variable of RSReports.ReportingService i.e.
Dim rsDeliverTo as RSReports.ReportingService
You should use "rsDeliverTo" to programmatically create your report, so you
can set the datasource in the code below as I have outlined:
Dim reference As New DataSourceReference
reference.Reference = ReportRoot & "/MyDatasourceName"
Dim ReportPathToReport As String = FolderPath + "/" + name
Dim rds() As RSReports.DataSource =rsDeliverTo.GetReportDataSources(ReportPathToReport)
Dim bflag As Boolean = False
Dim strResult As String = ""
For i As Integer = 0 To rds.Length - 1
If TypeOf rds(i).Item Is RSPolarisReports.InvalidDataSourceReference Then
rds(i).Item = CType(reference, DataSourceDefinitionOrReference)
bflag = True
End If
Next i
If (bflag) Then
rsDeliverTo.SetReportDataSources(ReportPathToReport, rds)
End If
Now that you have that, you can then proceed to set the report timeouts,
caching options, etc.
=-Chris
"Krishna kumar.M" <Krishna kumar.M@.discussions.microsoft.com> wrote in
message news:29C00F28-6ED1-4B1B-9BF6-9AFFB8C1CDD6@.microsoft.com...
> hi,
> Thx. in advance.
> How can I Associate DataSource with Report using Code.I'm using Reporting
> Service Web Serivice
> I tried this below code but it is giving error
> like
> "The data source 'DS_Code_002' cannot be found in this report. --> The
> data
> source 'DS_Code_002' cannot be found in this report"
>
> DataSourceReference reference = new RS.DataSourceReference();
> reference.Reference = txtDSPath.Text;
> DataSource[] dataSources = new RS.DataSource[1];
> DataSource ds = new RS.DataSource();
> ds.Item = (RS.DataSourceDefinitionOrReference) reference;
> ds.Name = txtDSPath.Text.Substring(txtDSPath.Text.LastIndexOf("/")+1);
> dataSources[0] = ds;
> rs.SetReportDataSources(txtReportPath.Text, dataSources);
>
> Please help me to resolve the issue.
> Thx. again.
> regards,
> Krishna.M

Friday, March 9, 2012

How are views used each time it is requested.

Taking the view below, is a view reran each time it is requested or is there
some sort of caching that would hold the dataset ready for the next request
of the view?
CREATE VIEW dbo.vwTodaysNeurologyAppts
AS
SELECT TOP 100 PERCENT PatientName, ResourceCode, ApptDate, ActivityType
FROM dbo.Appointment
WHERE (LEFT(ResourceGroup, 3) = 'NEU') AND (DATEDIFF(Day, ApptDate,
GETDATE()) = 0) AND (ApptStatus = 'ATTENDED')
ORDER BY ApptDateNo caching of the dataset, as that would be incredibly complex considering t
hat the underlying data
might have been modified in between. The data that has been accessed by the
query you ran against
the view can of course be cached (just as if you were querying those tables
directly).
You can create an index on a view (under certain circumstances) which essent
ially materializes the
view. Any modification if the underlying data need to be propagated to the m
aterialized/indexed
view.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"CD" <mcdye1@.hotmail.REMOVETHIS.com> wrote in message
news:OfR%23iKDKGHA.2992@.tk2msftngp13.phx.gbl...
> Taking the view below, is a view reran each time it is requested or is the
re some sort of caching
> that would hold the dataset ready for the next request of the view?
>
> CREATE VIEW dbo.vwTodaysNeurologyAppts
> AS
> SELECT TOP 100 PERCENT PatientName, ResourceCode, ApptDate, ActivityTy
pe
> FROM dbo.Appointment
> WHERE (LEFT(ResourceGroup, 3) = 'NEU') AND (DATEDIFF(Day, ApptDate, GE
TDATE()) = 0) AND
> (ApptStatus = 'ATTENDED')
> ORDER BY ApptDate
>|||no, the results are not cached between executions - but the source data
pages are, and depending on the level of activity on the server, there is a
good chance that they will still be in memory on successive executions.
however, you can persist the view by creating a clustered index on it - see
"indexed views" in BOL.
btw, don't rely on "SELECT TOP 100 PERCENT" and "ORDER BY" inside a view.
ORDER BY should be specified in the final SELECT. also, if there is an index
on ApptDate column, don't use DATEDIFF on it because the index won't be
used.
dean
"CD" <mcdye1@.hotmail.REMOVETHIS.com> wrote in message
news:OfR%23iKDKGHA.2992@.tk2msftngp13.phx.gbl...
> Taking the view below, is a view reran each time it is requested or is
> there some sort of caching that would hold the dataset ready for the next
> request of the view?
>
> CREATE VIEW dbo.vwTodaysNeurologyAppts
> AS
> SELECT TOP 100 PERCENT PatientName, ResourceCode, ApptDate,
> ActivityType
> FROM dbo.Appointment
> WHERE (LEFT(ResourceGroup, 3) = 'NEU') AND (DATEDIFF(Day, ApptDate,
> GETDATE()) = 0) AND (ApptStatus = 'ATTENDED')
> ORDER BY ApptDate
>|||Each SELECT statement performed against the view will result in a SELECT
statement against the base tables. Data is cached in memory to make
subsequent SELECTS against the view faster, but the actual view data is
stored only in the base tables unless you create a clustered index on the
view. Indexes with views, also known as materialized views, have a seperate
data store for the columns in the view within the clustered index.
If you wanted to index your view, you would have to remove the TOP clause,
which would also necessitate removing the ORDER BY clause.
"CD" wrote:

> Taking the view below, is a view reran each time it is requested or is the
re
> some sort of caching that would hold the dataset ready for the next reques
t
> of the view?
>
> CREATE VIEW dbo.vwTodaysNeurologyAppts
> AS
> SELECT TOP 100 PERCENT PatientName, ResourceCode, ApptDate, ActivityTy
pe
> FROM dbo.Appointment
> WHERE (LEFT(ResourceGroup, 3) = 'NEU') AND (DATEDIFF(Day, ApptDate,
> GETDATE()) = 0) AND (ApptStatus = 'ATTENDED')
> ORDER BY ApptDate
>
>

How accurate is dm_db_index_usage_stats

All,

I've been running this script below regularly to see the supposed usage of my indexes:

SELECT object_name(s.object_id) AS ObjectName

, s.object_id

, i.name as IndexName

, i.index_id

, user_seeks

, user_scans

, user_lookups

, user_updates

FROM sys.dm_db_index_usage_stats s

INNER JOIN sys.indexes i

ON i.object_id = s.object_id

AND i.index_id = s.index_id

WHERE database_id = db_id ()

AND objectproperty(s.object_id,'IsUserTable') = 1

ORDER BY (user_seeks + user_scans + user_lookups + user_updates) ASC

Before I start disabling/dropping indexes, just how accurate is the this dmv?

Thanks,

Ian

The data for the dmvs is real time.|||

It records all activity since SQL was last started, in real-time. I have found it to be very reliable and helpful in deciding which indexes are actually being used for reads. Try running this query to get a better picture:

-- Possible bad Indexes (writes > reads)

DECLARE @.dbid int

SELECT @.dbid = db_id()

SELECT 'Table Name' = object_name(s.object_id), 'Index Name' =i.name, i.index_id,

'Total Writes' = user_updates, 'Total Reads' = user_seeks + user_scans + user_lookups,

'Difference' = user_updates - (user_seeks + user_scans + user_lookups)

FROM sys.dm_db_index_usage_stats AS s

INNER JOIN sys.indexes AS i

ON s.object_id = i.object_id

AND i.index_id = s.index_id

WHERE objectproperty(s.object_id,'IsUserTable') = 1

AND s.database_id = @.dbid

AND user_updates > (user_seeks + user_scans + user_lookups)

ORDER BY 'Difference' DESC, 'Total Writes' DESC, 'Total Reads' ASC

How accurate is dm_db_index_usage_stats

All,

I've been running this script below regularly to see the supposed usage of my indexes:

SELECT object_name(s.object_id) AS ObjectName

, s.object_id

, i.name as IndexName

, i.index_id

, user_seeks

, user_scans

, user_lookups

, user_updates

FROM sys.dm_db_index_usage_stats s

INNER JOIN sys.indexes i

ON i.object_id = s.object_id

AND i.index_id = s.index_id

WHERE database_id = db_id ()

AND objectproperty(s.object_id,'IsUserTable') = 1

ORDER BY (user_seeks + user_scans + user_lookups + user_updates) ASC

Before I start disabling/dropping indexes, just how accurate is the this dmv?

Thanks,

Ian

The data for the dmvs is real time.|||

It records all activity since SQL was last started, in real-time. I have found it to be very reliable and helpful in deciding which indexes are actually being used for reads. Try running this query to get a better picture:

-- Possible bad Indexes (writes > reads)

DECLARE @.dbid int

SELECT @.dbid = db_id()

SELECT 'Table Name' = object_name(s.object_id), 'Index Name' =i.name, i.index_id,

'Total Writes' = user_updates, 'Total Reads' = user_seeks + user_scans + user_lookups,

'Difference' = user_updates - (user_seeks + user_scans + user_lookups)

FROM sys.dm_db_index_usage_stats AS s

INNER JOIN sys.indexes AS i

ON s.object_id = i.object_id

AND i.index_id = s.index_id

WHERE objectproperty(s.object_id,'IsUserTable') = 1

AND s.database_id = @.dbid

AND user_updates > (user_seeks + user_scans + user_lookups)

ORDER BY 'Difference' DESC, 'Total Writes' DESC, 'Total Reads' ASC