Quantcast
Channel: SQL Server Data Access forum
Viewing all 4164 articles
Browse latest View live

query how to add columns of each row using sql query

$
0
0

Hi

I want to subtract columns from each row

Please help me.I have given the details below

LeaveDateStart

LeaveDateEnd

CL

EL

HL

LOP

BCL

BEL

BHL

BLOP

Opening

0

0

0

0

7

34

0

0

.5

4

6.5

30

1

5.5

30

0

5.5

30

Total

1.5

4

I want to get BCL-CL=7-0.5 =6.5

6.5(BCL)-1 (CL)=5.5(BCL)

5.5(BCL)-0(CL)=5.5(BCL)

The same is repeated for other columns

 

Please help me to get solution

Thanks and regards

N.Ramachandran

 


What database to use insted of Excelfile with OLEDB

$
0
0

Hello there,

I'm writing a small program that needs a database to store information. Currently I'm abuseing an excel file to store the data, since for a first try it seems the easiest way to me as a beginner. With basic functionalities the program is working fine now. 

I decided to program it as a UWP-App to be able to adapt it also to mobile devices later on. In fact I was kind of suprised that something like OLEDB works for this. Installing my former working software on an other computer I found out, it unfortunately doesn't. I had to install the Access Database Engine first, to make it work.

Since I want to supply it possibly also in the store when I like the result, to me this seems not to be a good solution.

Nower state:

Software is running on PC and accesses an excel file, that is used as database, via SQL queries. I expect performance won't be an issue. I would be quiet suppriesed if any user would make it to bring 6000 entries ore more (maximum 8 tables of this size) to one table. Also I think that maximum 32 tables will be sufficient (depends a bit on the layout that I will use for future functions).

