SQL 2012 :: How To Execute One Query From SP Based On User Selection

Dec 22, 2014

I have a SSRS report with 6 columns each column containing count of total# of applicants meeting certain criteria.
User want to click on each column and see the basic information and also want to get the ability to export the data into excel.

I know that I can create 6 drillthrough reports with basic information of applicants and link it to the count from each column respectively but I was wondering if it is possible to write a Stored procedure with all 6 select queries and execute only 1 select query based on the column that user clicks on main report ?

View 0 Replies


ADVERTISEMENT

SQL 2012 :: Login / User Cannot Execute Or See Stored Procedures

May 6, 2014

We are using a third party tool that does not store passwords in an encrypted format therefore we created a user with minimal rights. Isn't there a way to grant "execute any stored procedure" to a user/Login? Do we really have to grant execute on each procedure to the user? And then do the same for each new store procedure? The only other option we have found to be able to "see" and execute the stored procedures is by granting "db_owner". I would think that would negate the user being minimal rights.

View 5 Replies View Related

How To Execute Update Query Based On Duration

May 21, 2008

Hi All,
I have a table which consists the leave details of an employee.
I have the columns like paid leaves,sick leaves,personal leaves in the above table
Problem :
For eg: An employee joined on 21 May 2008. After 6 months i.e., 21 Nov 2008 I need to update the above columns (i e., increase the no.of leaves)
So updation is to be done for every 6 months and for every 1 year.
Can anyone say me how to execute the update query based on the duration.
Thanks in advance.
 
Regards,
Praveen

View 4 Replies View Related

SQL 2012 :: Allow Low Privilege User To Execute Stored Procedure To Create DB Users

Jul 22, 2014

I have a requirement to allow a user to restore a database and then create database users and add them to the db_owner database role. The user must not have sysadmin rights on the server.

The database restore works ok by placing the user in the dbcreator role.

There is a stored procedure to create the database user and alter role membership, I want the user to execute the sp as a different, higher privilege account so as not to give the user underlying permission to create users in the database.

USE [master]
GO

/****** Object: StoredProcedure [dbo].[sp_create_db_users] Script Date: 22/07/2014 13:54:46 ******/
SET ANSI_NULLS ON
GO

[Code] ....

The user has execute permission on the stored procedure but keeps getting the error:

Msg 916, Level 14, State 1, Line 2

The server principal "Mydomainadmin1" is not able to access the database "Mydatabase" under the current security context.

Mydomainadmin1 has dbowner to Mydatabase and sysadmin rights for server. If the 'execute as' is changed to 'caller' and run by mydomainadmin1 it works so the issue is between the execute sp and the actual running of the procedure.

View 1 Replies View Related

SQL Server 2012 :: Query To Find User Who Last Modified User Roles / Access?

Dec 6, 2013

I would like to know if there is a way to find out who changed a users roles/access WITHOUT using the audit function. For example, if a user account was created and given SA access then changed to read only, how can I find out who made that change? I tried searching for an answer, but kept getting no results. I'm thinking this may tie into the sys.sysusers view?

View 3 Replies View Related

SQL 2012 :: Produce Report To Calculate No Of Days Based On User Input Start And End Date

Jan 5, 2015

I have to produce a report to calculate no of days based on user input start date and end date.

say for eg: in the tables I have emp name
user 'Phani' started work from - EStart 20/11/2014EEnd 10/01/2015 - total days --datediff
within his work period he did different roles:

PhaniMarketing (prSt Date) 20/11/2014prE date (28/11/2014) Total 9 days
PhaniAdmin (prSt Date) 29/11/2014prE date (20/12/2014) Total 22 days
PhaniCRM (prSt Date) 20/12/2014prE date (10/01/2015) Total 22 days
Total days 53 Days
for this :

[code]...

HOW CAN I USE Case statement to calculate days for given start date and end date. I have to include all three totals, 1 for Job dates, 2, subjobs dates, 3 cal of days for a requested period.

View 0 Replies View Related

Best Way To Set User Vars Based On Query

Mar 1, 2008

what's the best way to set user vars in ssis from a query. I have some components that set a from and to date in a table. I'd like to select those values right into some user vars in the pkg.

