Showing posts with label local. Show all posts
Showing posts with label local. Show all posts

Monday, March 26, 2012

Is it possible to have sqlcmd connect to local sqlexpress without a parameter?

(SQL Server Express 2005)

sqlcmd will connect to the local SQLExpress server just fine if I give the -S parameter:
SQLCMD -S .\SQLExpress

but is there any way to have it default to that so I can just say:
SQLCMD
?

Thanks,

dwh
You can do something like:
1) Create an Alias thorough Computer Management | SQL Server Configuration Manager | SQL Native Client Configuration
Alias Name: foo
Protocol: Named Pipes
Server: .\SQLExpress

2) Execute SQLCMD using the alias, like SQLCMD /S foo

Peter|||Umm... thanks, but that doesn't really help.

If I still need to say "sqlcmd /s foo", how is that any better than having to say "sqlcmd /s .\SQLExpress"?

Apparently on some machines here at work people are able to just say "sqlcmd" and it will default to the local SQL (Express) Server.

No?

Thanks,

dwh
|||They probably have a default instance installed. If /S is not specified, SQLCMD will try to connect to the dedfault instance. When installing Express, choose Advanced Options and then select "Default Instance". By default the Express setup installs Express and as a named instance called SQLEXPRESS.

To check whether they have a default or named istance, execute sp_helpserver against the server.

Peter

Is it possible to have a website remotely hosted, which would access local database?

Hi everybody,

Currently we have a MIS application, developed in VB 6.0 - SQL Server 2000 platform, which is used by around 60 users in our office.

We are planning to host a website remotely, which would allow clients to place orders, track order status etc. on it.

Would it be possible to access our local SQL database from the remote website?

utpal_nandi:

Would it be possible to access our local SQL database from the remote website?

I'm afraid, it won't be possible. You should host the database also.

|||

Well I guess in theory that's not impossible. It might be impracticle though...

When you say "our local SQL database", is that hosted on a dedicated box? You could open that up for remote (read: internet) connections. That would allow your web server to access it.

However, that probably won't save you any time and will deprive you of an in house server that could be used for testing, etc. Also, it'll probably be slower for the webserver to query your sql server over the internet than it would be to query another server on its own network (if you hosted the database at the same place you host the website).

So you asked if it would be possible, and the answer is yes, but I wouldn't actually recommend it.

|||

What do you mean by "dedicated box"? Do you mean dedicated server? We will be having a dedicated server on Windows 2000 Datacenter edition on which the database as well as the web server (IIS) would be installed. The web server would be opened up for remote connections through a static IP.

Regarding the time factor, 90% of our data entry and database access would be done by our office staff on our local database, which would be faster than doing the same on a remote database. Moreover in case of a remote database, if our internet connection fails, our work would get held up. Only 10% of data entry and database access would be done by our clients in case of a local database, which would be slow and could be alternatively done by our local staff in case the internet connection fails.

|||

Hi,

Regarding the time factor, 90% of our data entry and database access would be done by our office staff on our local database, which would be faster than doing the same on a remote database.

From your description, I think that you can make your MIS system connect to the local database first, and then update the data to the live server in a schedule plan. To achieve this, one of the ways is to create a step job in SQLServer Agent, and make your remote database be synchronized with your local database server.

Besides, if you are using Visual Studio Team Suite, you can start a Database project, in that project, you can deploy your local database to your remote server in an easy way, meantime, schema comparison and data comparison between databases on different servers are enabled, you can make different databases be synchronized more easier than before.

Thanks.

Friday, March 23, 2012

Is it possible to email a reportviewer graph as the email body not as an attachment

I have a page that disaplays a column report in a reportviewer control and the report processing mode is local not server. I was just wondering if its possible to programmatically email this graph as the email body not as an attachment using the system.net.mail classses. The email recepients have MS outlook email addresses.

Thanks in advance.

I still want help on this. And now i'm backing off from sending the report as the email body. It wouldn't hurt if the report is send as an attachment. Please some out there help.

|||

http://www.codeproject.com/csharp/Email_a_PDF_Report.asp