My plan is now to find a Database that can be accessed with SQL-queries and runs under windows on PC and Mobile systems. Because I also think about possibly to supply a comercial version (or at least add ons) of the program, licensing is an issue. Furhter it would be great if there would be a possibility to adapt things to Android later on (sorry Appel ;) ). Unfortunately I have no clue about what to use or look for. My first ideas where some open XML stuff (which hase shown to be kind of complicated for my use) and OLEDB that seems to cause problems on installation(aditional database engine must be installed separately). I also read that there is something that is called JSON (but till now I only know that it's used to store and/or transfer data). Also Unicode caracters should be supported. Most important to me are latin letters in all variations (é,è,ê,ã,ó,ö,ä,ç etc.) but also arabic and cyrillic ones.

It would be great if anybody can give me a hint in which direction I have to search and what way to store my data is the best one for my use.

Thanks in advance

When I execute this application in another windows I receive this error: Cannot open database "TEST" requested by the login. The login failed. Login failed for user 'ME'.

$
0
0

How can I remove LOGIN from my c# Entity Framework program?

I'm writing a "WINDOWS APPLICATION" program in C# using Entity Framework and SQL Server 2014 Enterprise edition using

"Windows Authentication". and I want everyone be able to download, setup this program and modify its database content WHICH

IS LOCATED IN HIS/HER COMPUTER, such as add new record, delete record, modify. but this application is unable to connect to

this database because Login prevent access to database. So, How can I solve this problem so that everyone can access to its

database and modify it without login problem?

When I execute this application in another windows I receive this error: Cannot open database "TEST" requested by the login. The login failed. Login failed for user 'ME'.

problems logging into software

$
0
0
I have a HP laptop that was running Windows 8.  This morning (March 7, 2016) my system decided to upgrade, on its own, to windows 10 and now I can not log into my business software 123Pet.  I did not try to upgrade to windows 10 because this laptop is only used for my business database software and now I can not access that software.  It tries to open but times out and a pop up windows says SQL could not be opened on this computer.  Please help!

OdbcType for SqlDbType.Structured (SqlCommand vs OdbcCommand)

$
0
0

I'm using Table-Valued parameter for a Stored Procedure and need to invoke it through C# code.

CREATE TYPE DeviceList
AS TABLE
(
  deivce_id varchar(10) not null
);
GO

CREATE PROCEDURE GetMyDeviceList
    (@DevList AS DeviceList READONLY)
AS
BEGIN
  SET NOCOUNT ON; -- actual implemetation hidden
  SELECT deivce_id FROM @DevList;
END;
GO
 

I'm able to invoke the stored procedure using SqlConnection. This is my code which works:

using (SqlConnection DbConnection = new SqlConnection(Settings.SqlConnectionString))
{
	DbConnection.Open();
	try
	{
		using (SqlCommand  DbCommand = DbConnection.CreateCommand())
		{
			DbCommand.CommandTimeout = Settings.QueryTimeoutInSec;
			DbCommand.CommandText = "GetMyDeviceList";
			DbCommand.CommandType = CommandType.StoredProcedure;

			SqlParameter dataParam = DbCommand.Parameters.AddWithValue("@DevList", dataTable);
			dataParam.SqlDbType = SqlDbType.Structured;
			dataParam.TypeName = "DeviceList";

			using (SqlDataReader DbReader = DbCommand.ExecuteReader())
			{
				while (DbReader.Read())
				{
					MyList.Add(DbReader.GetString(0));
				}
				DbReader.Close();
			}
		}
	}
	catch (Exception ex)
	{
		Logger.Log(ex);
	}
	DbConnection.Close();
}

But I'm not able to achieve the same using OdbcConnection. My project uses OdbcConnection all over and I'm bound to use the same. The closest I got was this code:

using (OdbcConnection DbConnection = new OdbcConnection(Settings.ConnectionString))
{
	DbConnection.Open();
	try
	{
		using (OdbcCommand DbCommand = DbConnection.CreateCommand())
		{
			DbCommand.CommandTimeout = Settings.QueryTimeoutInSec;
			DbCommand.CommandText = "GetMyDeviceList";
			DbCommand.CommandType = CommandType.StoredProcedure;

			OdbcParameter dataParam = DbCommand.Parameters.AddWithValue("@DevList", dataTable);
			// Above line throws ArgumentException
			// No mapping exists from object type System.Data.DataTable to a known managed provider native type.

			using (OdbcDataReader DbReader = DbCommand.ExecuteReader())
			{
				while (DbReader.Read())
				{
					SignalledDevices.Add(DbReader.GetString(0));
				}
				DbReader.Close();
			}
		}
	}
	catch (Exception ex)
	{
		Logger.Log(ex);
	}
	DbConnection.Close();
}

OdbcParameter.OdbcType enum hos no alternative for native data type or structured data type.

Can someone help me with this?

Set Transaction Isolation Level to Read Uncommitted for our applications

$
0
0

Hi everybody,

This weekend we discovered that one of our applications failed to set transaction isolation level to READ UNCOMMITTED (our default setting for all other applications). Obviously we would need to provide a hot fix, but I'm wondering if there is another way to remedy the situation?

We're using ODBC (DSN file) for connections. I read this blog post https://blogs.msdn.microsoft.com/ialonso/2012/11/26/how-to-set-the-default-transaction-isolation-level-server-wide/ which implies there may be a way to set it on ODBC level. I ran ODBC but I do not see any option to set transaction isolation level.

What would be a way to set it besides changing the application code?

Thanks in advance.


For every expert, there is an equal and opposite expert. - Becker's Law


My blog


My TechNet articles

JDBC Connection to SQL Server on my laptop

$
0
0
Can anyone help me with getting this set up?

Alan

isolation level escalation

$
0
0

Hi All:

We are facing DB deadlock issues recently, from analysis log it shows it's due to the transaction isolation level is escalated to SERIALIZABLE.

As I know, Sql server engine would escalate the transaction isolation level if it's not specified, however from this link https://technet.microsoft.com/en-us/library/ms184286(v=sql.105).aspx, it seems the isolation level will be escalated regardless the value specified when transaction is started.

I'd like to know if transaction isolation level could be stopped from being escalated to SERIALIZABLE when READ COMMITTED level is specified? 

Thanks in advance

kind regards


fight for future!


Problem in accessing a table in Tempdb

$
0
0

Hi Everyone,

I have problem in accessing a table in tempdb and would appreciate if someone assist me on that.

Our database is on SQL SERVER 2014. We have a table(table1) that has been created by user1 and with the schema of user1. So the full name of table is tempdb.user1.table1. Now I want to access to this table by User2. I have created a role(role1) in tempdb& model databases and give select permission to User1 schema. If I connect to SSMS by using User2 , I am able to select from tempdb.user1.table1. But if I try to call a sp in other database in which it has reference to tempdb.user1.table1, I face with below error message.

The SELECT permission was denied on the object 'table1', database 'tempdb', schema 'user1'.



A.G

SQL with Excel

$
0
0

Hello

I have sql 2012 and i want to access one database by Excel 2013 but i need Excel sheet to access the database and should have synced data from SQL server every 1 min ?

please how can i do that ?


MCP MCSA MCSE MCT MCTS CCNA

I am facing this issue intermittent

$
0
0

Dear Team,

Please find the snapshot I facing this very Intermittent.


satish Kumar

Need to open ASPX page when new row inserted in to sql server database table.

$
0
0

Hi Team,

I have a requirement that when ever new row inserted into sql server database table automatically I need to open one of the aspx page.

In our scenario we are getting data from third party tool to sql server database table individually like when ever each row gets insert into third party tool that row gets insert into our sql server database table. 

we have developed one web application in visual studio 2010, we are retrieving newly inserted row into sql server in to our one of the aspx page (New vehicle information.aspx) and we are displaying the data.

our requirement is when ever new row inserted into sql server database table from third party tool, automatically by identifying it need to get open our aspx automatically.

please let me know how to achieve this kind of problem.

thanks in advance.

Best regards,


shekar


Permission issue on running dynamic SQL

$
0
0

Hi Everyone.

We have a stored procedure called SP1. This SP is being called by user1. Since User1 does not have direct access to table1 in database1, so we have to execute the SP by 'with execute' option using a user2 who has read access to table1

Below is the definition of SP1 .

Use database1

go

alter procedure SP1

@TableName as varchar( 50)

with execute as User2

as

declare @SqlStr varchar (200 )

select

      @SqlStr  = " select * from database1.dbo.table1 t1 inner join " + @TableName + " t2 on t1.code = t2.code"

exec sp_executesql @SqlStr

go

when I ran exec   SP1 'tempdb.User1.table2' , I faced with below error message.

The SELECT permission was denied on the object 'table2', database 'tempdb', schema 'User1'.

User2 has read access to Table1 in database1 and also I have given select permission on User1 schema on tempdb. But still it is complaining about select permission on table2.

I would appreciate if someone helps me on this issue.

Thanks


A.G

SQL timeout when executing odata sync

$
0
0
                 
Hi All,

I'm new to using SQL and I'm trying to sync data from Project Online to an on-premise SQL server. The table I'm trying to sync is the TaskTimephasedDataSet and I've been following the procedure outlined in https://msdn.microsoft.com/en-us/library/office/dn720853.aspx?f=255&MSPPError=-2147217396 

The PWA is in Project Online and I'm trying to pull the data into a local SQL 2014 database.

I've developed the query via Visual Studio 2015 following the procedure provided for SSIS packages by Microsoft. The query was developed pointing to our test PWA environment and it runs quickly (less than 30 seconds however there are only 2 project records in the test PWA).

I then change the Connection to point to the production PWA which contains just over 100 projects. When I hit execute Visual Studio rebuilds the project and then sits there validating the project and after about an hour or so times out with this error:

"Package Validation Error
Error at Data Flow Task (OData Source): The operation has timed out"

I'm using the following query:

$select=ProjectId,TaskId,TimeByDay,ProjectName,TaskCost,TaskName&$filter=TaskCost ne 0 and year(TimeByDay) eq 2016 and month(TimeByDay) eq 3&$top=5&$format=json

Any help or pointers on how to get this data into SQL would be greatly appreciated.

Regards,
Conrad




problem with 'execute as login' on running stored procedure

$
0
0

Hi Everyone.

We have a sp1 which is being called by User1. In this SP there are some tables that User1 does not have access to them, so I have to create another user2 and give proper permission to that user.
when I ran the sp1 while I am login by User1 with 'execute as login =  'User2'',I recieved below error message:

Cannot execute as the server principal because the principal "User2" does not exist, this type of principal cannot be impersonated, or you do not have permission. 

But if I ran the same statment while I login as sysadmin , I dont have any problem.

I would appreciate if someone help me on this.

Thanks


A.G


Datetime dataype Support in Stored procedure Output parameter in ODBC

$
0
0

Hello,

We are migrating our application which was using SNAC OLEDB driver. This application performs different SQL operations like calling stored procedure and performing insert, update, delete, select.

From now it application will use Microsoft ODBC Driver 11 as MS has deprecated OLEDB support.

Following is the detail of the application:

1. Application calls the stored procedure using ODBC driver 11.
2. Stored Procedure is having datetime datatpyes (DateTime, SmallDateTime)) as its Output parameter. Also datetime datatype can be in any format. ( yyyy-mm-dd OR MM/DD/YYYY OR any other US, UK format).
3. I am using ODBC API SQLBindParameter for stored procedure parameter binding. There are few parameters required by this API, from which 2 are Value Type(C datatype) and Parameter Type( SQL Type).

