hi, i have this sql statement:
@uname varchar(20)
select@sql = 'select user_name, password, role_code, expiry_date,effective_from,active from usermaster where userid='1' and username like'@uname%'
it is not worrking for me.i don't know how to pass values in dynamicsql,can any one answer for me please.
I have an SSIS package that has a variable called @RUN_DATE.I would like to create a sql agent job and uses the set values tab to pass a dynamic parameter to the ssis package. for example, i would like to always set the variable to the last day of the previous month. I know that If i hardcode the date as 5-31-2013 it works fine, but i have not been able to figure out how to make the value dynamic by using an expression or if this is even possible.
In c# - how to pass uid,pwd,dbname and servername as input parameters from vs 2003 windows application (am calling the rdl file from reporting service 2005 web service) to sql server 2005 rdl files.
I use a DataGrid to show the data, and I want it has a sorting and Paging function, so I use dataset to collect the data from middle tier function and stored procedure. I have code in aspx page like BindData(ViewState("SortExpr")).
In the stored procedure I pass SortExpr as parameter as following:
DECLARE @RowCount int SELECT @RowCount = Count(*) FROM ZIPCodes WHERE ZIPCode = @Zipcode AND CityType = 'D'
if @RowCount > 0 BEGIN SELECT z.ZIPCode, z.City, z.StateCode, a.Make, a.Model, a.AutoPrice, a.AutoPrice2, a.AutoYear, a.Mileage, a.AdID, a.ImageURL, dbo.DistanceAssistant(z.Latitude,z.Longitude,r.Latitude,r.Longitude) As Distance /* The above functions requires the Distance Assistant. */ FROM ZIPCodes z, RadiusAssistant(@ZIPCode,@Miles) r, AutoAd a WHERE z.Latitude <= r.MaxLat AND z.Latitude >= r.MinLat AND z.Longitude <= r.MaxLong AND z.Longitude >= r.MinLong AND z.CityType = 'D' AND z.ZIPCodeType <> 'M' AND z.ZIPCode = a.Zipcode AND a.AdActive = '1' AND a.AdExpiredate >= getdate() AND a.Make = @Make AND a.Model = IsNull(@Model,a.Model) AND a.Condition = IsNull(@Condition, a.Condition) AND dbo.DistanceAssistant(z.Latitude,z.Longitude,r.Latitude,r.Longitude) <= @Miles ORDER BY @SortExpr END ELSE SELECT -1 As ZIPCode --ZIP Code not found... GO
but I got the error as "variables are only allowed when ordering by an expression referenceing a column name". How I fix this error? Please help.
I have a parent package which accepts date as input. I can configure Set Values of Execute Package Utility with hard coded date value and it works fine. My question is how do I configure Set Values to accept dynamic date value or current date value (may be using GetDate()) ?
My task is to read the filename from a database table and transfer the flat file data in to a table. In SSIS,I am able to fetch the file name using a Data Reader Source; but how to pass this fileName parameter to Flat File Source ?
In DTS I have used ActiveX script to pass filename variable as flatfilecon.Source. Any help ?
I am using the Query analyzer and i have this stored procedure and i need to pass the ProductID and the OrderID and in query analyzer i call the "EXEC CustOrdersDetail 75 10347" but i get a syntax error near 10374...so my question is how do i pass multiple paramters in the query anlyzer to see what the stored procedure will return....
SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO
ALTER PROCEDURE CustOrdersDetail @OrderID int AS SELECT ProductName, UnitPrice=ROUND(Od.UnitPrice, 2), Quantity, Discount=CONVERT(int, Discount * 100), ExtendedPrice=ROUND(CONVERT(money, Quantity * (1 - Discount) * Od.UnitPrice), 2) FROM Products P, [Order Details] Od WHERE Od.ProductID = P.ProductID and Od.OrderID = @OrderID
GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO
I want to do something like this SELECT LocationID, Description, ActiveFROM dbo.CapLocationWHERE (Active = 1) AND (LocationID NOT IN (2)) AND (LocationID NOT IN (@LocationID) OR @LocationID IS NULL)ORDER BY Description For the life of my I can not figure out how to pass a group of values like 1,2,3. Any help would be greatly appreciated, Bryan
We're using MS Access 2010 as a frontend to an SQL server back-end. From Access, I can run read-only queries and pass-through queries. I'd like to use a local Access table as part of a join to server data. As a non-pass-through query, it's slow; about 5 min to join to 2 other tables.
I could use VBA to turn the local table into part of a pass-through query, with a large in() statement, or several where x='' ors but the local table may have 50000 entries in it. Is there a good or right way to pass this data in the query if I don't have write access to the server?
I have to generate a seq num and increment it by 1,i used execute sql task and wrote a proc using a variable(out) now this out variable has that value.Now i need to add a extra column to all the records coming in this current batch with the value in the variable.
I know that i can use derived column transformation ,but its not working,giving the following error.
the errors thrown are:
[OLE DB Destination [16]] Error: An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80004005 Description: "Unspecified error". An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80004005 Description: "ORA-01779: cannot modify a column which maps to a non key-preserved table ". [OLE DB Destination [16]] Error: The "input "OLE DB Destination Input" (29)" failed because error code 0xC020907B occurred, and the error row disposition on "input "OLE DB Destination Input" (29)" specifies failure on error. An error occurred on the specified object of the specified component. [DTS.Pipeline] Error: The ProcessInput method on component "OLE DB Destination" (16) failed with error code 0xC0209029. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. [DTS.Pipeline] Error: Thread "WorkThread0" has exited with error code 0xC0209029. [OLE DB Source [1]] Error: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020. [DTS.Pipeline] Error: The PrimeOutput method on component "OLE DB Source" (1) returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. [DTS.Pipeline] Error: Thread "SourceThread0" has exited with error code 0xC0047038.
i have created a variable with scope as package,used that in execute sql task.then using precedence constrains added a data flow task to it.
In the data flow task between the source and destination i placed a derived column transformation.
the execute sql task is running fine,dataflow task is failing.In dataflow task also source and destination is failing but derived column transformation is working.
hi friends,i need to select some of the employees from the EmpMaster using in clause. I tried to pass a string with the comma delemeters. it didn't produce all the records except the first in that string.shall i try with string functions in TSQL or any other options? Thanks and Regads,Senthilselvan.D
Currently i am working in a project of report generation in MS ACCESS.
The tables are in sql server 2000. I have to write stored proc in ms access.
Illustration: I am having a stored proc as follows
name: myproc ------------------- Create procedure my_proc @f1 char(1), @f2 char(5) As select * from table1 where field1=@f1 and field2=@f2 ________________________________________________ and calling proc name: call_myproc
execute my_proc 'A','2004'
If i am getting the vales of field1/@f1 and field2/@f2 from forms in ms access.
How is it possible to pass values from ms access FORMS to a calling stored procedure.
I have followed the way of creating and executing the stored procedure as given in the article as follows. http://www.databasejournal.com/features/msaccess/article.php/10895_3363511_1
As per the given link. They did not give values dynamically.
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?
Hi, I need to automate the procedure of selecting column with numeric and passing those column values as string to another stored procedure.
Here is sample code : CREATE procedure procdeure1 @Utility varchar(50) WITH RECOMPILE as if @Utility='Electricity' begin IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'gmmers1') DROP TABLE gmmers1 IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'gmmers2') DROP TABLE gmmers2 create table gmmers1(sitecode varchar(15), Gen_Electricity_Usage bigint ) create table gmmers2 (gmmerssitecode varchar(15), Gmers_Electricity_Usage bigint ) insert into gmmers1 Select site.Sitecode,sum(isnull(AcctRptdata.ElectricityUse,0)*factor) as 'Electricity Usage' From GEN..AcctRptdata AcctRptdata, GEN..site site,SuperAccesslevels.dbo.convfactor,SuperAccesslevels.dbo.countrysettings Where ((AcctRptdata.Year*100)+AcctRptdata.Month) >= 200511 and --((AcctRptdata.Year*100)+AcctRptdata.Month) < year(DATEADD(m,-1, GetDate()))*100+month(DATEADD(m,-1, GetDate())) and ((AcctRptdata.Year*100)+AcctRptdata.Month) >= 200511 and ((AcctRptdata.Year*100)+AcctRptdata.Month) <= 200707 and site.idsite = AcctRptdata.siteid and site.sitecode not like ('C%') and len(sitecode ) = 8 and AcctRptdata.idsvc in (100) and SuperAccesslevels.dbo.convfactor.[Default] = SuperAccesslevels.dbo.countrysettings.IdUnitElec and SuperAccesslevels.dbo.countrysettings.IdCountrySetting = Site.IdCustomerSetting and [user] = 1 and site.Sitecode not like '%B%' and site.sitecode not like '9999%' and AcctRptdata.ElectricityUse >0 --Added on 16th Aug and site.sitecode in (select left (sitecode,8) from GEN..site where len(sitecode) >8)--= 11) --and site.sitecode in (select left(sitecode,8) from gmers_prodn..facility_data where len(sitecode) = 11) Group by site.Sitecode having sum(AcctRptdata.ElectricityUse*factor) > 0 Order by site.Sitecode
insert into gmmers2 select left (sitecode, 8) BU, sum(isnull(KWh_Purchased_Quantity, 0 )) as 'electric use' from gmers_prodn..electricity_data where sitecode in --(select sitecode from facility_data where left (sitecode ,8) in (select sitecode from gen..site where sitecode not like 'C%' and len(sitecode ) > 8 ) -- and len (sitecode) = 11) and rpt_dt >= '2005-11-01' and rpt_dt < '2007-08-01' --and sitecode like 'A0916323%' and sitecode not like '%B%' and left(sitecode,8) not in ('N0010024','N0010088','N0010101','N0010173', 'N0010373','N0010447') and sitecode not like '9999%' group by left (sitecode, 8) order by left (sitecode, 8) -- yyyy-mm-dd
select *,(Gen_Electricity_Usage-Gmers_Electricity_Usage)as Diff from gmmers1,gmmers2 where gmmers1.sitecode=gmmers2.gmmerssitecode and (Gen_Electricity_Usage-Gmers_Electricity_Usage) <>0 end else if @UTILITY='GAS' begin IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'gengas') DROP TABLE gengas IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'gmmersgas') DROP TABLE gmmersgas create table gengas(sitecode varchar(15), Gen_Gas_usage bigint ) create table gmmersgas (gmmerssitecode varchar(15), Gmers_Gas_Usage bigint ) insert into gengas Select site.Sitecode,sum(isnull(AcctRptdata.NaturalGasUse,0)*factor) as 'Gas Usage' From GEN..AcctRptdata AcctRptdata, GEN..site site,SuperAccesslevels.dbo.convfactor,SuperAccesslevels.dbo.countrysettings Where ((AcctRptdata.Year*100)+AcctRptdata.Month) >= 200511 and --((AcctRptdata.Year*100)+AcctRptdata.Month) < year(DATEADD(m,-1, GetDate()))*100+month(DATEADD(m,-1, GetDate())) and ((AcctRptdata.Year*100)+AcctRptdata.Month) >= 200511 and ((AcctRptdata.Year*100)+AcctRptdata.Month) <= 200707 and site.idsite = AcctRptdata.siteid and site.sitecode not like ('C%')and len(sitecode ) = 8 and AcctRptdata.idsvc in (200,300) and SuperAccesslevels.dbo.convfactor.[Default] = SuperAccesslevels.dbo.countrysettings.IdUnitGas and SuperAccesslevels.dbo.countrysettings.IdCountrySetting = Site.IdCustomerSetting and [user] = 61 and site.sitecode not like '%B%' and site.sitecode not like '9999%' and site.sitecode in (select left (sitecode,8) from GEN..site where len(sitecode) >8) and AcctRptdata.NaturalGasUse >0 ----Added on 16th Aug --and site.sitecode in (select left(sitecode,8) from gmers_prodn..facility_data where len(sitecode) = 11) Group by site.Sitecode having sum(AcctRptdata.NaturalGasUse*factor) > 0 Order by site.Sitecode
insert into gmmersgas select left( sitecode, 8 ) BU , sum(Utility_Natural_Gas_Volume) as 'gas use' from GMERS_PRODN..fuel_data where sitecode in --(select sitecode from facility_data where left (sitecode,8) in (select sitecode from gen..site where sitecode not like 'C%' and len(sitecode ) > 8 ) -- and len(sitecode )= 11 ) and rpt_dt >= '2005-11-01' and rpt_dt < '2007-08-01' and sitecode not like '%B%' and sitecode not like '9999%' group by left( sitecode, 8 ) order by left( sitecode, 8 )
select *,(Gen_Gas_usage-Gmers_Gas_Usage)as Diff from gengas,gmmersgas where gengas.sitecode=gmmersgas.gmmerssitecode and (Gen_Gas_usage-Gmers_Gas_Usage)<>0 end
My aim is to pass sitecode having difference <>0 and from date and todate as an parameter to another stored procedure which updates sitewise for the utility so that in case a particular sitecode with same date range is included in one utility it should not be repeated in another utility.
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).
I created a stored procedure like the following in the hope that I can pass mulitple company_id to the select statement:
CREATE PROC sp_test @in_company_code nvarchar(1024) AS
select company_code, name, description from member_company where company_code in (@in_company_code)
However, I tried the following :
exec sp_test 'abc', 'rrd', 'bbc'
Procedure or function sp_test has too many arguments specified.
and SQLServer doesn't like it.
Did I specify this stored procedure correct? If so, how can I can pass multiple values to the stored procedure then to the sql statement? If not, is it possible to specify a stored procedure like this?
I have a stored procedure "spDetailsByDay" which takes parameters @StartDateTime as datetime, @Day as int, @Hour as int, @Value1 as varchar(20), @value2 as varchar(20)
My report Parameters are StartDateTime as DateTime, Day as integer, Hour as integer, Value1 as string, Value2 as string, ReportType as string
hi, i am using ssrs 2005 and need to pass the multi selected parameter values to another report. how can i achieve this task? I use jump to report option.
ALTER PROC [dbo].[sp_GetInvitationStatusTest] ( @invited_by NVARCHAR (50) ) AS BEGIN -- SELECT * FROM dbo.Merck_Acronym_Invitations WHERE invited_by=@invited_by select distinct t1.invited_isid as 'ISID', t1.invited_name as 'NAME',t1.invitation_status as 'STATUS',
[Code] ....
If you look at the where clause i have invited by , i get the desired output if i just provide 1 name in the execution such as exec [dbo].[sp_GetInvitationStatusTest] 'marfilj' But my requirement is to make the procedure work with more than one input variable such as exec [dbo].[sp_GetInvitationStatusTest] 'marfilj','sujith' now i should get the output for 2 people but if i run this i receive the following error Procedure or function sp_GetInvitationStatusTest has too many arguments specified.
how to make my procedure work with more than 1 input variable?
We have an SSrS report that has a tablix cell with a textbox that is a hyperlink to another SSrS report. We pass parameters to the report using the textbox properties>Action set to "Go to report" and setting the parameters to the value of a field and a parameter as shown below. We want to set action to "Go to URL" and to pass these variable parameter values in the URL. How is that done? URL....
Actually we have multiple Sub Reports which we want to open from the Main Report. Initially when i used "Jump To Report" property it worked fine but in the browser the Main Report used to get refreshed everytime i had to Go Back to Main Report from Sub Report. Second solution which i want to try is using "Jump To URL" property. Some Details: I have multiple parameters in the report. My parameters are getting data from a Cube. Parameters can have Multiple Vaue selected at a time. I want to pass all the values to the URL.
Say Parameter1 is DimCountryCountry can have values such as: [Dim Country].[Country].[All] [Dim Country].[Country].&[India] [Dim Country].[Country].&[Germany] ......
Parameter2 is DimCountryState can have values such as: [Dim Country].[State].[All] [Dim Country].[State].&[Delhi] [Dim Country].[State].[Punjab] .....
Now i want to create a URL using these values,since each parameter should be separated by "&"(ampersand) my URL looks like one below. Following URL Works fine: javascript:void(window.open'(http://MyReportServer/ReportServer/Pages/Report.aspx?/MyReports/Project1/Country+Data&rcarameters=false&DimCountryCountry=[Dim Country].[Country].[All]&DimCountryState=[Dim Country].[State].[All]'))
as long as there is no "&" in the Parameter Value the URL works fine. But when i try to insert values other than "[All]" it starts failing because "[Dim Country].[Country].&[India]" contains "&", which gives error due to ambiguity, (whether this "&" is a parameter separater or is it a part of parameter value)
So i found a solution for that, which is to replace "&" with "%26" escape sequence characters.This works fine as long as we specify this escape sequence in address bar. i.e if we directly paste the following URL in the address bar it will work. http://MyReportServer/ReportServer/Pages/Report.aspx?/MyReports/Project1/Country+Data&rcarameters=false&DimCountryCountry=[Dim Country].[Country].%26[India]&DimCountryState=[Dim Country].[State].%26[Delhi]
but if we put this URL in the Javascript, it doesnot work, because the WIndow.Open function automatically replaces the "%26" characters with "&", which we know gives ambiguity error.
Please let me know if you have any suggesiton for it. Anyway any better solution for my problem.
I got issue when passing multiple values to a single parameter. Here is my stored procedure as following:
CREATE PROCEDURE [dbo].[School] @Grade AS varchar(50), @Class As varchar(50) AS BEGIN SELECT Name, Grade, Class FROM School WHERE Grade = (IsNull(@Grade, Grade)) AND Class IN (IsNull(@Class, Class )) END
In the front end, I got multiple values for Subject parameters such as Math, English, Reading, etc... in a specified class. How do I can modify my above stored procedure to receive multiple values for a single parameter.
I have One package that it contains one Execute SQL task in that i have placed a Stored procedure . Now i want to pass values to Stored procedure parameters from a databse table by dynamically .For this i am trying to use " Script task " How can i pass that table column values to that stores procedure thru using Script Task?
Hi, I have created an report by selecting stored procedure as dataset data source. Now when I run the report, it is asking for the parameter values for my stored procedure, but I want to pass the values from another .aspx page. Could any one please let me how do I pass values to the stored procedure parameters in the report. I tried doing the Local method of reports, but the printer icon is not appearing in that, if I use Reportviewer control of my own. When I use the Remote method of reports, I am facing this problem. Please could any one help me in this.
I would like to know how does subreport accept multi value, and how should i modify my expression so that the sub report will display correctly.
My main report will pass dynamic number of account number to sub report, it depends on how many account number a person has. I have my sub report parameter Data Type set as "Allow multiple values" and the visibility is "Visible".
Currently, I am using the following expression to try to pass multi value from main report to sub report. I had tested the result of that expression. It is showing the following result when there are 3 account numbers to pass to sub report.
1534896 1563498 1593548
With that expression, when only one account no is pass from main report to sub report, the sub report will display the result. But when more than one account numbers are passing over, the sub report display nothing, it is blank.
*Note: I cannot put the account number into a multivalue parameter in the main report and pass from that parameter to sub report. I know this will workd BUT I had tried that by setting the default value in the multivalue parameter to the dataset that consists of the account number. That involves 100 thousand plus plus account numbers and it will for sure over the limit of 8000 characters.