View 1 Replies View Related

Query Building Based On User Selections

Sep 22, 2006

I currently have a form that has different options in a list box such as:Status Codes

View 3 Replies View Related

Drill Down Based On Parent Selection

Mar 28, 2007

I have a report grouped by username, provider_name and it drills down on the username, and then on the provider name to display the detail data.

My report looks like this:



-Username1

+Provider1

+Provider2

-Username2

+Provider1

+Provider2



I would like to only display provider1 when I drill down on Username1 and only provider2 when I drill down on Username2.



-Username1

+Provider1

-Username2

+Provider2





Thanks!

View 11 Replies View Related

Change SqlCommand Based On Combo Box Selection

Dec 14, 2007

I have a textbox, combo box, and a button on a form.  I would like to perform a different query depending on the combo box selection.  I thought I could do something such as: if (cboSearch.Text == "Selection1")
{
scCmd = "SELECT * FROM tblTable WHERE txtSearch = @Selection1";
}
else if (cboSearch.Text == "Selection2")
{
scCmd = "SELECT * FROM tblTable WHERE txtSearch = @Selection2";
}
else
{
scCmd = "SELECT * FROM tblTable WHERE txtSearch = @Selection3";
} However, this obviously does not operate as I would need it to.  What is the proper method for conditional SqlCommand statements like this?

View 1 Replies View Related

Filtering Parameters Based On A Selection Of Another Parameter

Dec 28, 2007



Hi,

Im trying to create a drop down parameter whereby if i select a certain field, a different dropdown will be filtered off only the relevant selections, is this possible.

View 7 Replies View Related

SQL Server 2012 :: Indexes Based On A Query?

Aug 18, 2014

trying to create indexes on two tables:

SF_Affiliate_Customer
SF_Affiliate_Customer_Account

on which the following query is based. I need to build indexes so that the query will perform better. Now its very slow..

SELECT DISTINCT C.[afflt_cust_natl_key],[as_of_dt]
FROM [dbo].[SF_Affiliate_Customer] C
WHERE
( [afflt_intrnl_cust_ind] = 'N'
AND [afflt_empl_ind] = 'N'
AND (ISNULL([phys_addr_st_rgn_cd],'')<>'CA' AND ISNULL([mlng_addr_st_rgn_cd],'')<>'CA')
)AND

[code].....

View 3 Replies View Related

How To Populate Parameter2 Based On Parameter1 Selection On Report

Jan 8, 2007

I have two parameters on report both will be populated in dropdownlist boxes.

How can i trigger parameter2 based on parameter1 selection.

but when i fill parameter2 i also need to pass the selected value of parameter1's data.

Please i have done this on aspx form using vb.net but don't know here how to do that. haave difficulty in making a search on google, confused to form right words to search.

Thank you all very much, fot the information.

View 3 Replies View Related

Hide/Show Table Based On Parameter Selection!!!???

Apr 28, 2008

I'd like to hide/show a table based on selected parameters. In the current setup I have a matrix and two tables underneath that need to be displayed from time to time. First of I use a multi-value parameter called "Lieferart". Depending on the parameter I have set the visibility of the two tables with the following expression:


=iif(Parameters!lieferart.Value(0) like "Nagel%", False, True)

This expression doesn't work though, any ideas??? I am also unsure about what I have to do If multiple values from the parameter list are selected as Parameters!lieferart.value(0) doesn't necessarily need to have a label like "Nagel" included...

View 3 Replies View Related

Can A Variable Prompt Be Changed Based On A Language Selection?

Nov 16, 2007

there doesnt seem to be an object id associated with variable prompt phrases. Does this mean they cannot be localized based on language choice?

View 1 Replies View Related

SQL Server 2012 :: Increment Query Based On Two Tables?

Feb 17, 2014

I have two tables with this info:

TABLE 1

COL1 COL2 COL3
AAA BBB CCC
QQQ WWW EEE
AAA SSS DDD
WWW EEE RRR
BBB BBB BBB

TABLE 2

COL1 COL2 COL3 COL4
b b b 343
a a a 344
c c c 345
d d d 346
e e e 347