I used two ways to execute Datetime datatype from SP.

Method 1:

  • When I provide C dataype as SQL_C_CHAR and SQL Type as SQL_C_CHAR and execute the stored procedure it takes all the input date format with out any error but gives output in Alphabetical date format (Apr[il] [15][,] 1996)

Problem:

  • I expect output in ANSI format (YYYY-MM-DD). For more info of the date formats see, https://technet.microsoft.com/en-us/library/ms180878%28v=sql.105%29.aspx#SQLServerDateandTimeLimitations

Method 2:

  • When I provide C dataype as SQL_C_CHAR and SQL Type as SQL_Type_TIMESTAMP and execute the stored procedure it takes only ANSI format as input. For rest of the input format it gives error "Invalid character value for cast specification". But here it gives the output in required format which is ANSI.

Problem:

  • I want all the date formats to be working as stored procedure input parameter.

Question:

1. Is there any way in ODBC( Any API or property) by which we can convert any input date format to ANSI before sending to SQL server? so that all the date format support can be handled.

2. OR can we convert output format to ANSI ?

Regards,

Seema


seema

SQL SERVER AGENT IS STOP WORKING

$
0
0

Need help. One of the services is stop working, and we can't use the program. Could someone please assist us .

thanks.

Anne

Oracle Client component not Found by SSIS MS Visual Studio 10

