SQL 2012 :: Script That Will Allow To Create Multiple Logins In One Pass

Feb 24, 2015

I am new to SQL Server and I am trying to create a script / possible a cursor that will allow me to create multiple logins in one pass - without having to type each one.

I have 20 users USER1, USER2, USER3, USER4... but I can't seem to figure out how to get those users into a loop
so I can end up with something like this.

CREATE LOGIN <user> FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[English]......

I realize I can type this statement 20 times but perhaps there is a faster way -

View 3 Replies


ADVERTISEMENT

SQL Server 2012 :: Create Variable In Select Query And Use It In Where Clause To Pass The Parameter

Sep 9, 2014

I am writing a stored procedure and have a query where I create a variable from other table

Declare @Sem varchar (12) Null
@Decision varchar(1) Null
Select emplid,name, Semester
Decision1=(select * from tbldecision where reader=1)
Decision2=(select * from tbldecision where reader=2)
Where Semester=@Sem
And Decision1=@Decision

But I am getting error for Decision1 , Decision2. How can I do that.

View 6 Replies View Related

Integration Services :: Pass Multiple Parameter Values To SSIS Package In 2012 Through Stored Procedure?

Jul 9, 2015

we can  assign one parameter value for each excecution of  [SSISDB].[catalog].[set_object_parameter_value] by calling this catalog procedure..

Example: If I have 5 parameters in SSIS package ,to assign a value to those 5 parameters at run time should I call this [SSISDB].[catalog].[set_object_parameter_value] procedure 5 times ? or is there a way we can pass all the 5 parameters at 1 time .

1. Wondering if there is a way to pass multiple parameters in a single execution (for instance to pass XML string values ??)
2.What are the options to pass multiple parameter values to ssis package through stored procedure.?

View 4 Replies View Related

SQL 2012 :: Create View From Multiple Tables That Have 1 To M Relationship

Jul 31, 2014

I have two table studenTtable and courseTable which is each student take more than one course . 1:M...for example Student1 take 2 courses (C1 , C2). Student2 take 3 courses (C1,C2, C3).I need to create a table/View that contain student information from StudentTable plus all the courses and the score for each course from CoursTable in one row.

for example Row1= Student1_Id ,C1_code ,C1_name ,C1_Score ,C2_code,C2_name ,C2_Score Row2= Student2_Id,C1_code, C1_name,C1_Score,C2_code ,C2_name ,C2_Score , C3_code,C3_name,C3_Score

and since Student one just have two courses , I should enter NULL in 'Course 3 fields'.My Struggle is in the insert statement I tried the following but it show an error

Insert Into Newtable ( St_ID, C1_code,c1_name, C1_Score ,C2_code ,C2_name,C2_score,C3_code ,C3_name,C3_score)
Select (Select St_ID from StudentTable) , (Select C_code,c_name,c_Score from Coursetable,SudentTable where course.Stid =Studet.stid) , (Select C_code,c_name,c_Score from course ,student where course.Stid =Studet.stid ), (Select C_code,c_name,c_Score from course ,student where course.Stid =Studet.stid );

I'm fully aware that the New table/View will break the rules of normalization ,but I need it for specifc purpose.I tried also the PIVOT BY functionality but no luck with it .I also tried writing a code using Matlab (because it is high level sw that it is easy to learn for people not expret in programming as me) but didn't know how to combine the Student and Courses Matrices in my loop.

View 5 Replies View Related

SQL Server 2012 :: Create View With Exploding Rows Into Multiple

Apr 28, 2014

I have a table like below:

ItemIdAmountTax1Tax2SrvType
111 100 10 20 1
112 200 10 2
113 300 10 30 3

Now I want to create View that will have an exploded resultset based on SrvType.

For SrvType 1 and 2 there will be 2 lines per Itemid - One for 'Amount' anod another for 'Tax1+Tax2'. But for SrvType 3 there will be 3 lines per 'ItemId' - one for 'Amount', one for Tax1 and another for 'Tax2'.

I have a few hundred source records like this. Now sure how to achieve the exploded resultset with a View.

View 4 Replies View Related

SQL 2012 :: Create SSRS Report Based On Multiple Locations