Wednesday, March 21, 2012

is it possible to connect to SQL Express without network?

I have notebook, client server application and sql express sp2 on this notebook.

Also, I know domain user login/password,

but I don't know any local user name/password

and I don't know any sql server user name/password.

Domain user is not a local administrator on this notebook.

When notebook connected to the office LAN I am working good with my app-> my sql express as a domain/user.

I'd like to work at home too. I can logon to the system (XP SP2) using domain account when notebook has no network connection. (probably OS caches something)

Is it possible to work with sql express using domain login when no network connection?

PS. old version of this software used MSDE 2000 and it was possible(!).

Thank you.

Yes. SQL Server will still work the same as when you are connected to the office LAN.

Since you log on with your domain credentials (they are cachd on the laptop), the same credentials are used to gain entry to SQL Server.

|||

Arnie Rowland wrote:

Yes. SQL Server will still work the same as when you are connected to the office LAN.

Since you log on with your domain credentials (they are cachd on the laptop), the same credentials are used to gain entry to SQL Server.

Ok, thank you.

I did experiment on 2 workstations.

On one machine ist working good, but on the second machine (no netowrk connection) when I tried to connect to the sql server I have a problem:

SSMS is ocnnecting ok

Application gives me message: cannot generate SSPI context.

What can it be? ...

Thank you

|||

Check these souces:

Error -Cannot generate SSPI context
http://support.microsoft.com/Default.aspx?id=811889
http://support.microsoft.com/kb/827422/en-us
http://support.microsoft.com/kb/843248/en-us
http://support.microsoft.com/kb/269541/en-us
http://support.microsoft.com/kb/267588/en-us
http://support.microsoft.com/kb/814401/en-us
http://support.microsoft.com/kb/818173/en-us

sql

Monday, March 19, 2012

Is it possible to change the operator of an expression at run time?

I have a report I have created in local mode, in a Winform ReportViewer using VB.net.

Is it possible to change the operator of an expression at run time? That is, I have a filter on a list that looks like this:

Expression: =Fields!InvNum.Value

Operator: =

Value: =Parameters!InvNum.Value