$
0
0

Hi expert,

this is my first time using MS Visual Studio 10 with Windows 2012, I run SSIS that contain Oracle Connection as datasource, but it raise error 'Oracle Client and Networking component were not found..Oracle Version 7.3.3..bla bla' when run. I've tested by TNSPing, ODBC connection, Linked Server are all worked fine...

please your helps are very needed..

thank you,

regards

Urbel.

SQLServerLogMgr::LogWriter: Operating system error 170(The requested resource is in use.) encountered.

$
0
0

Hi All,

I am getting below error in sql server 2012 in errorlog and my database goes in recovery.

SQLServerLogMgr::LogWriter: Operating system error 170(The requested resource is in use.) encountered.

my sql server is in cluster. Kindly help.

Sachin.

After POODLE related fix(port 1433) SQL Server login fails

$
0
0

We are facing an issue in our customer site after making fix suggested for POODLE vulnerability in their DB server machine(no changes were made to application). Our Visual Basic application does not connect to database after this fix and gives an invalid connection string attribute error. The application uses ODBC connectivity. (error screenshots have been attached). Could you please suggest a solution?

Fix provided as per instructions in  sites below. (I.e., Change parameters for SSL 2.0 and 3.0 and TLS 1.0 in Registry. Use TLS 1.0 or higher instead.)

schneier.com/paper-ssl.pdf
support.microsoft.com/kb/187498
nessus.org/u?247c4540
openssl.org/~bodo/ssl-poodle.pdf
nessus.org/u?5d15ba70

After doing fix, application failed to login and SQL Server remote login also failed. Screenshot of errors attached.

Server Environment:

SQL Server 2008 running in Windows Server 2003 Enterprise edition

Application Environment:

Windows server 2003 enterprise running VB application


Viewing all 4164 articles
Browse latest View live


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