I want to insert TABLE 1 into TABLE 2 with a query that will auto increment to COL4 looking like this:

COL1 COL2 COL3 COL4
b b b 343
a a a 344
c c c 345
d d d 346
e e e 347
AAA BBB CCC 348
QQQ WWW EEE 349
AAA SSS DDD 350
WWW EEE RRR 351
BBB BBB BBB 352

I know this can be done easily by just altering the column to have an auto-increment datatype, but I currently cannot do that at this moment.

View 5 Replies View Related

SQL Server 2012 :: Execute SP For Rows Returned From A Query

Nov 27, 2013

I have a query that returns a bunch of rows. I have an sp that takes 3 of the columns in the query as parameters that I want to execute for each row. I can do that easily enough with a cursor, but I thought I'd try to eliminate one more task where I fall back on using cursors.

View 5 Replies View Related

Set Up Permission Based On The Selection Made From The Drop-down (Parameter) List

Oct 4, 2007

I created a report with a school parameter for all our schools in SQL report. The school parameter gets it's value from a query. The report is generated based on the selection made by the user. If user choose school "A", report is generated for school "A" and if user choose school "B" report is generated for school "B".


I am using a centralized user id and password for all users. A report URL (report link) is sent to user to access the report.
Currently, from the school parameter (school drop-down list) users from any school may/can choose report for other schools other than theirs schoos. The content of the report is sensitive and we do not want anyone to see anyone else report.

I want to create a user based security, so based on the user id for school "A", he/she will only be able to see school "A" report but nothing else.


I was trying to accomplish this by creating linked report but it does not look realistic to create a folder for each school on the report server (which means about 180 or more folder for all our schools ). Does anyone else have better suggestions what can/should I do?

View 4 Replies View Related

SQL 2012 :: Query Based On Column Name / Setting Up Database Table

Oct 30, 2015

I have a set of data spread across a number of tables regarding stock market data. An example of this follows:

Market Capitalization...

Date CompA CompB
01/01/11 100 5
02/01/11 102 4

Share Price....

Date CompA CompB
01/01/11 100 100
02/01/11 101 99

Event Data...

Date Company
01/01/11 CompA
02/01/11 CompB

Pretty simply, I need a way to retrieve the market capitalisation and share price data based on the event data. So for instance I say 'oh, there is an event on the 01/01/11 involving company A, the market capitalisation on this day was 100, then for the next event it was 4 for company B.

I can also transpose the data so that the company name is in the rows and the dates in the columns for the market cap and share price tables, but this leads to the issue that when I try and get the data, I don't know how to query the correct company for that date.

For instance:
SELECT Event.Date, Event.Company
FROM Event

how do I now say.....

SELECT MarketCapitalisation.Column
WHERE Column = Event.Company
AND MarketCapitalisation.Date = Event.Date.

I have played around with a few basic joins, but I am having issue with the principle of that second to last line of SQL (so only getting the correct column).

I still have a copy of the data in excel so can flip things around as needed, but that would only mean that I would have the issue of WHERE Column = Event.Date instead of Event.Company.

View 1 Replies View Related

Depending On The Selection Of The User Of The Asp.net Web-form How Can I Do Changes In The Stored Procedure

May 11, 2007

Hi frdz,  I have created the following stored procedure in sql server 2005. In my database i have one option for the payment mode which can be done thru cash or credit(cheque).   I have created my web-application in asp.net with C# 2005. There i have a dropdownlist box for the user to select the option whether wants to do the payment thru cash or cheque.Depending on that selection if user selects cheque then all the reqt for cheque like it's no,dt,bankname etc...are visible.but if user selects the option as cash then the cheque details become invisible.Depending on the selection of the user of the asp.net web-form how can i do changes in the stored procedure...   i can write the condition likeif paymentmode=cash then ..........else.............but where and how can it be written ...pls tell methanxs in adv...u can go thru my below SP     ALTER PROCEDURE MiscellaneousStoredProcedure