It is possible in code to change the operator from = to >= at the time I run the report? If so, what is the syntax? What I would like to do (don't know it is possible) is to have the operator set to >= at the time the the report is run and then set it back to = when a user selects a specific value for a Parameter for the report. Is this possible?

I suppose I can set it in the load event of the form that contains the ReportViewer, but if this is possible I have not been able to discover the syntax.

Anyone?

You can't change the filter operator at run-time. But you can change the filter expression to =IIF(<your condition>, Fields!InvNum.Value=Parameters!InvNum.Value, Fields!InvNum.Value>=Parameters!InvNum.Value), and the filter value to =true.|||

Thank you for responding.

It's not clear to me what you're saying. I mean I understand that you can change the filter expression as a whole (and not the filter operator) and I understand that you can do that with an Immediate IF statement, but where?

Are you saying that you can change the expression in code, at run time? If so, how and Where, specifically?

Or, are you saying that in the Filter tab of the List component that you can enter an IIF there? If so, what kind of value would I put in <your condition>?

It may be that I am asking a question that seems illogical to you, like "How is time?". But to me, what I am trying to do is pretty common. I am trying to figure out a way to bring lots of information into a report and then give the user the ability to whittle it down if he wants to.

|||

OK. I think I understand some of this. I created an additional string parameter for the report called IWantToSeeAllRows. I set the default value to Y. Then in the filter tab of the list, in the expression column I typed the following:

=IIF(Parameters!IWantAllRows.Value = "Y", Fields!InvNum.Value>=Parameters!InvNum.Value, Fields!InvNum.Value=Parameters!InvNum.Value)

After typing the above RS put an = character in the Operator column and <Blank> in the Value column of the grid in the filter tab.

When running the report I get an error of "Cannot compare data of types system boolean and system string. Please check the data type returned by the filter expression.

I am really guessing here as to where just exactly to place the code etc., but the documentation that I've found on the matter is not explicit for this particular issue. What am I missing?

|||

Most likely you changed the filter value expression to a constant value like TRUE (which is interpreted as string - hence the type mismatch).

Change the filter value expression to =True (which evalutes to a boolean)

-- Robert

Wednesday, March 7, 2012

Is it a "Partitioned View"?

Hello. Say you have a view and you want to know if it's
recognized by SQL Server as a local "Partitioned View".
Is there any way to see that, short of running queries to
see that it's scanning ALL table's indexes in the view,
not just the one with the specific WHERE clause criteria
you requested?
How do you know a view is treated as partitioned by SQL
Server (7 or 2000)? THanks, BruceBruce
Script out the view, it should be fairly obvious looking
at it if it is a partitioned view. I have not got 2000 bol
where I am at the moment, but in 7 you will see multiple
tables joined using union all, I would think 2000 would be
the same.
I hope that is what you meant.
Regards
John|||John, it's not that straight-forward. I was hoping
there's some SQL function (like an IsPartitionedView) that
just says that SQL Server THINKS this is a partitioned
view. I have a view and it's not being treated by SQL as
partitioned, in as far as using the separate table's
indexes, it's table scanning EVERY table's index. The
Tales have the correct CHECK constraint, and all the rules
APPEAR to be followed ok, so I was hoping there was a way
to see why SQL Server is just treating this view as a
regular UNION'd set of tables, not as a "partitioned"
view.
Scripting out the view doesn't show you the table
attributes, like the NULL PADDING setting, or the
constraints, etc...
There's probably no way to see this I'm guessing, but
thought I'd ask... THanks, Bruce
>--Original Message--
>Bruce
>Script out the view, it should be fairly obvious looking
>at it if it is a partitioned view. I have not got 2000
bol
>where I am at the moment, but in 7 you will see multiple
>tables joined using union all, I would think 2000 would
be
>the same.
>I hope that is what you meant.
>Regards
>John
>.
>|||There is no intrinsic property, it's purely a matter of query optimization.
You have to view the query plan and/or IO statistics to determine if SQL is
appropriately pruning table partitions from the query plan.
SET STATISTICS IO ON
Look for scan counts of zero on the non-qualifying tables.
Also, I've found that it is necessary to add an index on the partitioning
column(s), as non-intuititve as that seems, it helps the optimizer in
certain cases eliminate partitions
.
--
Kevin Connell, MCDBA
----
The views expressed here are my own
and not of my employer.
----
"Bruce de Freitas" <bruce@.defreitas.com> wrote in message
news:04bb01c376c9$573808e0$a001280a@.phx.gbl...
> John, it's not that straight-forward. I was hoping
> there's some SQL function (like an IsPartitionedView) that
> just says that SQL Server THINKS this is a partitioned
> view. I have a view and it's not being treated by SQL as
> partitioned, in as far as using the separate table's
> indexes, it's table scanning EVERY table's index. The
> Tales have the correct CHECK constraint, and all the rules
> APPEAR to be followed ok, so I was hoping there was a way
> to see why SQL Server is just treating this view as a
> regular UNION'd set of tables, not as a "partitioned"
> view.
> Scripting out the view doesn't show you the table
> attributes, like the NULL PADDING setting, or the
> constraints, etc...
> There's probably no way to see this I'm guessing, but
> thought I'd ask... THanks, Bruce
>
>
> >--Original Message--
> >Bruce
> >
> >Script out the view, it should be fairly obvious looking
> >at it if it is a partitioned view. I have not got 2000
> bol
> >where I am at the moment, but in 7 you will see multiple
> >tables joined using union all, I would think 2000 would
> be
> >the same.
> >
> >I hope that is what you meant.
> >
> >Regards
> >
> >John
> >.
> >|||Kevin, yes, adding the new index on the partition column
did the trick, thanks! It seems strange I need to add an
index on a column where every value is the exact same for
that table. The partition column was the middle column of
a 3 col PK. I had also tried changing the order of the
PK, so the parition column was col #1. But I didn't see
that helped, but adding a new index ONLY on the partition
column DID work, interesting! THanks a lot... Bruce
>--Original Message--
>There is no intrinsic property, it's purely a matter of
query optimization.
>You have to view the query plan and/or IO statistics to
determine if SQL is
>appropriately pruning table partitions from the query
plan.
>SET STATISTICS IO ON
>Look for scan counts of zero on the non-qualifying tables.
>Also, I've found that it is necessary to add an index on
the partitioning
>column(s), as non-intuititve as that seems, it helps the
optimizer in
>certain cases eliminate partitions
>..
>--
>Kevin Connell, MCDBA
>----
>The views expressed here are my own
>and not of my employer.
>----
>"Bruce de Freitas" <bruce@.defreitas.com> wrote in message
>news:04bb01c376c9$573808e0$a001280a@.phx.gbl...
>> John, it's not that straight-forward. I was hoping
>> there's some SQL function (like an IsPartitionedView)
that
>> just says that SQL Server THINKS this is a partitioned
>> view. I have a view and it's not being treated by SQL
as
>> partitioned, in as far as using the separate table's
>> indexes, it's table scanning EVERY table's index. The
>> Tales have the correct CHECK constraint, and all the
rules
>> APPEAR to be followed ok, so I was hoping there was a
way
>> to see why SQL Server is just treating this view as a
>> regular UNION'd set of tables, not as a "partitioned"
>> view.
>> Scripting out the view doesn't show you the table
>> attributes, like the NULL PADDING setting, or the
>> constraints, etc...
>> There's probably no way to see this I'm guessing, but
>> thought I'd ask... THanks, Bruce
>>
>>
>> >--Original Message--
>> >Bruce
>> >
>> >Script out the view, it should be fairly obvious
looking
>> >at it if it is a partitioned view. I have not got 2000
>> bol
>> >where I am at the moment, but in 7 you will see
multiple
>> >tables joined using union all, I would think 2000 would
>> be
>> >the same.
>> >
>> >I hope that is what you meant.
>> >
>> >Regards
>> >
>> >John
>> >.
>> >
>
>.
>

Friday, February 24, 2012

Is having a trigger that inserts a row in Table A, when a row in same table is inserted by

I want to insert a row for a Global user in Table 'A' whenever ADO.Net code inserts a Local user row into same table. I recommended using a trigger to implement this functionality, but the DBA was against it, saying that stored proecedures should be used, since triggers are unreliable and slow down the system by placing unecessary locks on the table. Is this true OR the DBA is saying something wrong? My thinking is that Microsoft will never include triggers if they are unreliable and the DBA is just wanting to offload the extra DBA task of triggers to the programmer so that a stored procedure is getting called, so he has less headache on his hands.

Thanks

Hey,

I would prefer stored procedure; the reason is I have no control over triggers, so it makes it easier from a maintenance perspective on me, which is what I think you may also be under that restraint? I don't know how much slowing down it would do; I would think a lot of that depends on volume of data as well.

If you are inserting the main data using a stored procedure, then that stored procedure can do two inserts. You can also group them in a transaction so if one fails, both statements are rolled back for safety purposes.

Microsoft includes a lot of things: they include xp_cmdshell which most DBA's disable because of the power of it. So they will include things even though they may not be the best to implement...

|||

Actually, your DBA is correct. I always recommend, if possible, opting for stored procedures as opposed to triggers. The trigger will save you time if you are inserting rows into the table from many different sources in many different ways. But, if the only point of entry is a stored procedure, there's no reason not to place it in the sp. The farther back in SQL Server version you go, the less reliable triggers seem to get - and, yes, they can place locks on tables. Microsoft included them because they have their place - but it is a mistake to use them as substitutes for logical flow.

This shouldn't be a lot of extra work on you. If you aren't using a stored procedure already, they are much faster and far more secure than "on page" SQL. If you have insert statements in various parts of your application inserting to the same table, then you should be encapsulating them into a stored procedure anyway! Your DBA's job is to protect the efficiency and cleanliness of your database. Adding triggers unnecessarily affects both.