Does anyone know how to get the original Login name, while a context switch is in effect.. For example during the use of Original login to SQL is Wayne
Then Execute as Test
Now I need to know that Wayne is the Login and not Test
none of the standard things work, they all use the current context (suser_sname, etc)... Books online includes the following text
SYSTEM_USER returns the name of the currently executing context. If the EXECUTE AS statement has been used to switch context, SYSTEM_USER will return the name of the impersonated context. Use the LOGIN() function to return the name of the original login during impersonation.
But I cannot find any function called LOGIN() anywhere?
There are some concept about context switch block me .
---executor: dbo create user u1 without login
go
create table t
(
col int
)
go
create proc proc1
with execute as 'u1' as
insert into t values(1)
go
exec proc1
I think proc1 can't be run successfully beacuse the executor of proc1 is u1 and I didn't grant any permission to user u1. So it will return a error message like The INSERT permission was denied on the object 't', database 'tempdb', schema 'dbo'
To my surprise, the "exec p1" command could run successfully..
I have 2 databases one for datawarehouse and one for reporting.
I created a view in the reporting database joining several tables from datawahourse. The view is meant for a users who uses powerpivot. It will contain a few million of rows.
I set up a role in the reporting database. I assigned select rights to that role on the view.
When the user wants to access the view, he can see the view but a select gives
The server principal "pp_user" is not able to access the database "datawarehouse" under the current security context.
How can I fix this ? I don't want to give the user select rights on tables in the datawarehouse.
I have setup a SQL 2014 server with mixed authentication. Below is sequence.
1. Created a server. Added server to a domain & logged out.
2. RDP to the server using a local account. Installed SQL 2014. Kept the services to run using default NT Authority accounts during initial setup. SQL was installed in mixed mode (SQL & windows authentication). a specific 'sa' pwd was set.
3. After initial setup, I changed all SQL services Logon account to be respective domain accounts. Made sure all services restarted, up & running.
Now, for the same 'sa' SQL login account -
--> if I RDP to the server using local system admin & connect to SQL studio with 'sa' (SQL authentication) - it works. but --> if I RDP to the server using my domain account (which is already an admin on SQL & windows), but connect SQL studio with the Same 'sa' (SQL authentication) - it fails & gives - unable to login 'sa'... ; standard error code : 18456.
Question : How can be the same 'sa' login, is acting different based on with what user context I RDP to the server ?
We are looking at developing an SQL Server 2005 Database and I would like to use Windows Authentication rather than SQL Server Authentication to connect our client app.
In our development environment, we have two Servers, one being used as a file server and the other as an SQL Server. We have now set up a domain using the file server as the domain controller. (We had previously been set up to use a workgroup).
I have set up an active directory group called SqlDevelopers and added an active directory user called Jonathan to it.
On the SQL Sever, in management studio, I have set up a new server login which uses windows authentication called DomainSqlDevelopers. I used the GUI to verify I could see the domain and the group.
The default database is set to a test database on the server. A user in the test database is mapped to the DomainSqlDevelopers and given the Roles dbo, db_datareader, db_datawriter.
To test the log in, on the server, I logged out as administrator and in as Jonathan. I could successfully access the server through management studio using windows authentication.
However, if I log in as Jonathan on my client PC and try to access the SQL Server using management studio and windows authentication, I have problems.
The first time I try I will get a timeout error. If I try again will get either:
Login failed for user ''. The user is not associated with a trusted SQL Server connection
Or
Cannot generate SSPI context
I can€™t determine any pattern to which of the above errors I get.
However, if I log in as administrator on my client PC, I can connect to the server using management studio and windows authentication.
Sounds like Active Directory/Domain or other Network issue (Not really my area). I would be grateful for any help.
Hi, Im getting this error when attempting to retrieve data from an sql database.
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 requested in login 'projectAllocations'. Login fails. Login failed for user 'sa'.
Source Error:
Line 13: objConn = New SqlConnection( "Server=LAB303-066NETSDK; Database=projectAllocations; User ID=sa;Password=mypassword") Line 14: objCmd = New SqlCommand("SELECT * FROM project_descriptions", objConn) Line 15: objConn.Open() Line 16: objRdr = objCmd.ExecuteReader() Line 17: While objRdr.Read()
Been looking through the forums for a solution to this problem.I already tried granting access through statements such as:exec sp_grantloginaccess N1'machineNameASPNET'But they don't seem to work.. i vaguely remember seeing somewhere a DOS command line statement that grants access to the ASPNET_WP and that fixed my problem before on another computer.. but this is a new computer and i forgot to write down the command.Can anyone help explain and propose a solution to my problem. Many thanxs.
I am using the MSDE to connect to my ASP.NET application. I get this error after clicking the login button of my login page. Anyone know why this would happen?
Thanks for any help,
Cannot open database requested in login 'DataSQL'. Login fails. Login failed for user 'serverASPNET'.
Hi All Server 2003 standard edition, MSsql 2005 standard edition As I understand it server 2003 standard only supports 4gb. Does this mean I can only use up to 4gb as the maximum memory for server 2005? If that is the case I would like to use the 3GB switch, and leave the other gig for other apps. If I set the 3GB switch in boot.ini do I then also have to enable AWE (which I can't seem to do) or can I forget about AWE altogether?
from the December 2004 _Redmond Magazine_, "Finding Gold in Yukon":http://redmondmag.com/columns/artic...ditorialsID=838"Developers will also pick up the usual new-version enhancements to T-SQL,including error handling, recursive queries, a ROW_NUMBER function, a PIVOTrelational operator and more."ROW_NUMBER???? What possible purpose could that have???
I got an issue with encrypt and decrypt. I encrypted a data, say 'ok', then I decrypt the encrypted data, but what I got is not 'ok'. but if I encrypt a column, then after decryption, those data asr same with the original data in that column.
Hi,Is it possible to switch to another user's credentials after logging in? Iseem to remember that there is a stored procedure for this, but I can't finddetails anywhere. I want to temporarily suspend my login's admin privilegesand become an "ordinary" user, for testing purposes.Thanks,Peter
I am trying my first sliding partition scheme with 2005, and I am getting the following error...
ALTER TABLE SWITCH statement failed. Check constraints or partition function of source table "ScanStoreAggregateLoad' allows values that are not allowed by check constraints or partition function on target table "ScanStoreAggregateTest'.
I have gone over the functions and constraints a gazillion times. The columns are set to Not Null. The constraints are set to AND NOT NULL. The constraint values align and align with the function. But still I get the failure. Any help would be greatly appreciated. Here are the definitions:
CREATE PARTITION FUNCTION pfn_ScanStoreAggregate(int)
AS
RANGE LEFT FOR VALUES
(19224,
19225,
19226,
19227)
CREATE TABLE dbo.ScanStoreAggregateTest(
ProductID int NOT NULL,
DateKey int NOT NULL CONSTRAINT ck_ScanStoreAggregateRange CHECK ((DateKey BETWEEN 19224 AND 19227) AND (DateKey IS NOT NULL)),
hi out there On our Windows 2003 servers w. sp1 and running MS SQL Server 2000 w. sp4 we see from time to time that we get this error "cannot allocate 64k continous memory" or "SQL Server could not spawn process_loginread thread" which could be caused by nothing left in the "Memtoleave" pool - I have now search for advice on how to determine the values for the -g-switch - but without much success - and if I just go for the "try&error" concept my sql-server just allocates less and less ??? - ehh - in which units are the parameters for the -g option specified - bytes, kilobytes, mbytes - 4k block ???? Any suggestions for measuring the actual running value of this pool - memtoleave ??
So here's what I'm trying to do: I have three columns of data. Sometimes only one of the columns will contain a value while others may contain a null. If two or three contain a value it will be the same. So if I'm building a table in the layout designed and I want the value of the table to be the value stored in these columns. In pseudocode it looks like this:
Switch(column1 and column2 are null, value = column3, if column1 and column3 are null, value = column2, otherwise, value = column1)
Something like that where column1 is the default so if column 1 has a value then set the textbox value to it otherwise find a column that has it. I know that at least one column will definitely have a value. Anyone that can provide guidance on how to execute these I would appreciate it greatly.
When using @original_{0}, how does this work if you are using a stored procedure instead of inline SQL? For example, if my update parameters are like this : <UpdateParameters> <asp:Parameter Type="String" Name="ProductType" /> <asp:Parameter Type="String" Name="OpportunityType" /> <asp:Parameter Type="Double" Name="Value" /> <asp:Parameter Type="String" Name="Probability" /> <asp:Parameter Type="Int32" Name="OpportunityID" /> </UpdateParameters>
And my stored procedure like this : CREATE procedure dbo.UpdateOpportunity ( @ProductType int, @OpportunityType int, @Value money, @Probability int, @OpportunityID int) as update Opportunity set ProductType = @ProductType, OpportunityType = @OpportunityType,[Value] = @Value, Probability = @Probabilitywhere OpportunityID = @OpportunityID Do I need to change both cases of @OpportunityID in my stored procedure to @original_OpportunityID for it to work?
I managed to get fuzzy grouping working. The relevant output (_key_in and _key_out) are stored in a new table that is a copy of the old table + fuzzy grouping columns.
How do i get SSIS to store the _key_in and _key_out in the original table? The new matching column _key_out refers to the new key: _key_in. How could i get SSIS translate that to a matching column that refers to my original key?
Starting to play around with SQL server at work and this is my question:
In the query design mode in access I can make one of the fields an expression that is driven by a built-in switch function. i.e. Switch([CategoryName] Like "Beverage","Drink",[CategoryName] Like "Cheese","Dairy") This results in the additional column field I created to display "Drink" for each record that has the CategoryName = "Beverage", and "Dairy" for "Cheese".
Can I do something like this in SQL server in the view designer itself, or do I need to make a user defined function and call it?
Any One Tell me how i can use N'Switch in SQL Server Stored Procedure . When I use Such a this syntax i am encountered and stoped with a error. the is below(Stoerd Prdocedure Code) ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- CREATE proc sp_check_userpass(@username nvarchar(50),@password nvarchar(50),@first nvarchar(50),@last nvarchar(50),@email nvarchar(50),@stage int )as declare @cnt int begin select @cnt=count(*) from member_info where (@username=username and @password=password) if(@cnt=0) begin insert into atable(first,last,username,password,stage) values(@first,@last,@username,@password,@stage) end else return @cnt end GO ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- Other thing is that when exec this store proc it must be return a value return back to the @cnt but it is return only This( The command(s) Completed succefully). Any One guide me how i can must be do . i must clear it that i am using this query in ASP.NET SqlClient Object To Execute Query. Thanx In Advance. ArQa
Hello everyone, thanks in advance for reading. I'm new to reports and have tried searching for my answer with no luck. Any direction would be great.
Here is the issue, I have 3 colums in the dataset which display String data ("High", "Medium", or "Low")
I've added a column to the table on the report where I would like to convert the value of "High", "Medium" and "Low" to 3,2,1 respectively then SUM these numbers.
Is this possible? I've tried several variations of the code below--maybe it's not possible to do what I want? Thanks again for your time and help.
Fields!PP.Value is set to: =Switch(Fields!Avail_Rank.Value = "High", 3, Fields!Avail_Rank.Value = "Medium", 2, Fields!Avail_Rank.Value = "Low", 1)
I have two SQL servers. One licensed for 2000 Standard Edition licensed under the processor model. The other is SQL 2000 Enterprise Edition licensed under the user cal model.
I want to switch these Editions and licensing models. My production server needs the Enterprise Edition and I want to put the processor licensing model with it. I want to put the Standard Edition on my reporting server with the user cal licensing model.
I have the instructions to upgraded Editions and it is straight forward. Can I use this procedure for both servers and not have issues?
I have a tempdb that was created at 1Gig. I don't know why but I want to shrink it below the original creation size. Is there a way to shrink this file or create a new file and delete the old?
I have tried shinkfile and shrink database with no luck.
I restored a backup of a database running SQL Server in W2K to my own laptop (Windows XP) for report testing pourposes. The restore worked perfectly, but when I ran the store procedure that returns my "report" set I noticed that several of the fields within the result set are different, the number of rows and customers are a perfect match to the production report. The fields that are different are calculated fields that invoque a user defined function, which again are exactly the same on both databases. I tried dropping the stored procedure and the 4 functions and recreating them again but I get the same results, the number of rows, the customers and all "non" function calculated fields are perfect, only the fields calculated with the functions are wrong.
I am trying to use SQL Express to support unit testing of functionality which requires database access.
I created an express database (.mdf) which contains a database snapshot which is the database environment that each test expects to see when it starts. Through the execution of the test the database will be modified arbitrarily and I need to reset the database to the original state before the next test executes.
Here's what I do today:
Before Test:
The original database is copied to a unique location in the temp directory A unique database name is generated (GUID-based) I connect to the new database file with:
When I do this, everything seems to work correctly but when I re-open the original database it has changed unexpectedly and includes the modifications that were made by the test as it ran.
Can anyone explain why this is happening and/or provide a solution?