Oct 23, 2015

I am looking to create an SSRS report based on multiple locations. There will be one report that presents a summary of all reports, and then individual report for each location.Instead of creating 2 separate reports, is it possible in SSRS to display different datasets based on the parameter selected?

View 3 Replies View Related

Analysis :: How To Create Parallel Period For Multiple Measures In SSAS 2012

Mar 27, 2012

I am trying to create a calculated member for parallel period function using ssas 2012. I have 10 measures for which i need to create parallelperiod. 

I can successfully create for 1 measure but when i add multiple values to it it breaks. Below is the sample i tried for multiple measures:

sum(ParallelPeriod([Date].[Calendar].[year],1,[Date].[Calendar].currentmember) ,
([Measures].[Revenue],[Measures].[Expenses]))

View 10 Replies View Related

SQL Server 2012 :: Create XML File From AS400 Stored Procedure Returning Multiple Datasets

Oct 3, 2014

I have a store procedure in MC400 which I can call from SSMS using the below command:

EXEC ('CALL GETENROLLMENT() ')At serverName

Now this command returns two data sets like:

HA HB HC HD HE
1112
112571ABC14
113574ABC16
114577ABC87
DADBDCDD
1115566VG02
1115566VG02
1115566VG02

I want to generate two different XML files from these two datasets.Is there any way this can be achieved in SSIS or t-sql ?

View 3 Replies View Related

Multiple Logins

Nov 24, 1998

Can the same user be logged into the database multiple times? If so,
what effects will this have on the data? Will the user receive lots of
locking problems or anything? We're in the process of setting up one
of our training rooms with new computers. We want to keep everything
as simple as possible -- which would be 1 login for all 30 computers --
but we are unsure of the ramifications.

Thanks so much for your advice!
Toni Eibner

View 2 Replies View Related

Lost SQL Logins, But Still Have DB Logins - Script To Recreate SQL Logins?

Jan 21, 2007

ok, first, I know... I forgot to run a backup of the master database, and I forgot to run a script to caputure logins. Not that that is out of the way... I need to recreate the logins under the Securities tab below the databases. All the company databases have the user names and passwords assigned to them, but they are not able to login, because they are not able to authenticate to the SQL server first.

Is there a script that someone has that will copy the company database security info for the users and recreate them in the SQL security tab?

I know that I can rebuild them manually, but I need to delete them first in the application software, then delete them from the databases, and then recreate them in the application software... and as simple as that sounds... it is a slow moving process.

Any assistance would be greatly appreciated.

Thanks,

John

View 3 Replies View Related

Multiple Database Logins

Jun 17, 2008

Hello EveryoneI am in the process of creating a web application that will allow me to have one place to go to see all of my SQL Databases. I would like to have one of the pages that showed the current status, or maybe next to the name of the server, have the status listed.I know how to create a database connection string using the web.config But I will need to have a query that loops thru a list of database server names, and each of them returning the status. Being able to connect, query the status of the server, show the status of each database. My database connection string will only log into one database. How can I code this to be able to loop thru the list of stored database server names, and then be able to log into each database server?Can I use a separate class with a method, and pass in the name of the server? That means that I would have to have the same user name on all the database servers, wouldn't I ?I am looking for a way to accomplish this. I am open to suggestions. I am coding my web app using C#. ThanksAndrew SQLDBA 

View 2 Replies View Related

Deleting Multiple SQL Logins

Feb 12, 2003

I need to delete multiple sql logins on one of my database servers that are no longer needed. Most of these logins are not attached to any database on the server because the database has been deleted from this server. Is there any way to delete logins that are no longer needed without having to review every login to verify it is not attached to a database before deleting?

View 2 Replies View Related

SQL Server 2012 :: Create New Table From Multiple Table?

Feb 19, 2015

I need to create a table from these 2 tables and want all the data. Table 1 has 15000 records and table has around 1000 records.

I have 2 tables.

SELECT [UniqueID]
,[Company]
,[CustID]
,[CustomerName]
,[FiscYr]

[Code] ....

View 5 Replies View Related

Permissions To See Server Logins/Create Database Users

