Correct Syntax For ADO.net Recordset's Select Method.

Feb 17, 2006

I have a interger stored in x.

I want to use x in a SELECT statement like so :

SELECT * from aTable WHERE A_Column = x

This select statement is then assigned to and passed as a string like :

sql = "SELECT * from aTable WHERE A_Column = x"

How does the x get interpreted correctly ?

View 1 Replies


ADVERTISEMENT

Correct Syntax For This Select In SQL Server?

Jun 22, 2007

This (demo) statement is fine in Access, and so far as I can see, shouldbe OK in SQL Server.But Enterprise Manager barfs at the final bracket. Can anyone helpplease?select sum(field1) as sum1, sum(field2) as sum2 from(SELECT * from test where id < 3unionSELECT * from test where id 2)In fact, I can reduce it to :-select * from(SELECT * from test)with the same effect - clearly I just need telling :-)cheers,Jim--Jima Yorkshire polymoth

View 4 Replies View Related

Incorrect Syntax Near The Keyword CONVERT When The Syntax Is Correct - Why?

May 20, 2008

Why does the following call to a stored procedure get me this error:


Msg 156, Level 15, State 1, Line 1

Incorrect syntax near the keyword 'CONVERT'.




Code Snippet

EXECUTE OpenInvoiceItemSP_RAM CONVERT(DATETIME,'01-01-2008'), CONVERT(DATETIME,'04/30/2008') , 1,'81350'




The stored procedure accepts two datetime parameters, followed by an INT and a varchar(10) in that order.

I can't find anything wrong in the syntax for CONVERT or any nearby items.


Help me please. Thank you.

View 7 Replies View Related

Plz, What Is The Most Correct Method

Jul 20, 2005

