Quantcast
Channel: Forum SQL Server Database Engine
Viewing all 15694 articles
Browse latest View live

cannot drop the view 'XXX' because it does not exist or you do not have permission

$
0
0

We migrated our servers from 2005 to 2014, User is able to delete it in the 2005 server But in 2014 we are getting the error as do not have permission or does not exits We have given to same permissions and even he is a system admin.In our application side they are not able to drop the view the application users are connecting through a user in our database he has all the permissions and he is sysyadmin

view: username.viewname

username is the schema name

In our db side I am able to drop it

drop view username.viewname

but at our application side its not working

in 2005 it worked properly


Opened my website database in Management Studio--now my website cannot log in

$
0
0

My new data-intensive website uses SQL Server 2005 Express.  It has been working fine for weeks so I know that my connection string is correct.  A few days ago I downloaded SQL Server 2005 Express Management Studio and made a slight adjustment to one of the views in the database.  Since then the website has been unable to log in to the database.

I am getting this error message:  "cannot open database <name> requested by the login.  The login failed.  Login failed for user 'NT AUTHORITY\NETWORK SERVICE'."  I do not have a user account with that name.

It is possible that Management Studio is not the cause of the problem--I also copied some slightly modified pages into my website on the same day.  However I have replaced most or all of the pages with the ones that were previously working.


LouatMonaco

two-field index semantics, indexed versus included

$
0
0

We have a piece of code, a statement in an SP, that is sporadically misbehaving - instead of running in 0.2 seconds it gets a bad plan and runs in 80 seconds.  Does this whether or not we hang an option(recompile) on it. It involves a couple of smallish (typically well under 1000 row) temp tables joined to some larger perm tables.

Several very similar statements seem to run fine 100% of the time.

One small difference in the problem case is that the central perm table had a slightly different index for the one that misbehaves.

The other cases/statements each have an index that covers two fields, "on (xid, aid)", both simple integer identity pks for related tables.

The one that misbehaves had an index on one field and the other included, "on (yid) include (aid)".

I would have thought this just fine, maybe even preferable - but judging on the evidence, perhaps not.

So here's the (maybe) interesting part, xid and yid are nullable - and are null 90% of the time.  aid is not null.

Is there some semantic difference to this, that if the first index field is nullable then it suddenly matters a lot if the second field is indexed versus included?

Thanks,

Josh

FILESTREAM error at server startup

$
0
0

When one of our SQL Server instances starts up I am getting the following errors in the log:

07/04/2016 08:21:59 FILESTREAM: effective level = 0, configured level = 2, file system access share name = 'MSSQLSERVER'.
07/04/2016 08:21:59 FILESTREAM feature could not be initialized. The Windows Administrator must enable FILESTREAM on the instance using Configuration Manager before enabling through sp_configure.
07/04/2016 08:21:59 Error: 5597, Severity: 16, State: 2.

However the impacted SQL Server service has the configuration:

If I subsequently try to enable this within SQL Server I get the error:

Prior to this problem, the most recent restart of SQL Server had the following message in the SQL errorlog:

05/04/2016 01:04:33 FILESTREAM: effective level = 2 (remote access enabled), configured level = 2, file system access share name = 'MSSQLSERVER'.

and everything worked fine.

For additional information, these databases are participating in an AlwaysOn Availability Group however the non-FILESTREAM databases have all started successfully.

Can anyone assist?

Thanks for your help.

sql server 2008 stored procedure select one table and get selected table's column description from another table

$
0
0