Feb 2, 2007

Our company has 2 Database Roles (DBE and DBA). The DBE creates
database schema, performs SQL Server Administration, and manages server
security. The DBA writes data access, ETL, and manages database
security. In 2005, we're struggling with how to allow the DBA to see
all of the logins on the server in order to add them as users of their
database. What permissions does the DBA need to select from any of the
logins on the server to add them to their database?



Michelle

View 1 Replies View Related

Does Security Admin Have Access To Create Logins Using Sp_addlogin

May 31, 2007

i have an asp.net web application that uses SQL2000 backend. any users login to the application using a proper SQL login. so each user has unique logins

One of the roles within the application is to allow the user to create new logins for the application which inturn creates a SQL login. for this i have been using the following special sp's within an application specific sp:-

EXEC sp_addlogin @strUsername, null, 'WEA_MIS', @loginlang
EXEC sp_grantdbaccess @strUsername, @strUsername
EXEC sp_addrolemember @strRole, @strUsername
EXEC sp_password NULL, @strPassword, @strUsername




the only way ican get this to run is if the user executing the sp is a member of sys admin, ideally i dont want to be giving anyone access to sys admin. i thought security admin would allow me to do the above but it doesnt. Is there any other ways or ideas to get around this problem

Cheers,
Craig

View 5 Replies View Related

SQL 2012 :: Restore With Replace - Logins Get Their Own Schema

May 29, 2014

I refresh QA environments with copies of our production database quite often. Many of the users also have read-only logins to production, but not all. I've noticed that in QA the users in the restored database are matched up with QA server logins that no longer have "DBO" as their default schema. We almost always use DBO, nothing else.

On the most recent restore, I didn't drop the target DB first, just restored with "replace." Does it matter whether I drop or replace in this instance?

The one user reporting issues could not open the database in management studio to view objects/tables etc. I noticed their default schema was their domain login, so fixed that and they now no longer have the issue.

View 0 Replies View Related

SQL 2012 :: Track All Logins Onto A Single Database?

Oct 17, 2014

We have a particular database sat on SQL Server 2012 box along with about 20 other databases.

What I require is a method/Script/Audit that will simply track anyone who logs (successfully / unsuccessful) into this one particular database on the server (The single database is the key as the end user does not want information on any of the other databases that sit on the server), it also has to log time the attempt was made and it must track the logins via SQL Server or the application itself that is attached to the database.

View 1 Replies View Related

SQL 2012 :: Code That Audits All Logins To Production

Jul 2, 2015

So I'm using the 2012 SSMS to connect to a SQL 2008 database, upon which we have code that audits all SQL logins to production and notifies us via email that someone is using logins they shouldn't. Mostly it's to notify us if people other than the DBAs are using these logins from their desktops instead of using their windows accounts.

This morning I opened up SSMS 2012, logged into my production servers in Object Explorer using Windows Auth. An hour later, I had to update an exception table, so I opened a new query with SQL Auth and used a SQL-only login it. Immediately the email pops that someone on my desktop is using a SQL Login. That's okay. That's expected.

What I didn't expect is that after I closed the query window, the email kept popping. The query window isn't even open / connected to production any more, but SQL still thinks I'm logged in using a SQL Login instead of with Windows Authentication (which is what I used on the Object Explorer connection).

Is there a bug with 2012 that causes a new connection type to affect all current connections? I.E., did it change my DB Windows Auth connection to SQL Auth on the other connection?

View 0 Replies View Related

SQL 2012 :: How To Reconcile Logins Between Two Server Instances

Oct 16, 2015

I am in the process of writing a generic PowerShell script (that executes T-SQL statements) to copy all or some databases from one SQL Server 2012 SP2 instance to a second instance that runs SQL Server 2012 SP2 or higher. The script is designed to be used on demand, and part of its execution will involve reconciling the logins between the source and destination instances.

I am looking for a reliable way to reconcile the logins between the instances in a somewhat repetitive (i.e., "on demand") fashion. There is no SSIS in the environment; so the SSIS transfer logins task to not available to me.

View 5 Replies View Related

SQL 2012 :: Migrate Logins From A Copy Of Master Database

