Need Help Mixing A Couple Of Queries Into One Quer

Jan 26, 2008

I want to create a filtered view according to some information provides.
for example I want to create in form 2 check boxes male and female and when either both or one of them is unchecked, the query filters out the unchecked content from view according to the other filtering conditions.

the exact thing I need is:
a text box for string looking (in a specific column).
male & female checkboxes.
two datetime textboxes to specify a range to focus in.

it is very important to me, so if you misunderstood my question, please contact me.

View 2 Replies


ADVERTISEMENT

PLEASE Help To Convert An Access Query To Sql Quer

Apr 2, 2008

Here is the access query

SELECT tbl1.evenID, Sum(IIf(IsNull([evpeDateCompleted]),0,1)) AS Completions, Count(tbl2.evpeID) AS Attendees, IIf(Count([evpeID])=0,"No Bookings",IIf(Count([evpeID])=Sum(IIf(IsNull([evpeDateCompleted]),0,1)),"Closed",IIf(Sum(IIf(IsNull([evpeDateCompleted]),0,1))>0,"Closing","In Progress"))) AS Status
FROM tbl1 LEFT JOIN tbl2 ON tbl1.evenID=tbl2.evpeEvenID
GROUP BY tbl1.evenID;

coding is my passion

View 2 Replies View Related

Converting Oracle Slq Quer To Sqlserver Query

Jan 14, 2001

Hi ,

I have a question for all , please help me out.

the question is : i have a query in Oracle like this
select count(*), to_char(ISL_FIRST_VISIT, 'Day, mm/dd/yyyy') from ISL_USERS
group by to_char(ISL_FIRST_VISIT, 'Day, mm/dd/yyyy')
order by to_char(ISL_FIRST_VISIT, 'Day, mm/dd/yyyy');

i want to convert this into SQLserver but in SQL server equlent function for TO_CHAR is Datename ..when i have given this i am getting error . please give me the tip on this issue .

thanks
shekhar

--------------------------------------------------------------------------------


|

View 1 Replies View Related

I NEED TO UPDATE THESES RECORDS BASED ON THIS QUER

Apr 25, 2007

I NEED TO UPDATE THESES RECORDS BASED ON THIS QUERY


select * from property where
Lis_key in(select lis_key from property where substring(func_key,1,5)='GEOSS'
And substring(func_key,6,8) >=3)and
Func_key = 'PV000000'
and substring(Attrib_code,5,2)!=16
AND ACTIVE = 1
order by Lis_key



HELP ME

View 4 Replies View Related

I Want To Restrict The My Clients To Access Database Through EnterPrise Manger Or Quer Analyser

Jul 20, 2005

Hello AllI am using SQL server 2000 as the backend of my application but don'twant my clients tobe able to view or edit the database tables, storedprocedures , view etc using enterprise manager or query analyser (orsimilar tools)How can this be done ?I searched a lot for this but unable to get the correct answer isthere anybody to give full solution regarding this.Please relpy me as early as possible

View 2 Replies View Related

Mixing Counts, Min Or Max ?

Nov 28, 2007

Hi I have this

select emailid,
count(emailid) as 'No.of occurences',

FROM tableA
where start_moment between '2007-11-01' and '2007-11-02'
GROUP BY emailid
having (COUNT(emailid) > 1)



Fair enough this returns the emailid along with the amount of times it appears (all greater then 1 .. duplicated in other words)

My question is , there is also a start_moment field in tableA
so i need to get the max or min start_moment along with the above result?

View 3 Replies View Related

Mixing Different Data Slices

Oct 30, 2007



My sales are broken into two different major categories: retail and internet. Rather than create two identical fact tables (ala AdventureworksDW) I created on fact table with a dimension that slices by retail or interent. I use that dimension as a parameter on nearly every one of my reports. The use can get retail, internet or both. So far, so good.