Dear All,

    Good Day! I am MS Visual Studio 2008 (Visual C#) and MS SQL Server Management Studio 2008.

In this i have to generate a report.  In this my C# code is below.

cn.open();  //to opren the remote server connection
                 cmd = new SqlCommand("dbo.GetReport", cn);
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.AddWithValue("@fldStnName", SqlDbType.VarChar).Value = txtRshwavrpt.Text.Trim();
                 cmd.Parameters.AddWithValue("@fldFrmDtEpoch", SqlDbType.BigInt).Value = frmDateEP;
                 cmd.Parameters.AddWithValue("@fldToDtEpoch", SqlDbType.BigInt).Value = toDateEP;
                 cmd.Parameters.AddWithValue("@fldShiftName", SqlDbType.VarChar).Value = txtRsltSft.Text.Trim();

                 using (SqlDataAdapter adpt = new SqlDataAdapter(cmd))
                 {
                     DataSet ds = new DataSet();
                     adpt.Fill(ds);

                     gridGroupingControl1.DataSource = ds;

                 }

                 //cmd.ExecuteNonQuery();
                 cmd.Dispose();

In SQL server i am using stored procedure to get report. Normally to get report i am using the following query.

IF @fldStnName='tAerator' BEGIN SELECT * FROM [itcdb].[dbo].[tAerator] WHERE fldepochts>=@fldFrmDtEpoch AND fldepochts<=@fldToDtEpoch ORDER BY fldepochts DESC END

By this above query i can adapt that particular to gridgroupcontrol view. But while i am showing in grid view that instead of selected (tAerator) table's column i want to show description of column from another table. Normally use with condition in query. But this below query not working. How to do it. Can you please help me to do this. 

SELECT [itcdb].[dbo].[tValidation].[tLblText] FROM [itcdb].[dbo].[tValidation] WHERE [itcdb].INFORMATION_SCHEMA.COLUMNS = [itcdb].[dbo].[tValidation].[tFName] 

    


Thanks & Regards Sasi ................. Go Green

Sql Server 2008 R2, table with Image cloumn consuming 380 GB while actual value is aroung 4 GB

$
0
0

Hi All,

We have a table with image column and its consuming 380 GB storage. We tried to dump the data to a new table or file its just consuming 4 GB.

Below is what we did to dump the table to a file.

EXEC master..xp_cmdshell 'bcp "select Content from tablename " queryout "D:\tmp\tmp.dat" -T -c'

Any lead or suggestion why its consuming so much space?

Thanks,

-SreejitG

Cannot send mails to mail server. (The operation has timed out.)

$
0
0

HI Everyone,

  IF anyone faces this issue with Database mail  on SQL 2012 SP3? it used to work till yesterday and all of sudden stopped receiving mail alerts from SQL and found this. 

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2016-04-03T17:32:25). Exception Message: Cannot send mails to mail server. (The operation has timed out.).
)

Any help or workaround is greatly appreciated. 

Thanks


Please Mark As Answer if it is helpful. \\Aim To Inspire Rather to Teach

SCOM 2012 and MS SQL Server

$
0
0

Hello Expert ..

the SCOM always send  Alert: SQL 2008 DB Average Wait Time is too high and actually couldn't find out what this alert means or what related to and when I check SQL everything seems normal..

any help what does this mean and should I pay any attention to this

Thanks


Problem to connection

$
0
0
Hi,
I get error
Server Error in '/Start3' Application.


Cannot open database "web_schema" requested by the login. The login failed.
Login failed for user 'ws_login'.


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.


Exception Details: System.Data.SqlClient.SqlException: Cannot open database "web_schema" requested by the login. The login failed.
Login failed for user 'ws_login'.


Source Error:


An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:



[SqlException (0x80131904): Cannot open database "web_schema" requested by the login. The login failed.
Login failed for user 'ws_login'.]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6568558
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +717
   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4515
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +84
   System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +53
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +368
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +6597311
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +6597891
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) +942
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1162
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +72
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +6601145
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +103
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +2102
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +116
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +1079
   System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +6605639
   System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +233
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +278
   System.Data.SqlClient.SqlConnection.Open() +239
   Start._Default.refresh_ddlist() +691
   Start._Default.Page_Load(Object sender, EventArgs e) +135
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.3428

using this

<add name="Mssqlconn2" connectionString="Data Source=WIN-O3CHI1MHE5D\SS2012EXPR;Initial Catalog=web_schema;Integrated Security=False;User ID=ws_login;Password=????" providerName="System.Data.SqlClient"/>

within Web.config, while by the same login and password, I can login the database by SSMS. Why?


Many Thanks & Best Regards, Hua Min

SQL Server after upgrade from Win7 to Win10

