Setting And Getting User-Specific Data In A Session
Oct 19, 2000
Hi:
I like to know how I may store some user-specific data at the beginning of a session and retrieve the same data later during the session in a SQL command. For those of you familiar with ORACLE, I am trying to mimic the SET_CLIENT_INFO and GET_CLIENT_INFO functions of ORACLE's DBMS_APPLICATION_INFO package on SQL Server.
Is there a way to specify a given Schema as the currently active one for a given database session ? i.e. im looking for somthing like:
Use Schema=<name>
Execute Queries / Stored Procs, etc
.....
I want all the Queries and Stored Procs to execute on the Schema set initially.
I can't use the Default_Schema on the User to do this due to certain restrictions in the way we create users and Schemas.
I know that i can always qualify the objects in the Queries with a Schema Name, but i have a requirement where the Queries need to be generic in nature and need to run on one of many identical schemas in the Database. Is this Possible in Sql Server?
I wanted to demonstrate something about CXPACKET wait type. For the purpose of this demo I've created a query in AdventureWorks database that uses a parallel query plan, an extended events session that captured the wait statistics for a single session and a query that shows the extended event's data. I ran it and it worked fine. Then I dropped and recreated the event session (to clear the data), in a new window I wrote a transaction that updated the table fallowed by waitfor statement so the first query will be blocked for few seconds and ran the whole thing again. The select statement was blocked as expected (ran for 9 seconds instead on 1 second as it ran without the blocking), but the wait stats that I got were almost identical to the those that I got without blocking the query.
--Query that uses parallel query plan With MyCTE as ( select top 50 * from Sales.SalesOrderHeader) select top 10000 * from Sales.SalesOrderHeader, MyCTE order by newid()
hi guys , does anyone of you have a good solution on the Error 1413: Communications to the remote server instance failed before database mirroring was fully started issue?
Hi, I would like to demonstrate mining temporary models in an ASP.NET application.
Creating, trainning, predicating actions are all witten at C# codes as follows:
Code Snippet
using (AdomdCommand cmd = new AdomdCommand()) { // Build temporary mining model cmd.Connection = asConn; cmd.CommandText = "CREATE SESSION MINING MODEL " + modelName + " (" + "HCVS_MemberId Text KEY," + "HCVS_MeasureDate DATE KEY TIME, " + "SysPressure LONG CONTINUOUS PREDICT, " + "DiaPressure LONG CONTINUOUS PREDICT," + "Pluse LONG CONTINUOUS PREDICT" + ") " + "USING Microsoft_Time_Series(Missing_Value_Substitution='Mean' ) "; // Periodicity_Hint = '{12}' cmd.ExecuteNonQuery();
// Train Data cmd.CommandText = "INSERT INTO " + modelName + " (HCVS_MemberId, HCVS_MeasureDate, SysPressure, DiaPressure, Pluse) " + "OPENQUERY([Healthcare], " + " 'SELECT HCVS_MemberId, HCVS_MeasureDate, SysPressure,DiaPressure,Pluse" + " FROM v_VitalSignForecast WHERE HCVS_MemberId=''" + id + "'' AND HCVS_MeasureDate>=''" + from.ToShortDateString() + "'' AND HCVS_MeasureDate<=''" + to.ToShortDateString() +"'' ')";
cmd.ExecuteNonQuery(); // Predict upon the Train Data. In addition, the standard deviation of each predicated value is retrieved cmd.CommandText = "SELECT FLATTENED " + "( SELECT *, " + " SysPressure + PredictStdev(SysPressure) AS [SysPressure_PlusStdev], " + " SysPressure - PredictStdev(SysPressure) AS [SysPressure_MinusStdev] " + "FROM PredictTimeSeries(SysPressure, " + fDays + ") AS SysTable " + ") " + "FROM " + modelName ;
AdomdDataAdapter adapter = new AdomdDataAdapter(cmd);
DataSet sysDS = new DataSet(); adapter.Fill(sysDS); The problem is that I do not know how to configure my Analysis Service Server to let ASP.NET account can utilize it. And ASP.NET account in trun impersonates the account who is authorized to use Healthcare DB in the Openquery. Please give a help. Thanks a lot.
I`m developing a library catalog in SQL server with a Cold Fusion front end, and I`m having some trouble with setting due dates for books when they get checked out. Most items in the library are due in a week, a month, etc., so it is easy to calculate the due date. However, we have a number of items that are due at the end of the working day.
So, I need to find a way to calculate "the next 5 PM", no matter what time of day it is, and store it in a datetime field? Any ideas?
Any help would be appreciated. Thanks, -Elizabeth S. Thomas Technical Librarian MAJIQ, Inc. ELizabeth_Thomas@majiq.com
Hi, How can I set the provider-specific property? Please let me know whether my code is correct.
For example, I want set provider-specific property set DBPROPSET_SQLSERVERDATASOURCE for memory based bulk copy operation. //Initialize the COM library. ...
//Obtain access to the SQL Native Client OLE DB provider. hr = CoCreateInstance(...);
hr = pIDBInitialize->QueryInterface(IID_IDBProperties, (void **)&pIDBProperties); hr = pIDBProperties->SetProperties(1, rgInitPropSet); pIDBProperties->Initialize(); // set provider-specific property DBPROPSET DbPropSetFL[1]; DBPROP DbPropFL[1]; DbPropFL[0].dwPropertyID = SSPROP_ENABLEFASTLOAD; DbPropFL[0].vValue.vt = VT_BOOL; DbPropFL[0].vValue.boolVal = VARIANT_TRUE; DbPropFL[0].dwOptions = DBPROPOPTIONS_REQUIRED; DbPropFL[0].colid = DB_NULLID; DbPropSetFL[0].guidPropertySet = DBPROPSET_SQLSERVERDATASOURCE; DbPropSetFL[0].cProperties = 1; DbPropSetFL[0].rgProperties = DbPropFL; IDBProperties* pIDBPropertiesFL = NULL; hr = pIDBInitialize->QueryInterface(IID_IDBProperties,(void **)&pIDBPropertiesFL); hr = pIDBPropertiesFL->SetProperties(1, DbPropSetFL); hr = pIDBPropertiesFL->Release();************************************************************ and,in SQL Server 2005 BOL,it mentioned (ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.ko/dataacc9/html/6e14fefc-4e0b-4847-a833-4cf0abe65d50.htm)Description: To bulk copy, SSPROP_ENABLEFASTLOAD property is set to VARIANT_TRUE. With this property set on the data source, the newly created session allows consumer access to the IRowsetFastLoad interface.If the property is set to VARIANT_FALSE, IRowsetFastLoad interface is available through IOpenRowset::OpenRowset by requesting the IID_IRowsetFastLoad interface or by setting SSPROP_IRowsetFastLoad to VARIANT_TRUE.Are there any one who provide a sample of above red-mark's not blues?
I have several reports for users to view on our Intranet. After installation of SQL 2005 SP2 patch, I cannot delete user or user's authority from Report in Properties Tab. An error message was shown on the status bar. It indicated that JavaScript Error: 'Return' statement outside of function. Seems something wrong with the 'Delete' funciton in SQL 2005 after update. The other functions worked fine. Could you point me out how to fix it or need to install any updates / hotfix. Thanks a lot!
Im using SQL Server 2000 sp2 for ASP application on windows server 2003 sp2.
Im getting an error 'Transaction context in user by another session'.
I have not at all used BEGINTRANS / committrans , No Insert / Update statements. the kind of SQL statements that i was using in that page load is only "SELECT statements"
Can any one give me answer how to get rid of this. I have used only one connection object. and result set as a loop containing few more result sets. But I m sure they are so complex statements to block the SQL server transactions.
I need to limit the sessions to access to SSAS cube to one per user. For example, if a customer uses Excel to check a cube, two or more users cannot use the same session or account.
We have a "main" SQL 2014 server who imports XML files using SSIS in a datacenter. In remote sites (which are warehouses), there is an instance of SQL 2014 Express. A merge replication is setup, as every operations done on each site must be "forwared" to the main database, as some XML files are generated as output for an ERP system.
Now, the merge replication replicate all the data to the server on each sites. But a specific site don't need the data of every other sites, only the data relevant to itself (which is the warehouse code). Is there a way to replicate only the data relevant to each individual sites to the subscribers? Or is there a better way than replication to accomplish this?
On MS-SQL 2k I have a created user. Security for the SQL instance isset to mixed.When I attempt to connect to SQL using Enterprise client on anothermachine on the local network using Windows Auth I get the error: DBName-Login Failed for user ('null')- Reason: Not associated with atrusted SQL Server Connection.What am I over looking?TIA
An old website I inherited uses sa to connect to SQL SessionState and had the details in the web.config. This is bad for security.The session state database is of -sstype "t" which is defined as:Temporary. Session state data is stored in the SQL Server tempdb database. Stored procedures for managing session state are installed in the SQL Server ASPState database. Data is not persisted if you restart SQL. This is the default.What kind of WIndows user, SQL Login, role and permissions do I need to create to make Session State secure? (Windows Server 2012 and SQL Server 2012 mixed mode authentication, Webfarm).
I am very early on in developing a website to track issues with projects which is tied to a SQL database. I have my Projects Table, my Users Table, and am creating a third table to track issues. I'm wondering what is the best way to assign specific users to specific data/projects. The user should only be able to view & update the projects assigned to him. He should not be able to see other projects. What is the best way to assign projects/data to the users to make sure they are only viewing their data?
We have an application running on SQL server. This application restores DB very frequently using Single user mode. Following are the SQLs that are executed to restore the database in single user mode and to get the database back in multi user mode.
alter database [test-db] set single_user with rollback immediate; --This sql is run using test-db use master;restore database [test-db] from database_snapshot = 'snapshot_test-db'; alter database [test-db] set multi_user;
After switching the test-db to single user mode some 4-5 background processes of Taskmanager jump in for the test-db kicking off the session that application has taken over in single user mode . These background process are deadlocked between them selves.
Please refer to the output of sp_who2 below at link [URL] .... and following is the deadlock XML.
NOTE: SPIDs in deadlock XML may differ from the output of sp_who2 as spids keeps on changing for these processes. <deadlock-list> <deadlock victim="process4bbfc78"> <process-list> <process id="process4bbfc78" taskpriority="0" logused="10000" waitresource="DATABASE: 5 " waittime="705"
[Code] ....
On searching for this problem I found out that people have faced similar problem but I was unable to find out the root cause and debug steps for this problem. Stopping the SQL server is provided as a solution to kick out these background processes but this is not a feasible in our case as code to restore DB runs very frequently resulting in this problem at a good frequency.
I also made sure that SQL Server Agent is not running. The SQL services running on server are SQL server, SQL Server Browser and SQL Server VSS Writer.
I've an online Database on a server. I've my own user name like "AKR". I want to create every table under that user. But what happens is whenever I create a table online it goes under "DBO" user name. How to avoid that?
My question is I want to be able to create a report specific to each individual user. More specifically I want to be able to create one report and once the user logs in with the appropriate credentials, I want the report to populate based on those credentials. Another important aspect is that each individual only sees their data. So once again I need to report to populate from the database based on the users logon credentails
actually a sever has a parallelism of 4 I would like to set the parallelism for a specific user to 2 without changing the code of the users application.
Is this possible.
As far as I understand with plan guides you just provide sql statements. Need I to find all queries from the user, and add plan guides for all the queries, or tis there a more elegant way to do it.
Hi, I want to receive a mail when a specific user connects. How can this be done best? Raise an alert? How? Btw, the 'Login auditing' is set to 'Failed logins only'. Suggestions are very welcome! Cheers, E
I'm new on ASP.NET 2.0Can anyone tell me how to get data from SQL to Session properties? In Classic ASP, it looks very simple as below.dim connset conn = server.createobject("adodb.recordset")rssql = "select myid, mypw from mydb where myid = '"& request("myid") &"' and mypw = '"& request("mypw") &"'"set rs = conn.execute(rssql)if rs.eof = true thensession("myid") = rs("myid")session("mypw") = rs("mypw")end if How to do the same things on ASP.NET?Many thanks!
Hi, I want to receive a mail when a specific user connects. How can this be done best? Raise an alert? How? Btw, the 'Login auditing' is set to 'Failed logins only'. Suggestions are very welcome! Cheers, E
In my application (infopath browser forms), First I get current user name thru System.Environment.UserName, after that, i want to check whether this user has access (read & write) permission to certain database, How do I do that? One way I tried before is to get all the users and stored the names in an array for comparing in my program, but can not figure out the SQL command (to get the database users), if there it is, please kindly tell me. Or if I can just pass the current user to check? Thanks in advance.
Hiya!I've combed the SQL Server 2000 online help but I don't see anythingakin to Sybase ASE's 'montor' views - equivalent to Oracle's V$views. The views are performance views which contain per sessioninformation such as:- SPID- number of logical read/write and physical read I/Os accumulatedthus far- CPU accumulated- Memoryetc.Does anyone know if I can snarf that data from SQL Server 2000?Thx!--Pablo Sanchez, Blueoak Database Engineeringhttp://www.blueoakdb.com
This is my first time to deploy an asp.net2 web site. Everything is working fine on my local computer but when i published the web site on a remote computer i get the error "Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed" (only in pages that try to access the database) Help pleaseee
I have an web application where the users has to run SQL scheduled jobs from the webpage. How to assign permission to a specific user to run specific jobs without making them a member of a Sysadmin role?
Any ideas you all smart people? Thanks in advance!
I have a database instance which of course I can connect to and edit data. I would like to set up other users for this database that can just as easily connect but that only read data?
I'm trying to write data from a session into database but it won't work. Could someone help me what is wrong with this.
cobjDT = Session("cart") For each cobjDR in cobjDT.rows Dim cmdInsert2 as New SQLCommand("order_details", loConn) cmdInsert2.CommandType = CommandType.StoredProcedure
cmdInsert2.Parameters("@Mangd").Value = Request(cobjDR("Quantity")) loConn.Open() cmdInsert2.ExecuteNonQuery() loConn.Close() next
When I execute this an error message comes
Server Error in '/examen' Application.
Input string was not in a correct format.
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.FormatException: Input string was not in a correct format.
Source Error:
Line 78: cmdInsert2.Parameters("@Mangd").Value = Request(cobjDR("Quantity"))Line 79: loConn.Open()Line 80: cmdInsert2.ExecuteNonQuery()Line 81: loConn.Close()Line 82: next
[FormatException: Input string was not in a correct format.] System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +723 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +194 ASP.TMP3thkwo1d0w_aspx.Page_Load(Object Sender, EventArgs E) in D:lofa.mine.nuexamenmembersTMP3thkwo1d0w.aspx:80 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Page.ProcessRequestMain() +731
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
I use same character types in storedProcedure what they are in the database and when I call the SP on my page the char types are same as they are in the SP