@miscid int output,
@storename varchar(20),--store name to storeid
@accountname varchar(20),
@groupname varchar(20),
@paymentdt datetime,
@payeename varchar(30),
@paymode varchar(20),
@bankname varchar(50),
@chqdt datetime,
@chqno varchar(20),
@amt numeric(10, 2),
@bal numeric(10, 2),
@remarks varchar(50)

as

declare

@storeid int,
@accountid int,
@groupid int



begin
set nocount on
select @miscid = isnull(max(@miscid),0) + 1 from miscellaneourpay

if exists (select * from storemaster where storename = @storename)
select @storeid = storeid from storemaster where storename = @storename

if exists (select * from accountmaster where accountname =@accountname)
select @accountid = accountid from accountmaster where accountname =@accountname

if exists (select * from accountgroupmaster where groupname=@groupname)
select @groupid=groupid from accountgroupmaster where groupname=@groupname




begin transaction
insert into miscellaneourpay
(
miscid,
storeid,
accountid,
groupid,
paymentdt,
paymode,
payeename,
bankname,
chqdt,
chqno,
amt,
bal,
remarks

)
values
(

@miscid,
@storeid,
@accountid,
@groupid,
@paymentdt,
@paymode,
@payeename,
@bankname,
@chqdt,
@chqno,
@amt,
@bal,
@remarks

)
commit transaction

end 

View 2 Replies View Related

How To Restrict User To Tab (no Mouse) Selection -question Transferred To VB Forms

Jan 16, 2007

Sorry.

View 1 Replies View Related

SQL Server 2012 :: Query For User Access To Application Modules

Mar 24, 2015

I have to create a query that will be returning the users and the application modules they have access for. Along with the list of users and modules the query should also return if any module is not accessible for that user.

The 'ApplicationUsers' table is like this:

CREATE TABLE #ApplicationUsers
(
userId INT,
UserName VARCHAR(50)
)
INSERT INTO #ApplicationUsers VALUES
(1, 'Daniel'), (2,'Martin'), (3, 'Brandon'), (4, 'Doug')The 'ApplicationModule' table is like this:

[Code] .....

I used pivot query but there are a couple of limitations in it(may be I am making mistakes in it). First, the pivot columns are static whereas I need dynamic column names(Application Modules). Second, I need to include all the users with all the modules with access or without access that I am unable to achieve.

View 5 Replies View Related

SQL 2012 :: Allow Authenticated User To Query Excel File Via Linked Server?

May 25, 2014

I have a 3rd party dashboard application that I can only use SQL authenticated logins to connect to the database.

I'm trying to create a query within the application that will directly access an excel file through a linked server.

As a test, I login to SSMS as the sql auth user to run the linked server query below but the following error is returned:

select *
from Corporate...[Sheet1$]OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "Corporate" returned message "Cannot start your application. The workgroup information file is missing or opened exclusively by another user.".
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "Corporate" reported an error. Authentication failed.
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "Corporate".

When I login as a Windows auth user, I can successfully run the above query.

I noticed within the linked server's security definition that I cannot specify a windows auth user as the mapped Remote User or as the Remote login

I've tried creating a Credential object with the identity of the windows user and assign that object to the sql auth user but to no avail. I still get the same error

I am using SQL Server express so the option of an automated server agent job to import the excel file is not available.

Details:
SQL Server Express 2012
Office version: Excel 10
Provider: Microsoft.ACE.OLEDB.12.0

View 9 Replies View Related

SQL 2012 :: Design A Table To Hold Filters For Selection Criteria?

May 5, 2014

I have an ordering database with several tables that store data of orders belonging to a wide variety of clients. There is a generic report that I need to run which outputs the same data elements. However the criteria to select these orders will vary widely between each client. For e.g.

i) for client# 1 it could be all orders that are still open after 30 days of placing an order

(
OrderStatus = 'Open'
AND
GetDate() - OrderCreationDate >= 30
)

ii) for client# 2 it could be all orders that have been completed 60 days or earlier

(
OrderStatus = 'Completed'
AND
GetDate() - OrderCompletedDate >= 60
)

iii) for client# 3 it could be a combination of different things (all orders in West Region that are in hold status for more than 10 days + all orders in Eastern Region that are in shipping and are expected to be delivered in the next 2 days + all completed orders for the rest of the regions).