$
0
0

After upgrade to windows 10 the SQL server process cannot start.

In logs I hvae message:

"Cannot use file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\master.mdf' because it was originally formatted with sector size 4096 and is now on a volume with sector size 3072. Move the file to a volume with a sector size that is the same as or smaller than the original sector size"

It was SQL Server Express version

I was reinstall using SQL Server 2016 but I still have the same error (Error code: 0x84B40002) with same as above message in logs.

KA

SQL 2000 - Any option to find query history? Need execuse to shut down old server

$
0
0

We have an old SQL 2000 server that at some point, just stopped being used, or at least we think so.  Im running a profiler trace now to see what shows up, but since this is 2000, I cant use dm_exec_sql_text to see any statement history, and from what I recall, this kind of information really isnt kept anywhere with this version.  I also looked at the error logs and hardly anything showed up in the last year or more that wasnt "system event noise".

My "redneck" solution = shut it down and see who complains :)

Any other suggestions to look for "user activity"

FlushCache:clean up and I/O requests taking longer

$
0
0
Recently lot of messages gets logged in sql server as

12:01 -> SQL Server has encountered  x occurrence(s) of I/O requests taking longer than 15 seconds to complete on file

12:00 PM -> FlushCache: cleaned up bufs with writes in ms (avoided new dirty bufs) for db


I understand that the flush cache will be logged if it cross the  checkpoint interval,
but does I/O request taking longer to complete relates to Flushcache cleanup?

because at the time of I/O request taking longer complete I did not see any heavy query running, Also want to know does alwayson can be responsible for this ? as noted there is no delay in AOAG dashboard(Synchronized)

Best Regards Moug

Once the backup completed Disk I/O error occurred - SQLServerLogMgr::LogWriter: Operating system error 1117 encountered.

$
0
0

Hi I'm using windows server 2012 R2 with SQL server 2012 enterprise. I have this server from AWS. Today got the Disk I/O error so many times. But I found that whenever the backup is done it has occurred.
SQL server error Log:
SQLServerLogMgr::LogWriter: Operating system error 1117(The request could not be performed because of an I/O device error.) encountered.
Write error during log flush.

Windows event log:
The IO operation at logical block address 0x5b8b00 for Disk 3 was retried.
The system failed to flush data to the transaction log. Corruption may occur in VolumeId: :F, DeviceName: \Device\HarddiskVolume5. (The I/O device reported an I/O error.)
Help he to fix this permanently

How to Select all the Id's details

$
0
0

Hi,

I have a scenario where I want to get the top 1 of all the id's

table is like below

ID Path status
A001 //folder1/file1.txt Rcv
A001 //folder1/file2.txt Rcv
A001 //folder1/file3.txt Rcv
A002 //folder2/text.txt Rcv
A002 //folder2/text1.txt Rcv

Here I want to get output as below, Need top 1 row per ID

ID Path status
A001 //folder1/file1.txt Rcv
A002 //folder2/text.txt Rcv

Please advise,

Sarva.

How to do SQL Server Health Check...?

$
0
0

Hi,

I am new to DBA area..Is there any way to do SQL server health check ( on database wise) ? what are the scenarios we have to consider..



Log file full issue in 'SIMPLE' recovery model

$
0
0

Hi, 

We are running a package. We know that the Log file will be extensively used during the package execution and hence changed the Recovery model to 'SIMPLE'.

But to our surprise, the transaction failed stating the Log file for the database 'XXXX' is full. There is no enough space in the disk. 

When I checked the log_reuse_wait_desc for the database it shows - 'ACTIVE_TRANSACTION'. 

How to perform the transaction. To my surprise, why the log file is still growing in SIMPLE recovery mode. 

Please help me to understand. 

Create non cluster with where condition

$
0
0

Hi,
I have a table with millions of rows. every day I perform an update operation based on the where username='myname'.. I already created a non-clustered for the username column. But still I have deadlocks during the update operation.

Now I want to create a non clustered with where condition. Like this,
Create NONCLUSTERED INDEX on mytable where columnname='myvalue'. I don't know is this possible or not, please suggest a solution.


