SQL 2012 :: Using OVER Command Together With (WITH) And Excel With A Parameter?

Dec 29, 2014

I'm am using an Excel with a parameter, in this case a customer-number. For retrieving the data I use a view. In this view I start with a WITH to retrieve the data because I need the customer number in several places in the view. In the beginning all data I need is a 1:1 relation with the customer but problems occurs when there is a 1:n relation, in my case a customer can have more contact persons. When I try to collect the contact person information it always finds the first contact person in the table and that's from a different customer.

What do I have to do to find the contact person(s) that belongs to my specific customer/?

with Customer as (
Select * from [ods].[custtable] where ODSACTIVE = '1' AND DATAAREAID = 'NL01'
)
union all
select src.accountnum, 'Contact Person 1 Name' as 'Field', SRC.NAME as 'Value'
FROM (SELECT CP.NAME, CT.accountnum, ROW_NUMBER() OVER (ORDER BY CP.PARTYID) AS RN, ct.partyid
from [ods].[contactperson] cp inner join CUSTOMER CT on ct.partyid = cp.ORGpartyid and ct.DATAAREAID = cp.DATAAREAID
WHERE cp.DATAAREAID = 'NL01'
) AS SRC WHERE SRC.RN = 1

View 2 Replies


ADVERTISEMENT

SQL Server 2012 :: Can Excel Be Passed As Stored Procedure Parameter

Sep 29, 2015

Currently i am using SQL Server 2012 Import/Export Wizard to upload data to sql tables manually. However i was trying to write a procedure to update that table. and on the time of execution, if i can pass excel. Is there any way to pass excel to stored procedure parameter?

View 1 Replies View Related

Import Excel Via Excel Command

Jan 24, 2008



Hi
I want to import excel in SSIS via sql command and change the data types. can anyone guide me on this or give me some sample command on how to change datatypes explicitly.

View 1 Replies View Related

SQL Server 2012 :: Set Default Parameter For Function Parameter?

Jan 13, 2014

I want to set the default parameters for a function. I;d like to set the date start date to current date and end date for the last 90 days. how to make this work?