(
OrderRegion = 'West'
AND
OrderStatus = 'Hold'
AND
GetDate() - OrderHoldDate >= 10

[code].....

I want to have a stored procedure that selects all data and dynamically attach the where condition at the end for filtering. This way I wouldn't have to worry about any additions/changes that are made to the selection criteria. I can build an interface for admins who can use the UI to maintain the selection criteria and not worry about any code changes to accommodate it. I would like to design a table that holds this criteria. At this point in time, I am thinking of using key value pairs (Column Name, Column Value) but I am not sure how to implement multiple logical operators.

View 4 Replies View Related

Two Parameters Question? Second Parameter Should Get Data Based On First Parameter Selection.

Jan 8, 2007

I have two parameters both are related to each other.

second parameter should get filled based on the selection of the first one which is project.

the first paramater is project, once the project is selected it should bring the all the contracts related to that project.

Please is it possible...



Thank you very much for all the helpful info.

View 5 Replies View Related

Selection Of Table Based On Value Selected For The Particular Attribute In Master Table

May 29, 2008



Now i have master Table for a device Utility. There is a attribute called "Device Type " in the table. Every Device Type has specific Device Attributes associate with it . Now attribute of Diffrent Device type are stored in Different Tables. Now when i select a particular value of Device Type ( lets say Type 1 or TYPE 2 ... ) then the table with has the attribute associated with particuter device type only has to be selected .
So how can I do this ???
How to form a realtion between the tables,... ????

View 1 Replies View Related

One Form To Update Different SQL Tables Based Upon Form Selection

Apr 16, 2008

Hello,
My company Intranet has a form that agents can use to post their comments about the company to upper management, but our customer service department would like to modify the form so that the agent has to pick from a comment type.
The dropdown options on the form will be as follows:
ComplimentsComplaintsGeneral CommentsSuggestions
Each dropdown option has a designated table in a SQL DB.Using postback on the same page, I need to change which fields of the form are visible based upon which dropdown selection the user chooses, and I need the fields to then be inserted into the table that corresponds with the dropdown selection item.
For example: If the Compliments dropdown selection is picked, I need a text box to show for the user's location, the name of the customer, account number, and the message box. Once the submit button is clicked, the characters in these boxes need to be inserted into the Compliments table using its data adapter.
However, if the user selects Suggestions, the name of the customer and the account number should not be visible, since these fields do not exist and when the submit button is pressed, the Suggestions table should be updated.
If you need more information, I will provide whatever is needed.
As always, thanks for everyone's assistance.
Chris

View 3 Replies View Related

In 2000 Is It Possible To List Second Parameter Based On The First Parameter Selection

Jan 11, 2007

Hi

In 2000 is it possible to list second parameter based on selection

in the first parameter list

Cheers

View 10 Replies View Related

Selection Query

Sep 21, 2006

Hi All

Being new to this forum and to SQL, I would to apologise upfront for my clumsy code and explanations as I try and get to grips with this subject.

I have created this query which does work:

SELECT T1.U_Serial,
case
when (U_RDate < GETDATE() AND U_ASDate Is NULL)
then 'NA'
when (U_RDate Is NULL)
then 'No Request'
when (U_ASDate Is Not NULL And U_AEDate Is NULL)
then 'NA'
when (U_ASDate Is Not NULL And U_AEDate Is Not NULL)
then 'A'
when (U_RDate > GETDATE() AND U_ASDate Is NULL)
then 'NA'
else 'DN'
end As Available,
case
when (U_RDate < GETDATE() AND U_ASDate Is NULL)
then 'Late'
when (U_RDate Is NULL)
then 'No Request'
when (U_ASDate Is Not NULL And U_AEDate Is NULL)
then 'Busy'
when (U_ASDate Is Not NULL And U_AEDate Is Not NULL)
then 'Done'
when (U_RDate > GETDATE() AND U_ASDate Is NULL)
then 'Waiting'
else 'DN'
end As Progress,

T1.U_Status,T1.U_JobTp, T1.U_JobNr,T1.Code, T0.U_CardNM, T0.U_ZpCd, GETDATE() as Today, T1.U_RDate, T1.U_ASDate, T1.U_AEDate, T1.U_ItemCd, T1.U_ItemDsc

FROM [dbo].[@IDH_JOBENTR] T0 , [dbo].[@IDH_JOBSHD] T1

WHERE T0.Code = T1.U_JobNr AND T1.U_Serial not like ''

ORDER BY T1.U_Serial, T1.U_AEDate DESC, T1.U_JobNr DESC ,T1.Code DESC,Today, T1.U_RDate, Available, Progress, T1.U_Status,T1.U_JobTp,T0.U_CardNM, T0.U_ZpCd, T1.U_ASDate, T1.U_ItemCd, T1.U_ItemDsc

The tables I’m using are IDH_JOBENTR which is the header records for my jobs and IDH_JOBSHD, which holds the row details for the jobs.

I’m trying to extract from the IDH_JOBSHD table the last (row) detail record for the (header) job.

The way the query works now, the first row for each unique serial number is the record I need, but this is all the info I would like to display I don’t need the other lines, and I don't know how to strip out the rest of the data

I hope this make sense.

Kind regards
Hayden

View 7 Replies View Related

Selection From Query Fails

Mar 29, 2005

Hello,
I wonder if someone has come across a similar problem I am having.
I am migrating a database from Access to MS SQL 2000. The tables imported fine, but the queries had to be rewritten. I placed them under "Views". At present I am able to run a query directly on the SQL server, and it populates all fields nicely.
When I do "SELECT * FROM EQCustomerReport" where EQCustomerReport is a name of a View on SQL, it only returns part of the fields. The other fields are blanked out for some reason.
Please tell me if I am making a common mistake or something. Should I be using Stored Procedures instead of Views. Or would I be better of passing a full text of a query from my .NET application?
Thanks very much in advance.
Martyn

View 3 Replies View Related

SQL 2012 :: Query To Make Single Records From Multiple Records Based On Different Fields Of Different Records?

Mar 20, 2014

writing the query for the following, I need to collapse the continuity. If the termdate for an ID is one day less than the effdate of the next id (for the same ID) i need to collapse the records. See below example .....how should i write the query which will give me the desired output. i.e., get min(effdate) and max(termdate) if termdate is one day less than the effdate of next record.

ID effdate termdate
556868 1999-01-01 1999-06-30
556868 1999-07-01 1999-10-31
556869 2002-10-01 2004-01-31
556872 1999-02-01 2000-08-31
556872 2000-11-01 2004-01-31
556872 2004-02-01 2004-02-29

output should be ......

ID effdate termdate
556868 1999-01-01 1999-10-31
556869 2002-10-01 2004-01-31
556872 1999-02-01 2000-08-31
556872 2000-11-01 2004-02-29

View 0 Replies View Related

Help! The Transaction Log Is Full Error In SSIS Execute SQL Task When I Execute A DELETE SQL Query

Dec 6, 2006

Dear all:

I had got the below error when I execute a DELETE SQL query in SSIS Execute SQL Task :

Error: 0xC002F210 at DelAFKO, Execute SQL Task: Executing the query "DELETE FROM [CQMS_SAP].[dbo].[AFKO]" failed with the following error: "The transaction log for database 'CQMS_SAP' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.


But my disk has large as more than 6 GB space, and I query the log_reuse_wait_desc column in sys.databases which return value as "NOTHING".

So this confused me, any one has any experience on this?

Many thanks,

Tomorrow

View 5 Replies View Related

Vote Query Logic Selection

Jun 3, 2006

Hello,
I have a requirement to select millions of rows from table and need do some parsing each row. I have identity column on each table.
Here is the query logic I'm following.
Logic A:Uisng While loop processing data row by row
Logic B: Using Cursor Processing row by row

Here is the perormance on the above ran against .5 millions rows of data.

Logic A: Logic B:
CPU usage 564254 464511
Duration 18 15

The above result after completion of the data
The below is from query analyser
Estimated query Cost 21% 79%

Can we trust Estimated query cost? and Which logic you will choose use?.

View 1 Replies View Related







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