Question regarding index on a table

$
0
0

Consider a table with 3 columns A, B & C. It has one index Ind1 on all the 3 Columns A, B & C.

For the any queries that are querying on Column C, is Ind1 good enough or do I have to create another exclusive index on Column C? Will that additional index help in performance gain? or would that just be a redundant index causing additional overhead?

Thanks

Is there a hint like (optimize for count(t.guid)=@precount)?

$
0
0

You've probably seen it, it's a common app pattern, when a user query is going to run first a counting-query is run to estimate the number of rows that match and maybe store their PKs into a table, then a second query is run to actually fetch the data.

The counter is usually pretty quick, it's the second query, typically fetching a page at a time, that may run slow, as it has to join many tables and access fields not in convenient indexes.

Something like:

insert into temptable(myguid, datapk) select @myguid, pk) from ... a bunch of tables and conditions. set @precount = @@rowcount;

-- might insert zero rows or anything up to a million. select top 60 * from temptable t inner join a bunch of tables and conditions where t.guid = @myguid; -- typically also uses a ranking function to define pages

What I'd like to do is to accurately hint that second query, something like:

select top 60 * from temptable t inner join a bunch of tables and conditions where t.guid = @myguid option(optimize for count(t.guid)=@precount);

I'm pretty sure such a thing does not exist, but if it did I could use it very heavily around here to try to avoid some of those huge variations in plans and execution times that bedevils this kind of code otherwise.

Any chance of doing anything at all similar?

Thanks,

Josh




SQL server 2008 stored procedure How to get variable value

$
0
0

Dear All,

   Good Day! I am using sql server 2008 and Visual Studio 2008 C#. In this i want read a tValidation Table get text and set to variable. Then use of SELECT AS query and adapt these all values to grid view using C#. In this i could not get variable vale. How to fix this problem.

SQL stored Procedure query is:

USE [itcdb]
GO
/****** Object:  StoredProcedure [dbo].[sAerator]    Script Date: 11/01/2015 09:45:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[sAerator]
	-- Add the parameters for the stored procedure here
	@fldStnName varchar(50), @fldFrmDtEpoch bigint, @fldToDtEpoch bigint, @fldShiftName varchar(10)

	AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here

    -- IF @cost <= @compareprice
    -- Station 0 input 0

    DECLARE @fldAE1 varchar(100)
    DECLARE @fldAE2 varchar(100)

DECLARE @fldNm varchar(50)

    SET @fldNm='fldAEdnt'
    SELECT @fldAE1 = [itcdb].[dbo].[tValidation].[tLblText] FROM [itcdb].[dbo].[tValidation] WHERE  [itcdb].[dbo].[tValidation].[tFName]= @fldNm

    --SET @fldNm='fldAEshift'
    SELECT @fldAE2 = [itcdb].[dbo].[tValidation].[tLblText] FROM [itcdb].[dbo].[tValidation] WHERE  [itcdb].[dbo].[tValidation].[tFName]='fldAEshift'

SELECT fldAEdnt AS fldAE1 , fldAEshift AS fldAE2 FROM [itcdb].[dbo].[tAerator]

END

And C# side Code is:

                 cmd = new SqlCommand("dbo.sAerator", cn);
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.AddWithValue("@fldStnName", SqlDbType.VarChar).Value = txtRshwavrpt.Text.Trim();
                 cmd.Parameters.AddWithValue("@fldFrmDtEpoch", SqlDbType.BigInt).Value = frmDateEP;
                 cmd.Parameters.AddWithValue("@fldToDtEpoch", SqlDbType.BigInt).Value = toDateEP;
                 cmd.Parameters.AddWithValue("@fldShiftName", SqlDbType.VarChar).Value = txtRsltSft.Text.Trim();

cmd.ExecuteNonQuery();

                 using (SqlDataAdapter adpt = new SqlDataAdapter(cmd))
                 {
                     DataSet ds = new DataSet();
                     adpt.Fill(ds);

                     gridGroupingControl1.DataSource = ds;

                 }


Thanks & Regards Sasi ................. Go Green

Viewing all 15694 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>