Now I need to create a report that shows retail sales and internet sales in adjacent columns on the same report. Is there a way to filter individual columns in a table? Or will I have to rethink how I store my data in the cube?

Thanks.

View 3 Replies View Related

Mixing INNER And OUTER Joins

Sep 26, 2006

I've encountered this problem multiple times in the past and I have a solution but wonder if there might be a more elegant method of achieving the same result...

Take the following example:SELECT * FROM [User]
LEFT OUTER JOIN [Profile] ON [Profile].[UserId] = [User].[UserId]
INNER JOIN [Department] ON [Department].[DepartmentId] = [Profile].[DepartmentId]

Users may or may not have a profile (but never more than one). A profile may or may not have a department (but never more than one).

Now, this will return only users that have a profile even though an outer join has been used. What I really want is to return all users and include their profile and department details but only when the profile has a department.

The solution I have used in the past is:

SELECT * FROM [User]
LEFT OUTER JOIN
(
SELECT *
FROM [Profile]
INNER JOIN [Department] ON [Department].[DepartmentId] = [Profile].[DepartmentId]
) [ProfileDepartment] ON [ProfileDepartment].[UserId] = [User].[UserId]

The trouble here is that I've lost the ability to reference department and profile independantly in the outer query. Also, more complex scenarios can also become horribly complex if this needs to be done multiple times in the same query.

I could do this:SELECT * FROM [User]
LEFT OUTER JOIN [Profile] ON [Profile].[UserId] = [User].[UserId] AND [Profile].[DepartmentId] IS NOT NULL
LEFT OUTER JOIN [Department] ON [Department].[DepartmentId] = [Profile].[DepartmentId]

But again I feel that the intention is not at all clear. I want to inner join department to profile because I'm only interested in profiles with a department and departments referenced by a profile.

I would like to be able to specify that the departments should be inner joined to profiles and whichever profiles remain get outer joined to users whilst retaining department and profile as seperate entities within the query.

Is there any way to use brackets to indicate an order of precedance to the logical joins within the from clause?

Daniel

View 3 Replies View Related

SQL Mixing Aggregate && Non-aggr Exprs

Jan 7, 2004

How do I create a query that emulates a mix of aggregate & ‘non-aggregate’ expressions. I am using the query as the rowsource for a list box in Access.

Here is my query:
strSql = "SELECT tblTestHeader.TestHdrUniq, tblTestHeader.TestDate, " _
& "'" & Forms("frmCompanySearch").[lstCompanySrch].Column(2) & "'" _
& " + ' ' + tblLoadCell.Abbrev + ' ' + tblTestHeader.CertNumSequence AS CertNum, " _
& "tblLoadCell.Description AS LoadCell, " _
& "tblTestType.Description AS Test, " _
& "tblTester.Sname + ', ' + tblTester.Gname AS Tester " _
& "FROM tblTestHeader INNER JOIN tblLoadCell ON " _
& "tblTestHeader.LoadCellUniq = tblLoadCell.LoadCellUniq INNER JOIN " _
& "tblTester ON " _
& "tblTestHeader.TesterUniq = tblTester.TesterUniq INNER JOIN " _
& "tblTestType ON " _
& "tblTestHeader.TestTypeUniq = tblTestType.TestTypeUniq " _
& "WHERE CompanyUniq = " _
& Forms("frmCompanySearch").[lstCompanySrch].Column(1) _
& " ORDER BY tblTestHeader.TestDate, CertNum"

I want to include another column:
max(tblTestDetail.CertChar) as LastChar
but must have all or no aggregate expr. What is work around for this ?

View 1 Replies View Related

Sp_trace_setfilter Mixing AND/OR Operators In Profiler

Jul 24, 2007

Hello, how do you setup a Profiler filter, that has mixed AND/OR operators. Thru the Profiler GUI, I don't even see how you would ask for any statement/proc with READS over 10,000 OR DURATION over 1000ms. How do you do an "OR" thru the GUI?