Create Function HR.Equipment
(
@startdate Date =(Convert(Date,DATEADD(DAY,-1,GETDATE())),
@enddate Date = (Convert(Date,@StartDate-90)
)
RETURNS TABLE AS RETURN
(
SELECT
EquipID,
EmpName,
IssueDate
FROM HR.Equipment
WHERE IssueDate <=@StartDate and IssueDate >=@EndDate
)
GO

View 5 Replies View Related

Getting OUTPUT Parameter In An OLE DB Command

Jul 12, 2007

Is it possible to use stored procedure with output parameter and retrieves the values of that output parameter, in an OLE DB Command within a Data Flow?

What I wanted to do is to get the newly created identity of a row so that I can insert it to the main data set in data flow. I'm not even sure if there is even a much better design to achieve this. I've rummaged the internet but everything I got were all about Execute SQL Task.

View 5 Replies View Related

C# Command Timestamp Input Parameter

Mar 27, 2007

I have a stored proc that inserts a customer and it expects a timestamp input parameter. I dont know what a timestamp datatype is for sql 2005 and Ive tried to parse all sorts of data types but the proc errors out saying it needs "Byte[]" which Ive tried. Can anyone help me with this? ThanksRyan 

View 2 Replies View Related

How To Pass Parameter Into Source SQL Command?

Nov 15, 2007

Hi all,
I want to pass a parameter into my OLE DB source. For eg, I want to set the condition
SELECT * FROM "tablename" where ID = parameter  <-----------------
I do not know how to do this? can it be done by using package variable?

View 2 Replies View Related

Adding Parameter To Items In Where Command

Nov 6, 2013

I have 3 specific where searches in where command I want to add a defined text to each specific where query if that makes sense. highlighted in red, how do I do this? going to add status after and then do pivot table afterwards.

SELECT
POHEAD.DocumentNo
,POHEAD.CreditorCode
,POHEAD.InternalReference
,POHEAD.QuantityOrdered
,POHEAD.Z_ArrivalDate

[Code] .....

View 1 Replies View Related

Passing A Parameter To A USE Command Within A Cursor

May 27, 2008

Hi everyone I am trying to pass a parameter to a USE command within the body of a cursor. I keep getting an error. Here is my code.




Code Snippet
DECLARE @SQLText AS NVARCHAR(4000)
Declare @SQLText2 as NVARCHAR (2000)


DECLARE Cursor_Trial CURSOR FOR SELECT name FROM sys.sysdatabases order by name
Declare @name as varchar(255)
Open Cursor_Trial
FETCH NEXT FROM Cursor_Trial INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN
Use @name --------This is where I'm getting the error


Set @SQLText2 = @name
select @SQLText2, * from sys.database_principals
where type_desc='DATABASE_ROLE'
and name = 'xxxxx'

FETCH NEXT FROM Cursor_Trial INTO @name

END

CLOSE Cursor_Trial
DEALLOCATE Cursor_Trial


As you can see I am trying to pass the next database name into the body of the cursor so that the query will pull the role information only for the current database in the loop. Any thoughts or tips? Is there a better way to accomplish what I'm trying to do here?


View 1 Replies View Related

Integration Services :: Using A Parameter In Command

Nov 3, 2015

I have a Data Flow task Within a for loop Container.. the for loop container receives the result of sql query, iterates over the result set and passes each variable to the OLE DB Source.. Now based on the parameter passed I need to execute a query.. say for example if the parameter passed is P1 execute SQL S1 , P2 then S2 & so on.. How do I use the Parameter passed in SQL Query?

View 12 Replies View Related

Parameter Cannot Set The Command Text For Dataset

May 14, 2007

Hello



I get the following error in a very quick test system i created:



An error occurred during local report processing.

An error has occurred during report processing.

Cannot set the command text for data set 'test'.

Error during processing of the CommandText expression of dataset 'test'.



My sql is:

= "select T.testid, T.test from test T " & Iif(Parameters!test1.Value = 1, "", "Where T.testid = " & Parameters!test1.Value)



There is nothing obviously wrong in the code as far as i can see



The parameter 'test1' is of type 'string'



The database 'test' has 2 columns of type 'smallint' and 'Name:nvarchar(50)'



I am at a loss, as this query is really simple, and is similar to the example query set up my microsoft which works fine



Thanks

View 5 Replies View Related

Optional Command Line Parameter

Jan 17, 2006





Hello,



I want to use an optional parameter at the command line for my package.

I planned to make the first task a script which simply checks the variable (which is a string), and if it is empty, go one way, and if it is not, go another way. Is the best to go?



Many thnaks in advane

View 4 Replies View Related

Using Adodb Command - Output Parameter Problem- HELP!

Jul 20, 2005

We use a number of similar databases and frequently create a newdatabase using a backup restore of another similar database. We try tokeep changes between databases in _Additional tables - like AccountAdditional, Sale_Additional so most tables stay the same. The latestrestored database (I'll call it DBaseA) is behaving differently in VB6code and I need help trying to make it work.I have been using use an ADODB.Command to execute a stored procedureusing adCmdStoredProc and Parameters.Refresh to get an output parametervalue which is an integer. Here is a sample of the VB:Public Function UnlockAccount(Account_ID As String) As BooleanDim LCmd As ADODB.CommandOn Error GoTo ERROR_UnlockAccountUnlockAccount = TrueIf Account_ID <> "" ThenIf DBConnect() ThenSet LCmd = New ADODB.CommandLCmd.ActiveConnection = CN(0)LCmd.CommandTimeout = 0LCmd.CommandType = adCmdStoredProcLCmd.CommandText = "Unlock_Account"LCmd.Parameters.RefreshLCmd.Parameters("@Account_ID").VALUE = Account_IDLCmd.Execute , , adExecuteNoRecordsIf LCmd.Parameters("@Status") <> 0 ThenUnlockAccount = FalseEnd IfElsemsgbox "UnlockAccount: DBConnect Failed", "UnlockAccount"End IfEnd IfExit FunctionERROR_UnlockAccount:UnlockAccount = Falsemsgbox "UnlockAccount: App Error: " & Err & " " & _Err.Description, "UnlockAccount"DBConnect TrueExit FunctionResume'for debuggingEnd Functionand this is one of the sps that fails - can't be more simple!Create PROCEDURE Unlock_Account( @Account_ID UNIQUEIDENTIFIER,@Status INTEGER =null OUTPUT) AS/* Strip functionality */SET @Status = 0goThis code is still working in at least 4 other databases. It fails indatabase DBaseA with the error:Invalid character for cast conversionWe are talking about the exact same table definition and the exact samestored procedure just in different databases.I fumbled around on the Internet and found a mention in a PowerBuilderweb site of additional parameters in the connect string which seems tofix the problem in SOME of the stored procs - but not all.The added parameters are:DelimitIdentifier='No';MsgTerse='Yes';CallEscape='No';FormatArgsAsExp='N'They are not documented in MS but are in Sybase?? No idea why, but someof the stored proc functions work when I add this to the connect string.The complete connect string is:Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DBaseA;Data Source=PHASE2-S500,1433;Network Library=DBMSSOCN;DelimitIdentifier='No';MsgTerse='Yes';CallEscape='No';FormatArgsAsExp='N'The databases are on different servers - but they are running the sameversion of SQL2000, the same version of Windows. I see no differencesin options set in the different servers or between databases that workand this one. And dbcc checkdb runs clean.The compiled code that fails, fails across the board - not just on my(developer) PC. The same source code works on the same tables in otherdatabases, including the one we copied....The final kicker - if I build a SQL statement string and get therecordset instead, it works like a charm. But I have to fix about 20 VBfunctions and check that I do have a recordset and SET NOCOUNT ON in all20 sps.I feel this is either something so obvious I will kick myself or soserious Microsoft will be digging into it.Any ideas anyone??Sandie*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!

View 1 Replies View Related

OLEDB Command Parameter Type Is Different In Different Situations

Dec 3, 2007



Hi All,

I am using OLEDB Command transformation in a data flow to update the table. Find the columns for the table EMP as follows.


EmpID - int
EmpName - varchar(40)
EmpSal - float
Status - varchar(20)

I am using the following command to update the table.


Update EMP set status = 'Disabled' where EmpID = ? and EmpSal = ?


when I use the above condition the type of the second parameter is taking as "double precision float" as the incoming input column type is "double - precision float". This is fine.


But when I use the following condition the type of the param is taking as different one.

Update EMP set status = 'Disabled' where EmpID = ? and ( EmpSal + ? ) = 0


It is taking as "four byte signed integer" even though the incoming input column type is "double precision float" thus I am loosing the precision and getting error when the limit exeeds. If I use 0.0 then it is taking as "Numeric" type.


If I use convert function like (EmpSal + ? ) = Convert(float, 0) then it is taking as "double precision float".
Update EMP set status = 'Disabled' where EmpID = ? and ( EmpSal + ? ) = Convert(float, 0)


My question is how it behaves in the above situation. Can any body clarify please?

Venkat.

View 1 Replies View Related

Listbox Contents To Sql Stored Procedure Command Parameter?

Feb 11, 2004

Hello,

Stuck in a spot and hoping someone will nudge me in the right direction....

I'm trying to write to a sql db via a storedprocedure using a parameter. i'm pretty certain the below statement is causing the problem. but i'm not sure how to properly refer to it....


Dim connString As String
connString = "integrated security=false;user id=sa;server=HCENT1;database=LicenseRenewal;persist security info=False"
Dim myConnection As New SqlConnection(connString)
Dim myCommand As New SqlCommand("InsertPage1", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
' .......other (working) parameter statements.........
Dim parameterDates As New SqlParameter("@Dates", SqlDbType.VarChar, 4000)
parameterDates.Value = Session("lstDates")
myCommand.Parameters.Add(parameterDates)

myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()


the session("lstDates") is the contents of lstDates.Items (listbox) from a previous page.
i'm guessing its not valid to refer to it as a varchar, can someone point me to the proper way to handle this?

tia
andy

View 4 Replies View Related

Sql Command Oracle Oledb Connection - Parameter Issue

Jul 5, 2006

I need to extract rows using date as parameter... where source contains millions of rows but few thousands per date.

I tried using SQL command in data access mode in OLE DB Source Editor but having problem with passing parameter...

Anyone has solution?

View 10 Replies View Related

SQL Server 2008 :: File Formatting Export To Excel Using BCP Command

Aug 28, 2015

Declare@QRYvarchar(8000)
Select@QRY='bcp "Select COL1, COl2 From table(nolock)" queryout "D: est.xls" -c -T -S ' + convert(varchar(20), serverproperty('servername'))
Select@QRY
Execmaster..xp_cmdshell@qry

The file test.xls is getting generated but when opening getting the message

"File you are trying to open is in a different format than specified by the file extension"

Is there any property that can be set to avoid this message?

View 6 Replies View Related

SQLCMD - How Do I Pass Parameter At Dos Command Line To Input File?

Mar 23, 2007

I am not sure if this has been asked before but I couldn't find any thread talking about this.

Let's say we have a parameter in the .sql input file called @Start_Date, how can we pass the value of a particular date, for example, "02-28-2007" to @Start_Date via SQLCMD? is it possible?

I'm trying to skip the need to write a simple windows application...if things can be achieved via dos command line, that will keep everything simple!

thanks! :)

View 3 Replies View Related

Passing Parameter To OLE DB Command To Perform Update On Paradox Table

Aug 23, 2007



Dear All -
iam facing a problem for passing a parameter to update paradox table statment in the OLE DB Command

Briefly an OLE DB Command exist between OLE DB Source and OLE DB destination , all i want it to send the data that flow from the OLE DB Source to the update paradox table statment in OLE DB Command ,

i use the parameter annotation which is "?" to refer to the parameter in the update where clause and it sucess when i use the OLE DB Command to connect to SQL Server DB but when i use it with the Paradox Table an error appear saying that there is more than one data source column with the name "?" The data source column names must be unique.

i dont know what that means is it means that "?" it consider "?" as a column or what or is there another way to send parameter to Update statment for the paradox table differ from the SQL Server Update statment which is the "? "

i hope someone help me as soon as possible because i need it in work sOOon
Thanks,
Maylo

View 2 Replies View Related

Integration Services :: Using Database Name As Parameter In OLE DB Source Command Text?

Aug 6, 2015

I'm using following command to populate my OLE DB Source. I have two of those in each Data Flow in my package. One of the OLE DB Sources points to my source database the other to the destination. In order to limit the number of rows I use the WHERE clause below. The [EnergyMiserFSRLive] being the the name of the source database. The Connection manager points to the destination database.

I would like an elegant way to replace  [EnergyMiserFSRLive] with a parameter which I can reuse in each of my many data flows rather than use this hard coded value [EnergyMiserFSRLive].In particular I'm after the syntax of the below query that uses the parameter for [EnergyMiserFSRLive].

SELECT [SitesId]
      ,[SiteName]
      ,[FilePrefix]
      ,[City]
      ,[StateProv]
      ,[Country]
  FROM [Sites]
WHERE SitesId >= (SELECT MIN(SitesId) FROM [DBNameFSRLive].[dbo].[Sites])
  ORDER BY [SitesId]

View 5 Replies View Related

How To Script An Excel Datasource In Sql Job? (SSIS)The Command Line Parameters Are Invalid.

Dec 4, 2005

I have a Sql agent job which will exeute a SSIS package.  While, one of my data sources is an excel file. I scriptted the sql agent job and recreate on a test server, it fails with The command line parameters are invalid.. The command line has the following for the excel data source, and that is the place fails the job. /CONNECTION UserDataExcel;"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\myserverUserDataUserData.xls;Extended Properties=""EXCEL 8.0;HDR=YES"";" I guess it has something to do with the double-quote inside, Please advise.

View 1 Replies View Related

Integration Services :: Argument For Option (parameter) Is Not Valid - The Command Line Parameters Are Invalid

May 6, 2015

i am parameterize  my DB connection in sql sever 2012,it showing in agent job as parameter.but when i run job it giving me error:

Argument "" for option "parameter" is not valid.  The command line parameters are invalid.  The step failed.

what i need to do is pass different environment here while deploying to different env.

View 2 Replies View Related

SQL 2012 :: Run A Command To Send File To TSM Server

Oct 3, 2014

write a backup to local disk and then run a command to send the file to the TSM Server.This is the command I use at a Command Prompt to do an TSM incremental backup.

Command for an incremental backup of drive letter h:
C:Program FilesTivoliTSMaclientdsmc incremental h:

Command for an incremental backup of a mount point:
C:Program FilesTivoliTSMaclientdsmc incremental -domain="E:Backup"

I would like to be able to run this as the last step in my backup processes. This would allow me to send my local backup file to the TSM server to write to tape.

I am looking for either a CMDEXEC Expert that could show me the syntax to run these commands via a direct command or a batch job. The other option would be to run these commands via the Powershell type.

View 3 Replies View Related

SQL 2012 :: Powershell Command To Install Specific KB

Jul 1, 2015

My system is windows 2012 core, no gui installed..I need to install missing kb through powershell. Need the powershell command to install specific KB

View 1 Replies View Related

SQL Server 2012 :: Using Variables To Generate The Command?

Sep 17, 2015

I am trying to use variables to generate the command:

USE DATABASE
GO

Code below:

DECLARE @DBName_Schema varchar(500)
SET @DBName = 'Test'
EXEC ('USE ' + @DBName )
GO

It does not seem to be working.

View 5 Replies View Related

SQL 2012 :: Alter Database Set Partner Command Failed

Jun 23, 2014

Running this query in DR server to start SQL mirroring but encountered an error below.

Query:
use master
go
alter database test set partner= N'TCP://HOSTNAME.DOMAIN.GROUP.INTRANET:5023'
go

Error:
Msg 1452, Level 16, State 6, Line 2

The partner server instance name must be distinct from the server instance that manages the database. The ALTER DATABASE SET PARTNER command failed.

View 2 Replies View Related

SQL 2012 :: Restore Database Command - BufferCount Option?

Jul 22, 2014

What the BUFFERCOUNT option does in a RESTORE DATABASE command?

View 5 Replies View Related

SQL 2012 :: How To Obtain Feature List From The Command Line

Sep 18, 2014

Is there a command at the CLI or in PowerShell that will list the components installed for SQL? I'm looking for something like the Feature List you can get from running the discovery report from Tools in the SQL Server Installation Center program option.

I'm running SQL Server 2012 on the CORE version of Windows Server 2008 R2 Enterprise.

View 4 Replies View Related

SQL 2012 :: Command To Uninstall Node With Skip Validation?

Jun 25, 2015

what is the command to uninstall sql node with skip validation in sql 2012 ?

View 1 Replies View Related

SQL 2012 :: Way To Remove All Indexes From A Table With One Single Command

Sep 29, 2015

IS there a way to remove all indexes from a table with one single command ( without having to know what the index name is ) ;

View 2 Replies View Related

Possible To Send Parameter To Excel (via Web) To Pas Along Through To SQL Server?

Sep 14, 2004

Is there anyway to pass a parameter to an Excel spreadsheet (loaded in a browser) to use as a parameter in SQL statement?

I know that the Microsoft Technologies can write Excel files and then load them, but I'm looking to take an existing workbook, parameterize the SQL statement and pass parameters via the Querystring/Form Post to it.

Why you may ask? For existing PivotTables/Charts that can be filtered BEFORE they are run.

Any/all thoughts appreciated.

Bob

View 3 Replies View Related

Passing Excel File As A Parameter

Feb 24, 2008

All,

I am developing the SSIS pacakge. I am loading the data from excel file to Sqlserver table. I have two set of excel files and each excel file belongs to one division. I want the same mapping should call both file. Basically, i wanted to pass the filename as a parameter. Any help....

Regards
Govind

View 1 Replies View Related

Excel OmitFormulas DeviceInfo Parameter:

Jun 30, 2006

Is there a way I can set OmitFormulas DeviceInfo parameter to true for a whole site so that when a user exports the data to Excel, they only get the values?



Joe

View 4 Replies View Related







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