Hi,Given 2 tables:Table1:id Auto,int,PrimKeytable2id inttxt nvarchar50Table2:id Auto,int,PrimKeyorder intThe scenario: Table2.order defines how the table1.txt is should be ordered.Table1.table2id contains the id of the order. This cannot be changed :(How do I select all Table1.txt values but ordered by their correspondingvalues of the table2.order field?--Thx,PipHans---Outgoing mail is certified Virus Free.Checked by AVG anti-virus system (http://www.grisoft.com).Version: 6.0.516 / Virus Database: 313 - Release Date: 01-09-2003

View 7 Replies View Related

ADO Recordset's Object Method Open

Jul 20, 2005

Hello group!I use MS Visual C++ 6.0, ADO, MS SQL Server 2000.When I attempt to open my database I meet with a following problem:when I try to get a bookmark of the current record in a Recordsetobject a following run-time error occurs: Unhandled exception intestdb.exe(KERNEL32.DLL):0xE06D7363: Microsoft C++ Exception.I created my database by 3 SQL commands:create database testdbcreate table testtable(i int)insert into testtable values(0)The error occurs in the following code snippet:#import "D:Program FilesCommon FilesSystemADOmsado15.dll" no_namespace rename("EOF", "EndOfFile")int main(){CoInitialize(NULL);bstr_t strCnn("Provider=sqloledb;Data Source=;""Initial Catalog=testdb;Trusted_Connection=YES;");const char* tablename = "testtable";_RecordsetPtr recs;recs.CreateInstance(__uuidof(Recordset) );recs -> Open(tablename, strCnn, adOpenStatic,adLockOptimistic,adCmdTable);_variant_t bm = recs -> Bookmark; // the error occurs hererecs -> Close();CoUninitialize();}During the debugging this code I met that the error depended on a typeof locking. When I set adLockBatchOptimistic or adLockOptimisticor adLockPessimistic the error occurs but when I set adLockReadOnly oradLockUnspecified it doesn't occur. By the way this error doesn'toccur whenI open Pubs database with any type of locking. What is a cause of thiserror?Thank you.

View 1 Replies View Related

Timeout For Recordset.Requery Method

Jun 8, 2007

I have an application coded in C++ using ADO. It has a very simple Recordset that opens a table and gets only one record without any filtering. The CommandTimeout is set to 600 (seconds). Once a while I get a timeout error generated by Requery() that puzzles me. I cannot imagine how Requery (i.e. close the Recordset and open it to get only one record in my case) can take 600 seconds.



Any clue would be greatly appreciated.

View 1 Replies View Related

VB6 Recordset Update Method Fails On SQL 2005 Server

Jan 13, 2008

Hi to all....

I'm new on this forum, but, I'm a experienced programmer.
I wanna solve this problem (if you can helpme....), recently, I'm trying to migrate an old SQL 7 to the new SQL 2005 server enterprise edition, I have no problem to import the data, users, stored procedures, etc. and all work fine, I can connect troght ODBC from the others computers, including some older pentium 1 mmx 200 mhz. with WIN98 (yes!).

My problem is an legacy VB6 application that work (well fine) with SQL7 server, but, when i change the odbc of the desktops systems to the new 2005 SQL server and run this legacy application hi recibe this error:
(english translation from spanish language)

[ODBC SQL Server Driver][SQL Server] The table to be modified is not included on this cursor or these can't be modified throught this cursor.

I have look on the source code of the legacy application, and someone of the segment's that causes error is:

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


Public Function ConsultaCamara(sRutOP As String, _
sRut1 As String, _
strConsulta As String, _
Tipo As String, _
chk As CheckBox, _
Timer1 As Timer, _
LbAviso As Label) As Long
'----------------------------
Dim rsCACH, rsCACH_upd0, rsCACH_upd1, rsCACH_upd2 As ADODB.Recordset
Dim CmCACH As ADODB.Command
Dim lPendiente As Boolean
Dim lActivo As Boolean
Dim strSQL1, strSQL_upd0, strSQL_upd1, strSQL_upd2 As String
Dim StrWHE As String
Dim DameTiempo As Integer
Dim snombre As String
Dim sMsgEstado As String
Dim sAviso_Inicial As String
Dim cNum As String
Dim cDig As String
...
...
...
'Defino el string de consulta
strSQL1 = " SELECT RUTOPERADOR, " & _
" IDCAMARA, " & _
" RUTCONSULTADO, " & _
" ESTADO, " & _
" CANCON, " & _
" CADENACONSULTA, " & _
" FINGRESO, " & _
" FULCONSINT, " & _
" ULTRUTOP " & _
" FROM BOLETIN " & _
" WHERE RUTCONSULTADO = '" & sRut1 & "'" & _
" AND (ESTADO = 'PE' OR ESTADO = 'AC' )"

Set rsCACH = CreateObject("ADODB.Recordset")
rsCACH.ActiveConnection = cn
rsCACH.CursorType = adOpenKeyset
rsCACH.LockType = adLockOptimistic
rsCACH.Open strSQL1
If rsCACH.EOF Then 'No hay registro antiguo o en consulta, creo uno para consultar
sMsgEstado = "NO Existen datos ES REGISTRO NUEVO" & vbCr
rsCACH.AddNew
ConsultaCamara = GeneraID()
rsCACH.Fields("IDCAMARA") = ConsultaCamara
rsCACH.Fields("RUTOPERADOR") = sRutOP
rsCACH.Fields("RUTCONSULTADO") = sRut1
rsCACH.Fields("ESTADO") = "PE"
rsCACH.Fields("CANCON") = 1
rsCACH.Fields("CADENACONSULTA") = strConsulta
rsCACH.Fields("FINGRESO") = GetDateTime() 'Format(Date, "Short Date")
rsCACH.Fields("FULCONSINT") = GetDateTime() 'Format(Date, "Short Date")
rsCACH.Fields("ULTRUTOP") = sRutOP
rsCACH.Update <----- here's launches the error
...
...
...

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

As you see, I'm not english spokeman, I hope that you understand me.

Thanks and best regards.

View 3 Replies View Related

Correct Syntax

Sep 25, 2006

HelloI have having trouble displaying some simple columns in ascending order.I know that the database is populated and I can get the more complex code to work if I display like this: SELECT FName, LName, Town, '<a href="' + url + '">' + Site + '</a>' as LinkFROM Names_DBWHERE FName = 'Tom' And url like 'http:%'ORDER BY LName ASCBut I need a simpler view but I can't get it to workI  have tried this:SELECT FName, LNameFROM Names_DBORDER BY  LName ASCAnd thisSELECT FName, LNameFROM Names_DBORDER BY  LName ASC; And This:SELECT FName, LNameFROM Names_DBORDER BY  LName 'ASC' What is wrong with this syntax?ThanksLynn

View 2 Replies View Related

What Is The Correct Syntax For Anything

Mar 15, 2007

I have a query and I need to check to see if a field is occupied, i.e., it can have anything in it, i just want to see if something is there... this is what I want, but of course, anything isn't the right word here...

and (r.id = 'anything')

View 7 Replies View Related

Correct Syntax

Feb 25, 2008

Hi.

This is a Stored proc I am working on
I dont know much about stored procs.
This is what I am trying to achieve
The proc takes two input parameter and returns one outparameter.

This is what I have

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[GetNextAction]

(
@Code char(10),
@Track varchar(30),
@NextAction ntext output
)
AS
BEGIN

SET NOCOUNT ON;
Declare @ID int;
@ID = Select Sequence from [dbo].[Track] where Code=@Code;
Declare @nextCode varchar;
@nextCode= Select Code from [dbo].[Track] where sequence =(@ID+1);
@NextAction= Select nextAction from [dbo].[CaseStage] where Code=@nextCode;
return @NextAction;


END
GO

I guess you can understand what I am trying in the proc but the rules and syntax are wrong. Please help me with this.
Thanks

View 4 Replies View Related

Please Correct Syntax

Dec 3, 2006



hi there

RS2005 - Layout tab

I have a field that says

txtTrackerTrue=Sum(Iif ((Fields!Tracker.Value = Fields!RecvdBy.Value), 1,0 ))

I want another field that says

txtAllTrue=Sum(Iif ((Fields!Tracker.Value, ClosedBy.Value = Fields!RecvdBy, 1,0 ))

obviously this is going to error

how would I do this please

thanks

View 19 Replies View Related

What Is Correct Syntax

Oct 19, 2007

select CONVERT(VARCHAR, stdate, 'YYYY') startyear
from tbl_emp


i want output : 2007



How can i get?

View 5 Replies View Related

Correct InsertParameters Syntax

Jan 29, 2008

If someone can show me the correct syntax for the right side of the code below, I'd appreciate it.
srcMoreInfo.InsertParameters("Address").DefaultValue =       DirectCast(cuwMoreInfo.FindControl("txtAddress"), TextBox).Text 

View 11 Replies View Related

Is Syntax Is Correct ? URGENT

Jun 21, 2000

CREATE PROCEDURE test1
@spname nvarchar(20),
@tblname nvarchar(50)
AS

declare @sqlrun varchar(8000)

set @sqlrun = "CREATE PROCEDURE @sp_name AS CREATE TABLE @tblname
(MsdsId [nvarchar] (5),
IngredId [nvarchar] (2),
Agency [nvarchar] (10),
AgencyText [nvarchar] (4) ,
nName [nvarchar] (40))"

eXEC sp_ExecuteSql @sqlrun

WHATS WRONG IN THIS CODE ?
---------------------------------
PS: I'm getting this error:
-------------------------------

Server: Msg 214, Level 16, State 2, Procedure sp_executesql, Line 7
Cannot convert parameter '@statement' to ntext/nchar/nvarchar data type expected by procedure.

View 2 Replies View Related

SYNTAX Help, Correct Way To Use LIKE In Statement

Feb 27, 2007

Hi, I'm new to SQL and was wondering if there was an easier way to filter data.

I have two tables -

The first table called Names of Companies has a column named: NAMES

NAMES
XYZ Company
ABC Limited Liability Company
ZZZ Corporation
KKK Inc.
ABC Inc.

The second table called Keywords has a column named: WORDS

WORDS
Company
Limited


I want to search for all NAMES that contain the WORDS in some form

The results should be:

NAMES
XYZ Company
ABC Limited Liability Company

Technically, I can get the results I want by manually typing into the SQL statement all the words that appear in the WORDS column.

SELECT *
FROM [Names of Companies]
WHERE [Names of Companies].Names Like "*Company*" Or ([Names of Companies].Names) Like "*limited*"));

But is there a way that I reference the table Keyword instead of typing into the query statement all the words that appear in the column WORD? I have a lot of words to search for.

Can anyone recommend a better way to do this?

Thanks for all your help!

View 8 Replies View Related

Correct Syntax For Dtsrun

May 18, 2006

Somehow I'm not getting dtsrun to work.

The server is local

The name of the package is ImportHosttrncs. It is saved under Local Packages.

There is no password.

Is this syntax correct?

dtsrun /Slocalhost /PImportHosttrncs

View 1 Replies View Related

Correct Syntax For IF EXISTS

Apr 11, 2008

What is the correct syntax for dropping a column if it exists?

Cant seem to get it to work. This is SQL 2005 if it makes a difference.





ALTER TABLE Reports_PI_Recent

IF EXISTS (DROP COLUMN RollingAverage )

View 3 Replies View Related

Correct Syntax For Parameters When Creating SQL Job

Dec 30, 2007

I'm trying to create a SQL job in SQL Server and am a little unclear about the formatting.Here's a snippet from the stored procedure that creates the job:CREATE PROCEDURE [dbo].[spArchive]     @DB            varchar(30),    @Date        DateTimeAS EXEC msdb.dbo.sp_add_jobstep @job_name = 'ArchiveIncentives'     , @step_id = 1    , @step_name = 'ArchiveAHD'    , @subsystem = 'TSQL'    , @command = 'spArchiveAHD ''@Date'''    , @on_success_action = 3     , @on_fail_action = 2     , @database_name = '@DB'     , @retry_attempts = 1   In this case, the job will be calling this stored procedure:CREATE PROCEDURE [dbo].[spArchiveAHD] (    @dtArchiveBefore DateTime)AS I'm unclear about these lines:    @command = 'spArchiveAHD ''@Date'''    @database_name = '@DB'   Do they look correct to you or should I drop some/all of the apostrophes?Robert W. 

View 5 Replies View Related

Is There Any Correct Syntax For ParameterDirection.Input ?

Apr 3, 2008

 I try to call the storeproc to perform task by allowing only input 6 of length. The syntax over here might not be relevant, im seeking for correct syntax.
 webform
Dim connString2 As String = _ConfigurationManager.ConnectionStrings("Local_LAConnectionString1").ConnectionString Using myConnection2 As New SqlConnection(connString2)
Dim test01 As IntegerDim myPuzzleCmd2 As New SqlCommand("GetRandomCode", myConnection2)
myPuzzleCmd2.CommandType = CommandType.StoredProcedure
Dim retLengthParam As New SqlParameter("@Length", SqlDbType.TinyInt, , 6)                 < --------   allow 6 letters in length to be input   
retLengthParam.Direction = ParameterDirection.InputmyPuzzleCmd2.Parameters.Add(retLengthParam) Dim retRandomCode As New SqlParameter("@RandomCode", SqlDbType.VarChar, 30)
retRandomCode.Direction = ParameterDirection.Output
myPuzzleCmd2.Parameters.Add(retRandomCode)
TryDim reader2 As SqlDataReader = myPuzzleCmd2.ExecuteReader()
myPuzzleCmd2.ExecuteNonQuery()
Catch ex As Exception Response.Write("sp value : " & retRandomCode.Value)
Dim iRandomCode(1) As StringReDim Preserve iRandomCode(1)
iRandomCode(1) = Convert.ToString(retRandomCode.Value)myPuzzleCmd2 = Nothing
Session.Remove("RandomCode") HttpContext.Current.Session("RandomCode") = iRandomCode(1) Response.Write(Session("RandomCode"))
Finally
myConnection2.Close()
End Try
End Using
 
StoredProcedure ALTER PROC [dbo].[GetRandomCode]
@Length TINYINT,
@RandomCode VARCHAR(30) OUTPUT
ASDECLARE
@Chars2BUsed VARCHAR(30),
@LookAt TINYINT,
@iCnt INT,
@CharFound CHAR(1)
 
SELECT @Chars2BUsed ='ABCDEFGHJKLMNPQRTUVWXYZ2346789'
SELECT @RandomCode = ''SELECT @iCnt = 1 WHILE @iCnt<=@Length
BEGINSELECT @LookAt = FLOOR((RAND()*LEN(@Chars2BUsed))) + 1
SELECT @CharFound = SUBSTRING(@Chars2BUsed, @LookAt, 1)IF CHARINDEX(@CharFound, @RandomCode)=0
BEGINSELECT @RandomCode = @RandomCode + @CharFound
SELECT @Chars2BUsed = REPLACE(@Chars2BUsed, @CharFound, '')SELECT @iCnt = @iCnt + 1
END
END

View 2 Replies View Related

Can You Please Correct My Syntax For If Statement In Stored Proc

Nov 23, 2004

I am using @strsql to construct the where condition for a select query.
Can you please correct my syntax.



DECLARE @strsql nvarchar(2000)


IF @ProgNO <> '' then
strsql = WHERE ProgNO = @ProgNO
end if



If @ProjNO <> '' then
if strsql <> '' then
strsql = strsql & " and ProjNO =@ProjNO
ELSE
strsql = wHERE ProjNO =@ProjNO
END IF
END IF



Thank you very much.

View 9 Replies View Related

Correct Syntax For An Update Stored Procedure

Nov 24, 2005

This is probably a very simple question but i would appreciate some helpwith the correct syntax for and update stored procedureI  have created  user form that allows the user to update the name and address fields in a datatable called  customers based on the input value customer ID =  ( datatable/Customers)customerIDI have got this far and then got lost:Create SP_UpdateCustomer(@customerID, @name, @address)As Update customers ( name, address)Where customerID =  @customerID GOCould anyone tell me what the correct sntax should be.many thanksMartin

View 3 Replies View Related

Correct Syntax Using Variables Inside SQL Queries (SqlCommand)

Mar 30, 2008

I have a test page where I'm using SqlConnection and SqlCommand to update a simple database table (decrease a number).
I'm trying to figure out how to make a number in the database table to decrease by 1 each time a button is being pressed. I know how to update the number by whatever I want to, but I have no idea what the correct syntax is for putting variables inside the query etc. Like "count -1" for instance.
The database table is called "friday" and the one and only column is called "Tickets".
Here's the code behind the button:protected void Button1_Click(object sender, EventArgs e)
{SqlConnection conn;
conn = new SqlConnection("Data Source=***;Initial Catalog=***;Persist Security Info=True;User ID=***;Password=***");
conn.Open();int count = -1;
 SqlCommand cmd = new SqlCommand("select Tickets from friday", conn);
count = (int)cmd.ExecuteScalar();if (count > 0)
{
 string updateString = @"
update friday
set Tickets = 500" ;   <------ Here I want to set Tickets like "current count -1"SqlCommand cmd2 = new SqlCommand(updateString);
cmd2.Connection = conn;
cmd2.ExecuteNonQuery();
}
else
{
}
conn.Close();
}

View 3 Replies View Related

Correct Syntax For Query Using Osql.exe In MSDE Setup

Nov 10, 2003

I have the following .bat file that I call to register users to my MSDE instance...

echo osql -E -S %COMPUTERNAME%OfficiumInstance -Q "sp_grantlogin '" + %COMPUTERNAME% + "ASPNET'"
echo osql -E -S %COMPUTERNAME%OfficiumInstance -d Officium -Q "sp_grantdbaccess '" + %COMPUTERNAME% + "ASPNET'"
echo osql -E -S %COMPUTERNAME%OfficiumInstance -d Officium -Q "sp_addrolemember 'db_owner', '" + %COMPUTERNAME% + "ASPNET'"

My question is how do I correctly append %COMPUTERNAME% as a string to

I have tried using + signs...

"sp_grantlogin '" + %COMPUTERNAME% + "ASPNET'"

But that doesn't work.
I have looked for .bat file tutorials on the web but can't find the correct way to do this.

Greg

View 1 Replies View Related

Integration Services :: Correct Syntax To Access A Variable

Sep 30, 2015

I am having trouble finding the correct syntax to access a variable. I have a variable defined in the Variables window: The variable name is formatedDate. The DataType is String.

I am successfully setting the value of the variable in a Execute SQL Task. The SQL is as follows:

SELECT LEFT(CONVERT(VARCHAR, MAX(ReportDate), 120), 10) as formatedDate
from DimReportDates

The Result Set is set to “Single Row” and properly set up. 

No problem so far. I can see with a watch that the variable has the correct value, something like:

‘2015-09-30’

Now, in a subsequent step, a Data Flow Task, I want to access the variable. Actualy it is in the SQL statement of a OLE DB source in the Data Flow… I have the following:

Declare @sDate smalldatetime
SELECT @sDate = xxxxx

I have tried several things substituting xxxxx above, but nothing seems to work. One variation was

 @[User::formatedDate])

 Another was

((DT_WSTR, 10) @[User::formatedDate]).

I think I’m close, but just can’t get it. What is the correct syntax.

View 4 Replies View Related

Seeking Correct Syntax To Pass A NULL Value For A Datetime Field From An Asp Page To SQL

Jan 13, 2006

Hello,I've been searching the web for quite some time to resolve the problemof "1/1/1900" returning in a datetime field in SQL that resulted from ablank (not NULL) value being passed to it through an ASP page.The solution is that a NULL value needs to passed to SQL from ASP.Thats fine...I understand the why the problem is happening and thesolution around it. HOWEVER, I can't seem to get the proper syntax towork in the ASP page. It seems no matter what I try the "1/1/1900"still results. Below are a few variations of the code that I havetried, with the key part being the first section. Does anyone have anysuggestions?!?!?______________cDateClosed = ""If(Request.Form("dateClosed")= "") ThencDateClosed = (NULL)end ifsql="UPDATE rfa SET "&_"dateClosed='"& cDateClosed &"', "&_"where rfaId='"& Request.Form("RFAID")&"'"_____________________________cDateClosed = ""If(Request.Form("dateClosed") <> "") ThencDateClosed = (NULL)end ifsql="UPDATE rfa SET "&_"dateClosed='"& cDateClosed &"', "&_"where rfaId='"& Request.Form("RFAID")&"'"_____________________________cDateClosed = ""If(Request.Form("dateClosed")= "") ThencDateClosed = NULLend ifsql="UPDATE rfa SET "&_"dateClosed='"& cDateClosed &"', "&_"where rfaId='"& Request.Form("RFAID")&"'"_______________Thanks in advance!!!!

View 7 Replies View Related

Correct Syntax To Pull Back Duplicate Vendors Based On 6 Fields From Two Different Tables

Feb 20, 2015

I'm looking for the correct syntax to pull back duplicate vendors based on 6 fields from two different tables. I want to actually see the duplicate vendor information (not just a count). I am able to pull this for one of the tables, something like below:

select *
from VendTable1 a
join ( select firstname, lastname
from VendTable1
group by firstname, lastname
having count(*) > 1 ) b
on a.firstname = b.firstname
and a.lastname = b.lastname

I'm running into issues when trying to add the other table with the 4 other fields.

View 5 Replies View Related

How To Get Recordset From Only Last SELECT Stmt Executed???

Feb 14, 2005

How to get recordset from only last SELECT stmt executed???

this is part of my code.. in T-Sql


Create proc some mySp
...
AS
...
set nocount on
if (@SelUserID is null)
select 0
else if (@SelUserID = @userID)

select 1

else
begin

select * -- select a.
from dms_prsn_trx_log
where @incNo = ult_incid_no and
prsn_trx_no = 10 and
trx_log_txt = @logText
if (@@rowcount != 0)
set @isForwardedByUser = 1
select 2 -- select b. I NEED This value.

end
set nocount off
GO

here it executes select a, b.
But, I want mySp return last executed select result. which is here "select 2"

I thought set nocount ON does that, but it doesn't.
How can I do???

View 2 Replies View Related

How To Make A Correct Select

May 24, 2006

Could anyone help med with a select statement with a join between totables. It is to be used in a OLAP cube.I Havde table LedgerBudget and Table Admin. In table admin I can setupa from and to date and also a budgetmodel.The admin have ONE record per OLAP cube.The statement below works fine if I have stated a budgetmodel in tableAdmin.But if no budetmodel stated in table Admin, I want the statement toselect every ledgerbudget with active = 1 and allocatemethod = 0Could anyone help me with this.SELECT LTRIM(dbo.LEDGERBUDGET.ACCOUNTNUM) AS ACCOUNT_ID,dbo.LEDGERBUDGET.STARTDATE AS TRANSDATE, - dbo.LEDGERBUDGET.AMOUNT ASBUDGETFROM dbo.LEDGERBUDGET INNER JOINdbo.ADMIN ON dbo.LEDGERBUDGET.STARTDATE >=dbo.ADMIN.FROMDATE ANDdbo.LEDGERBUDGET.STARTDATE <= dbo.ADMIN.TODATEANDdbo.LEDGERBUDGET.MODELNUM =dbo.ADMIN.BUDGETMODELIDWHERE (dbo.LEDGERBUDGET.ACTIVE = 1) AND(dbo.LEDGERBUDGET.ALLOCATEMETHOD = 0)BR/Thanks

View 6 Replies View Related

Could I Use SQL Select Case .. When... In ADODB.Recordset().open

Jul 20, 2005

Is there any SQL Error?Or I have to use Select case in VB code to control SQL instead.Thank you for any ans.Nuno

View 4 Replies View Related

SELECT Top. Which Method Is Best?

Jul 20, 2005

HiSQL Server 7.0 using stored procedures.I need to do a SELECT Top but I always need to find the record countfor the entire SELECT statement.ID Name-- ----1 Abraham20 Barrington32 Callaway54 Dennis58 EmmettIf I do a SELECT TOP 3, I'll get the required records but get arecordcount of 3.I cant use the ROWCOUNT method either becuase the recordcount willalso be 3.I can see two different options for getting back the information Ineed:1 - Run the select statement twice, first to retrieve the recordcountand then with top to get the recordset2 - Use a temp table to get the entire recordset and recordcount, andthen extract the Top N recordsI'd like to know if anyone has any other suggestions. Currently, I'mtempted to go for the second option....ThanksSam

View 5 Replies View Related

Is There A Method To Convert Select * From Table To Select Field1,field2,...fieldn From Table ?

Nov 29, 2007

Is there a method to convert "Select * From Table" to "Select field1,field2,...fieldn From Table" ?
 
Thanks

View 1 Replies View Related

Use Select Method Of SqlDatasource

Dec 1, 2005

hiplz can any one tellHow should i use select method of SqlDatasourceplz show little code toothanks

View 1 Replies View Related

Which Method For SELECT Is Prefered?

Nov 19, 2007

Hi guys,

I'm just curious if there is a prefered method when it comes to SELECT statements that include multiple tables. I have two versions:

SELECT FirstName, LastName, ProductName, SalePrice
FROM SALES, PRODUCTS, CUSTOMERS
WHERE MONTH(SaleDate) = '2'
AND YEAR(SaleDate) = '2005'
AND SALES.ProductID = PRODUCTS.ProductID
AND SALES.CustomerID = CUSTOMERS.CustomerID;


SELECT FirstName, LastName, ProductName, SalePrice
FROM CUSTOMERS
INNER JOIN SALES ON CUSTOMERS.CustomerID = SALES.CustomerID
INNER JOIN PRODUCTS ON PRODUCTS.ProductID = SALES.ProductID
WHERE MONTH(SaleDate) = '2'
AND YEAR(SaleDate) = '2005';

Could you tell me if either of these methods are favored over the other or if there is another way of producing the same output that is used over both these methods.

Thank you in advance

Butterfly82

View 4 Replies View Related







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