Jun 18, 2015

I am working on a Login migration issue. I have the Master database from the original database, that I have attached as a User Database, call it OriginalMaster. I also renamed the mdf and ldf files, before attaching, just in case.

I want to select the logins from the OriginalMaster, and using sp_help_revlogin script all the Logins out. I know there were many logins in that database. But what I am seeing, are all the Logins from the Current Master database. Which are only 7 Logins.

How can I select the logins, or script out the Logins from the OriginalMaster database?

View 1 Replies View Related

SQL 2012 :: Disable Logins Automatically Depending Upon Expiry Date In A Table?

Jun 4, 2014

Disable logins on access expiry date(Not windows password expiry). we grant access to users on databases only for 60 days. So access is only valid for 60 days. Then the user should again request access to the database going thru security clearance. Thn the DBA's enable the login. Maintaining all these logins of users manually is causing more confusion.
As we know, we dont have any inbuilt functionality to automatically disable logins in SQL Server.

I have a table where the logins and expirydate were recorded in a DB.

Using this table and SQL Server agent. Can i achieve this process automated ?
CREATE TABLE [dbo].[LoginsExpiry](
[LoginName] [varchar](50) NULL,
[ExpiryDate] [date] NULL,
[Roles] [varchar](500)
) ON [PRIMARY]
GO

View 3 Replies View Related

SQL 2012 :: Ability To View Server Level Logins And Agent Jobs?

Sep 16, 2014

In one of my environments, I need to grant the ability to view all the logins and agent jobs to an account, but I don't want to give him "sysadmin" or "securityadmin".

View 2 Replies View Related

How To Pass Multiple Parameters In SSRS

Apr 25, 2008


Hi,

I am working on SSRS. I need to open a new report from one report when user clicks on some particular summerized count link.

Its a sort of drilled down report. I am not getting how to pass the respected Ids (more than one) to the next report when user clicks on the link in the 1st report. These ids I want to use as a parameter (multiple) in the 2nd report to dump the rows from the database.

Please help.

Regards,
Sachin

View 4 Replies View Related

SQL 2012 :: Grant Read-only Access To Windows Logins On Remote Standby Database

Mar 23, 2015

We log ship our production database tansaction logs to a secondary database on a separate remote domain.

Incidentally, this was not set up via the "Ship Transaction Logs" wizard, but instead we had to use the various system stored procedures after restoring a copy of the database on the remote domain in standby mode.

We now have an issue where users are unable to access the remote secondary database without having sysadmin privileges. Clearly we want to avoid this!

We want to be able to use Windows Authentication mode on the server of the secondary database. But since the two domains differ, is it possible to even achieve this?

How can we set up read-only access for users on the secondary database without giving them sysadmin privileges?

View 3 Replies View Related

SQL Server 2012 :: Pass Parameter Value To CTE

Jul 29, 2015

In some t-sql 2012 that I am using, I am using the following on 5 separate merge statements.

USING
(select LKC.comboID,LKC.lockID,LKC.seq,A.lockCombo2,A.schoolnumber,LKR.lockerId
from
[LockerPopulation] A
JOIN TST.dbo.School SCH ON A.schoolnumber = SCH.type
JOIN TST.dbo.Locker LKR ON SCH.schoolID = LKR.schoolID AND A.lockerNumber =
LKR.number
JOIN TST.dbo.Lock LK ON LKR.lockID = LK.lockID
JOIN TST.dbo.LockCombination LKC ON LK.lockID = LKC.lockID
and LKC.seq = 1
) AS LKC2 (comboID,lockID,seq,combo)

What is different, is the value of LKC.seq = 1 as listed below. I am using 5 separate ctes

and the only value that changes is the LKC.seq number being a value between 1 and 5. Thus

can you pass a parameter value to the CTE that I just listed above? If so, would you show me

the t-sql to accomplish this goal?

View 2 Replies View Related

Pass Multiple Parameters To Stored Procedure

Mar 26, 2008