Forgetting the GUI and doing traces thru scripts, the @logical_operator isn't too logical, and I can't find any description for setting this parameter. If you only have one filter, it doesn't matter if you set it to 0 (AND) or to 1 (OR)... But if you want multiple filters, so one filter is Reads >= 10,000 and the other filter is Duration >= 1000ms., how do you do that? I tried it with the @logical_operator of "1" on both, but then I also got other events with a NULL value in READS.




Code Snippet

-- @traceID = 1
-- @columnID = 13 (Duration)
-- @logicalOperator = 1 (OR)
-- @comparison_operator = 4 (greater or equal)
-- @value = 1000000 (1000 ms)


sp_trace_setfilter 1, 13, 1, 4, 1000000


-- @traceID = 1
-- @columnID = 16 (Reads)
-- @logicalOperator = 1 (OR)
-- @comparison_operator = 4 (greater or equal)
-- @value = 10000 (# Reads)

sp_trace_setfilter 1, 16, 1, 4, 10000


Looks like DURATION is never NULL for these events>>>



RPC:Completed

SP:Completed

SPtmtCompleted

SQL:BatchCompleted

SQLtmtCompleted



but the READS value cane be null (for SP:Completed at least).



Any ideas on how to mix AND/OR operators in multiple filters of one trace?



Thanks, Bruce

View 1 Replies View Related

Update Command In SQL DateSource Mixing Up My Parameters

Dec 14, 2007

I have an update command with 7 parameters, but at run time the order to the parameters gets mixed up.
I'm using a stored procedure. At first I have the command type set to text, and was calling it using EXEC spName ?,?,?,?,?,?,?
I then named each of the parameters and set their sources.  The parameters are like this (samepl name, then source, then type):
A : QueryString - intB: Control - intC: Control - intD: None - intE: None - decimalF: Control - datetimeG: Control - datetime
At run time I was getting an error that an integer couldn't be converted to date time. So I put a breakpoint in the Updating event and then looked at the parameters prior to update.
This is how they looked (Parameter index, paramter name):
[0] A[1] B[2] D[3] E[4] F[5] G[6] C
It didn't maek any sense. Do, I deleted all of the paramters and readded them. That didnt' work. Then I changed the command to StoredProcedure and refreshed the parameters from the stored proc and it brought them in the right order, but the problem remains the same.
I looked at the page source, and there are no indexes in the page source, but the parameters are listed in the proper creation order, as follows:<UpdateParameters><asp:QueryStringParameter Type="Int32" Name="PROJ_ID" QueryStringField="pid"></asp:QueryStringParameter><asp:ControlParameter PropertyName="SelectedValue" Type="Int32" Name="TASK_UID" ControlID="fvTask"></asp:ControlParameter><asp:ControlParameter PropertyName="SelectedValue" Type="Int32" Name="ASSN_UID" ControlID="gvResources"></asp:ControlParameter><asp:Parameter Type="Int32" Name="RES_UID"></asp:Parameter><asp:Parameter Type="Double" Name="Work"></asp:Parameter><asp:ControlParameter PropertyName="Text" Type="DateTime" Name="Start" ControlID="TASK_START_DATETextBox"></asp:ControlParameter><asp:ControlParameter PropertyName="Text" Type="DateTime" Name="Finish" ControlID="TASK_FINISH_DATETextBox"></asp:ControlParameter></UpdateParameters>
No mater what I do, at run time ASSN_UID is always the last parameter. I've also run a SQL trace to see how it is actually being executed, and sure enough, its passing the value for ASSN_UID as the last parameter, which obviously doesn't work.
Any ideas as to why this would happen or how to fix it?
(I guess I can reorder the patameters in the stored proc to match how they are being passed, but still, that wouldn't be a very comfortable solution, since it could perhaps revert at some point or something)

View 2 Replies View Related

Using INSERT INTO Mixing SELECT And Static Text

Jan 26, 2008

 I'm trying to populate a table of pending emails. The problem is I need
to populate the email field using a select statement but the message
field with static text. Can this be done or is another approach more
prudent? What I have is below but is kicking errors:DECLARE @msg varchar(300) SET @msg = 'New users have applied for accounts. Please review their information.'IF @Type='CreateUserApply' INSERT INTO cdds_Email (Address,Message)VALUES (SELECT M.EmailFROMdbo.aspnet_Membership MINNER JOINdbo.aspnet_UsersInRoles UINNER JOINdbo.aspnet_Roles RON U.RoleId = R.RoleIdON U.UserId = M.UserIdWHERER.RoleName = 'Manager',@msg)

View 3 Replies View Related

Mixing Parameter Syntax In Execute SQL Task

Feb 5, 2006

Hi all,

As part of the logging process for data input, I want to update two fields in a logging table. The first is a datetime, derived from looking up the maximum value in another table (the table I've just imported), and the second is an integer - the number of rows captured in a variable during the task.

I can do this in two separate Execute SQL tasks as follows:

Task 1 syntax

DECLARE @maxDate datetime
SELECT @maxDate = max(dtLastChangedDate)
FROM dbo.tblCancel_RAW

UPDATE dbo.tblLogging
SET PreviousFilterValue = CurrentFilterValue,
CurrentFilterValue = ISNULL(CAST ( @maxdate as varchar(25)),CurrentFilterValue),
DateSourceTableLastRead = GetDate(),
RowsReturned= -1
WHERE SourceTableName = 'cancel'

Task 2 Syntax, with the variable user::rowsimported mapped to parameter 0

UPDATE dbo.tblLogging
SET
RowsReturned= ?
WHERE SourceTableName = 'cancel'

However I cannot make this work with a single SQL statement such as

DECLARE @maxDate datetime
SELECT @maxDate = max(dtLastChangedDate)
FROM dbo.tblCancel_RAW

UPDATE dbo.tblLogging
SET PreviousFilterValue = CurrentFilterValue,
CurrentFilterValue = ISNULL(CAST ( @maxdate as varchar(25)),CurrentFilterValue),
DateSourceTableLastRead = GetDate(),
RowsReturned= ?
WHERE SourceTableName = 'cancel'

because no matter how I try to map the parameter (0,1,2,3,4 etc) the task fails.

Is this behaviour by design, is it a bug, or is there something I've missed?

Thanks as ever,

Richard

View 1 Replies View Related

Couple Of Question About SQL 2000

Feb 17, 2004

Hi

I've bin using MySQL and now trying to convert it on to SQL 2000 and i've got a couple of questions


1. Ive got a SQL Script of a database generated by MySQL, can i run this script stright into SQL 2000 and if so how do i go about it ????

2. In my MySQL i have a Gender field which data type is Enum ('M','F'). How do i recreate this type of field in SQL 2000.

Thanks

View 3 Replies View Related

A Couple Of Easy Questions

Nov 23, 2006

Hi everyone,

Running Windows 2003 x64 and Sql25k 64-bit edition

We just have a couple of questions related with our system:

-What is Sql Server VSS Writer service for?

-What sort of implications must we assume when Integration Services service is running as NT AUTHORITYNetworkService

Any link or advice would be welcomed.

Thanks for your time,

View 3 Replies View Related

Just A Couple Quick Questions

Oct 9, 2006

I need to:



Copy an existing production database to a new database on the same server; this will be used for development.

Copy an existing table for backup purposes in preparation for deleting a couple fields from the table (precautionary process really).



I've been out of the database swing if you will for a while, just now getting the opportunity to get my feet wet so to speak. I can use either Enterprise Manager or connec to the database via ODBC and make the copies/deletes there, but I'm looking to do this via EM or SQL command.

Any help or direction would be greatly appreciated!

Thanks!

Bobby

View 3 Replies View Related

A Couple Of Things With My New Report

May 11, 2007

I have made a report in SRS and am not sure of how to do some of the functions I need.

In SQL I can use UPPER to convert to upper case, SRS doesn't seem to like this. The report runs but the line that is to be upper case is missing. If I remove the UPPER word from my query it works fine just displaying in lower case. Am I doing something wrong?

In Excel 2007 (I am converting my report from Excel to SRS) there is a function called NETWORKDAYS (Returns the number of whole working days between start_date and end_date. Working days exclude weekends and any dates identified in holidays. Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days worked during a specific term.) Is there something similar I can use in SRS?


Thanks.

View 3 Replies View Related

Select Just A Couple Of Rows Into Gridview

May 7, 2008

 I am using a sqlDataSource to read my query and to put the rows into a gridview. Now I want to read just a couple of rows from my query based on a maximum number, also defined in the table. I have absolutely no idea how to do that..for example: I want to view  only the 10 most recent subsciptions into my gridview. The subscriptions are stored into tabel Subscriptions which has values id, userid,date. Table Event has a parameter "maximum subscriptions" (which is 10 in my example) I hope it is clear enough?Thank you in advance!BlueiVeinz 

View 2 Replies View Related

A Couple Of SQL Server Express Questions

Apr 11, 2006

Hello - I'm about to rebuild my website on a nice new windows 2k3 server. I was previously using SQL server 7 but I'd like to use the 2005 edition.
Here's my first question - is the Express edition 2005 good enough to use on my live web server? Are there limits on the amount of connections at any one time?
My second question is this - what's the best way to connect to SQL Server 2005 Express?
At the moment I would use something like:
Server=.SQLEXPRESS;Integrated Security=True;Database=myDB
And then I would set up a COMPUTERNAMEASPNET account under SQL Server 2005 Express.
Is that an ok way to connect??
Any ideas?
Thanks.

View 1 Replies View Related

Couple Of Basic SSIS Questions

Dec 4, 2007

Hello all, this is my first post, I have a couple of basic questions regarding the use of SSIS. I have used SSIS for a couple of years for on off table loads but never implemented production jobs with it so please bear with these questions.

1. When making scripts that connect to one or more databases, is there a way to store the userid and password somewhere besides embedded within the package, such as a web.config file, this would make routine password changes much more manageble.

I guess it was only one question but any help would be greatly appreciated.

Thanks.

View 1 Replies View Related

Couple Of Easy Questions, Newbie Here

Jul 20, 2007

I am using Merge Replication for my scenario (POS). I have made the publication (articles are a set of tables in DB ABC) and its subscription (in same DB and diff tables xyz1, xyz2). I have scheduled the push subscription as run continuously between Dates(e.g current date to 3 days ahead, just for testing). Now, Can I change this schedule? How can I edit/remove the artilce from the above publication?

View 1 Replies View Related

A Couple Of Quesitons Regarding SQL 2005 Express

Apr 28, 2008



Hello, I'm a little confused after installing a service pack for SQL 2005 Express. I see SP 1 & 2 for 2005 but I can't see where the SP stands alone for Express. The title says Express 2005 Service Pack 2. Does that mean that I download that version of Express and SP2 is already built in and I just load the new one over the old one or do I uninstall the old one first? I'm not real bold at this point since it took me a long time to get the Express working.

Another question - I downloaded the DTSWizard.exe 2006 msi package and installed it on my XP Pro machine. The add/remove programs window shows it to be installed but it doesn't show up in the folder it is supposed too. I've done searches for the DTSWizard.exe but it's not there, anywhere. Any ideas what I may be doing wrong? I was able to get the DTSWizard to work on my 2000 Pro machine before going to XP Pro this past week. Thanks for any help you may be able to give me.
Riley

View 6 Replies View Related

Analysis :: SSAS Tabular - Dynamic Security Roles - Mixing Together DAX Filters

Oct 10, 2015

I have two different roles, each one with a dax filter. One is for filtering users that access by Excel, and other for filtering users that access by Reporting Services, respectively:

=CONTAINS(FILTER(V_FILTRO_C;V_FILTRO_C[IDPerfilGrupo]<>7);V_FILTRO_C[iCursoCod];[SK_CURSO];V_D05_DIM_UTIL[DSC_LOGIN_USER];RIGHT(USERNAME();LEN(USERNAME())-SEARCH("";USERNAME())))
=CONTAINS(FILTER(V_FILTRO_C;V_FILTRO_C[IDPerfilGrupo]<>7);V_FILTRO_C[iCursoCod];[SK_CURSO];V_FILTRO_C[IDUtilizador];VALUE(CUSTOMDATA()))

To create only one role that serves Excel and Reporting Services users, is it viable to use only the || (OR) operator?, is there any other regard i should take?

View 2 Replies View Related

Reporting Services - A Couple General Questions

Mar 14, 2008

A couple questions about SQL Server Reporting Services:
 1. Can it be used for other data sources besides SQL Server (Oracle db, XML files, via APIs, etc.)?
2. Can it do ad hoc reporting? I like the "universes" that the SAP Business Objects product allows. Does Reporting Services have something like this, to provide a simplified view that non-technical business users can use to create their own reports? Or is Reporting Services just the equivalent to Crystal Reports?
 
(I wanted to post this in the general MSDN forum for SQL Server, but I can never log in there for some reason.)

View 3 Replies View Related

Couple Of Questions Regarding Building Packages Programatically

Jul 12, 2006

Hi,

I'm trying to build a package programatically.



I've added a variable to my package but how do you specify its datatype? Is it purely determined by the type of the value that you pass in the Variables.Add(...) method?
I've added task and a sequence container to my package - no problem there. My sequence container is referenced in a variable of type DTSContainer but DTSContainer doesn't have an executables collection. So, how do I add a task into my sequence container?

Thanks

Jamie

View 4 Replies View Related

Can't Connect To DB When SqlServer Exp Has Been Idle For A Couple Hours.

Mar 13, 2008

Does SQLServer go to sleep when it's been idle? How can I connect without an error?

I have SQLExpress on a server. Server Name is SqlExpress. I have 2 DBs on that server... Tuna & Guppy. I'm connecting to the DBs from a remote PC which runs my App... an exe created with Visual Studio 2008, Visual Basic.

If I run my App at say 9:30PM, after the server has been idle for several hours, I get a "Can't open connection to Guppy" error, which is my error message when the connection attempt fails. If I quit & relaunch the app, it connects fine, and will continue connecting fine unless you leave the server idle for serveral hours again.

If I'm developing a 2nd app all evening... which connects to a 2nd DB...Tuna, that activity seems to keep the SqlServer awake and then launching the 1st app at 9:30PM connects to Guppy just fine.

I tried adding a "Connection Timeout=30" to my connection string but that did not help.

My connection code is as follows (note the server's name is SQLExpress):

Dim strConnG As String = "Data Source=SQLEXPRESSSQLEXPRESS;Initial Catalog=Guppy;Integrated Security=True;Connection Timeout=30"
Using ConnG As New SqlConnection(strConnG)
'open Guppy connection
Try
ConnG.Open()
Catch ex As Exception
MsgBox("Can't open connection to guppy")
Return False
End Try
'Code that does stuff
End using


Can anyone tell me how to fix this so I can connect without error, even if the server has been idle?

Thank you,

Joe A

View 6 Replies View Related

A Couple Of, I Hope Basic Questions RE SqlDataSource's And Scripting

Jan 9, 2007

Greetings!
 I am writing a proof of concept ASP.net application for my employer and I have run into a couple perplexing issues.  First off, In my Page_Load event I have the following code.
txOTHrs.Attributes["onBlur"] = "return calculateTotal(this)";
The onblur event handler is coded as follows
function calculateTotal(tb)
{
    var regHrs = document.getElementById ("txRegHrs").value;
    var otHrs = document.getElementById("txOtHrs").value;
    var rate = document.getElementById("txRate").value;
    var regAmt = rate * regHrs;
    var otAmt= rate * ( otHrs * 1.5 );
    var total = otAmt + regAmt;
    document.getElementById("txTotal").value = total;
}
Everything seems to work fine. The onBlur event is handled and, as I expect the value in the txTotal text box is updated correctly.  The problem occurs when I try to access that value in the codebehind page. When ever I look at txTotal.Text in the debugger it is always blank. This has left me scratching my head as I can clearly see a value on the web page. Have I missed some step where I have to notify the server that a value in the control has changed ?
 
My second question is, I hope a very easy one to answer.  In WinForms when I have a dataset I can access the individual rows ( in an untyped dataset ) by speficying dataset.tables["tableName"].Rows[index]. Is there any similar mechanism for accessing the individual rows, and fields in the SqlDataSource object in ASP.net ?
 
Any help anyone can provide is greatly appreciated!!

View 2 Replies View Related

A Couple Of Questions On Remote Connection To SQL Server 2005 Database

Nov 23, 2006

I have a SQL Server 2005 database (called BDHSE) in a PC which i call PC1. I have a second PC (PC2) and both are within a network (a WLAN).

What i want is to have access to BDHSE from an application in VB6 (APP1) running in PC2. All the INSERT, DELETE, UPDATE records process is done through APP1.

APP1 ia currently running in PC1 and is to be installed on PC2.

I have these questions:

1. What do i need to install in PC2 since all the INSERT, DELETE, and UPDATE is done using APP1? I guess i only have to install the Microsoft SQL Native Client (with all the prerequisites of course) but i am not sure.

2. In the APP1 made in VB6, do i have to change the connectionstring since i am accesing the database which physically is at PC1 and the APP1 will be used in PC2?

3. Any advice you can give me on doing this will be well received.

Thanks in advance,

BSc Fernando Martinez

View 4 Replies View Related

Mixing Dynamic SQL With Non-Dynamic In Stored Proc

Mar 24, 2007

I have a Stored Procedure for processing a Bill of Material.

One column on the Assembly Table is a Function Name that contains some busniess rules.

OK, now I'm doing a Proof of Concept and I'm stumped.

Huuuuh!

I will ultimately have about 100 of these things. My plan was using Dynamic SQL to go execute the function.

Note: The function just returns a bit.

So; here's what I had in mind ...

if isnull(@FnNameYN,'') <> ''
exec spinb_CheckYN @FnNameYN, @InvLineID, @FnBit = @FnBit output




CREATE PROCEDURE dbo.spinb_CheckYN
@FnNameYN varchar(50),
@InvLineID int,
@FnBit bit output
AS

declare @SQL varchar(8000)

set @SQL = '
if dbo.' + @FnNameYN + ' (' + convert(varchar(31),@InvLineID) + ')) = 1
set @FnBit = 1
else
set @FnBit = 0'

exec (@SQL)
GO



Obviously; @FnBit is not defined in @SQL so that execution will not work.
Server: Msg 137, Level 15, State 1, Line 4
Must declare the variable '@FnBit'.
Server: Msg 137, Level 15, State 1, Line 5
Must declare the variable '@FnBit'.


So; is there a way to get a value out of a Dynamic SQL piece of code and get that value INTO my OUTPUT variable?


My many thanks to anyone who can solve this riddle for me.
Thank You!


Sigh: For now, it looks like I'll have a huge string of "IF" statements for each business rule function, as follows:
Hopefully a better solution comes to light.

------ Vertical Build1 - Std Vanes -----------
if @FnNameYN = 'fnb_YN_B1_14'
BEGIN
if dbo.fnb_YN_B1_14 (convert(varchar(31),@InvLineID) ) = 1
set @FnBit = 1
else
set @FnBit = 0
END

------ Vertical Build1 - Scissor Vanes -----------
if @FnNameYN = 'fnb_YN_B1_15'
BEGIN
if dbo.fnb_YN_B1_15 (convert(varchar(31),@InvLineID) ) = 1
set @FnBit = 1
else
set @FnBit = 0
END
.
.
.
etc.

View 10 Replies View Related

Using A Excel Source To Get The Data From An Excel File Gets Null Values For A Couple Columns

Nov 19, 2007

I am using a Excel Source to get the data from an excel file to sql server 2005 table. A couple columns are coming in a double precision float, but some values have characters in them, but those values are coming out as null, even though I changed the datatype from float to unicode string. Any inputs on resolving this will be much appreciated.

Thanks,
Manisha

View 4 Replies View Related

Parameterized Queries Running Slower Than Non-parameterized Queries

Jul 20, 2005

HelloWhen I use a PreparedStatement (in jdbc) with the following query:SELECT store_groups_idFROM store_groupsWHERE store_groups_id IS NOT NULLAND type = ?ORDER BY group_nameIt takes a significantly longer time to run (the time it takes forexecuteQuery() to return ) than if I useSELECT store_groups_idFROM store_groupsWHERE store_groups_id IS NOT NULLAND type = 'M'ORDER BY group_nameAfter tracing the problem down, it appears that this is not preciselya java issue, but rather has to do with the underlying cost of runningparameterized queries.When I open up MS Enterprise Manager and type the same query in - italso takes far longer for the parameterized query to run when I usethe version of the query with bind (?) parameters.This only happens when the table in question is large - I am seeingthis behaviour for a table with > 1,000,000 records. It doesn't makesense to me why a parameterized query would run SLOWER than acompletely ad-hoc query when it is supposed to be more efficient.Furthermore, if one were to say that the reason for this behaviour isthat the query is first getting compliled and then the parameters aregetting sent over - thus resulting in a longer percieved executiontime - I would respond that if this were the case then A) it shouldn'tbe any different if it were run against a large or small table B) thisperformance hit should only be experienced the first time that thequery is run C) the performance hit should only be 2x the time for thenon-parameterized query takes to run - the difference in response timeis more like 4-10 times the time it takes for the non parameterizedversion to run!!!Is this a sql-server specific problem or something that would pertainto other databases as well? I there something about the coorect use ofbind parameters that I overall don't understand?If I can provide some hints in Java then this would be great..otherwise, do I need to turn/off certain settings on the databaseitself?If nothing else works, I will have to either find or write a wrapperaround the Statement object that acts like a prepared statement but inreality sends regular Statement objects to the JDBC driver. I wouldthen put some inteligence in the database layer for deciding whetherto use this special -hack- object or a regular prepared statementdepending on the expected overhead. (Obviously this logic would onlybe written in once place.. etc.. IoC.. ) HOWEVER, I would desperatelywant to avoid doing this.Please help :)

View 1 Replies View Related

How To Run Queries???

Aug 9, 2006

Hi,
I am using visual web developer2005 express edition and finding hard time to get my query run in this i am making my own login page as i have few more things to ask to user before they get logged in so i am not using the login control.   
i want to write my own query without help of sqlDataSource control from start something like
sqldatasource con=new sqldatasource;
con.connection String=""
then what all things will come........ ???
and please give me some poitners to some articles which help one to do the requested.
 
Regards,
 
 

View 1 Replies View Related

Is It Possible To Put Several Queries Into One Sp

Dec 7, 2007

 I have an update query which either inserts a row or increases quantity, depending if row exists or not. It works, better than my explanation probably.After that query could be a good time to count total of all calculated sub sums.Something like this.  previous queryEND goSELECT SUM(SubTotal)FROM dbo.t_Shoppings I have tried this on the tool which has a long name, but I think my way didn't work. (Microsoft sql server management studio express)Is this possible or do I have make and call another stored procedure.I can send my sp if someone wants. 

View 4 Replies View Related







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