Hi,
I want to create a stored procedure which I can pass multi parameters. This is what I need, I have a gridview which is used for displaying customer info of each agent. However, the number of customers for each agent is different. I will pass customer names as parameters for my stored procedure. Here is a sample,
CREATE PROCEDURE [dbo].[display_customer]
@agentID varchar(20), 
@customer1 varchar(20),
@customer2 varchar(20),
.....            -- Here I do know how many customers for each agent
AS
SELECT  name, city, state, zip
FROM rep_customer
WHERE agent = @agentID and (name = @customer1 or name = @customer2)
Since I can not decide the number of customers for each agent, my question is, can I dynamically pass number of parameters to my above stored procedure?
Thanks a lot!
 

View 6 Replies View Related

How To Pass Multiple Parameters Across Reports In SSRS

Apr 25, 2008



Hi,



I am working on SSRS. I need to open a new report from one report when user clicks on some

particular summarized count link.


It is a sort of drilled down report. I am not getting how to pass the respective Ids (more

than one) to the next report when user clicks on the summarized link in the 1st report.

These ids I want to use as a parameter (multiple) in the 2nd report to dump the rows from

the database.

View 3 Replies View Related

Sub: How To Pass Multiple Parameters Across Reports In SSRS

Apr 25, 2008

Hi,


I am working on SSRS. I need to open a new report from one report when user clicks on some

particular summarized count link.



It is a sort of drilled down report. I am not getting how to pass the respective Ids (more

than one) to the next report when user clicks on the summarized link in the 1st report.

These ids I want to use as a parameter (multiple) in the 2nd report to dump the rows from

the database.

View 1 Replies View Related

How To Pass Multiple Values To A Parameter While Cascading

Oct 9, 2006

Hi,

I am using RS2005. i have a requirement in which i need to pass more than 1 value to a parameter. this parameter is used in a dataset for filtering.

Eg: if i have a parameter as @years, i want to assign values 2005, 2006 to it and use it in the dataset to filter like select.... where year in (@years).

How can i achieve this?

Thanks

Vivek S

View 13 Replies View Related

How To Pass Multiple Value From A Single Parameter In Sql Report

Jan 25, 2008



In my form i have a list box and i need to display paticular records of all employees I selected.So please tell me how to pass multiple values from a single parameter.

currently i am able to pass single value through a parameter using following code




osqlreport.reportViewer1.ServerReport.ReportServerUrl = new Uri("http://localhost/reportserver");

osqlreport.reportViewer1.ServerReport.ReportPath = "/employee/5_0emplyeedata";



List<Microsoft.Reporting.WinForms.ReportParameter> paramList = new List<Microsoft.Reporting.WinForms.ReportParameter>();



string stritem;





stritem = Convert.ToString(this.lstSelectedData.Items[0]);

paramList.Add(new Microsoft.Reporting.WinForms.ReportParameter("paraempno", stritem, false));



osqlreport.reportViewer1.ServerReport.SetParameters(paramList);

osqlreport.reportViewer1.RefreshReport();

osqlreport.Show();


what changes do i need to do to make it work.(lstSelectedData is my list box)

View 3 Replies View Related

SQL Server 2012 :: By Pass Error While Insertion

Jan 29, 2014

I have a scenario in which if I do bulk insertion in a table and if any error occurs then insertion should not stopped and will proceed with insertion of remaining records.

View 2 Replies View Related

SQL Server 2012 :: Pass In Null Values

Sep 20, 2014

The following t-sql 2012 works fine in sql management studio. However when I place it in a .net 2010 web form application, I am told the sql does not work when the parameter values are null. Thus can you tell me what I can change in the sql below that will accept null as 3 possible input values?

SELECT i.[lastName]
,i.[firstName]
,i.[middleName]
,i.[suffix]
,a.[userid]

[code]...

View 1 Replies View Related

SQL 2012 :: Can Default To 0 When Pass NULL Explicitly

Sep 23, 2014

I have a Nullable columns. I want the value to be zero if NULL is passed.

1) having a view for every such table,
2) using ISNULL for needed columns in that view
3) using those view for inserts instead of using tables directly.

This way i can reduce the number of places to use ISNULL in all my SPs.I dont want to make it to NOT NULL, as my application impact will be high. And Default constraint does not work here.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved