Retrieve Id After Adding A New Record

May 13, 2005

How do I retrieve the id of the record after I INSERT it?

View 4 Replies


ADVERTISEMENT

Adding To Outputs Together To Retrieve The Top(10) - Is It Possible??

Sep 24, 2007

Hi There,

I have been struggling day and night with the creation of a store procedure due to not being able to retieve the rows I need for SUM and AVG functions.

I have two tables ('actions' & 'incident_types') which both have a score value for each record. In my database, I have reports that contain both action codes and incident_type codes based on a personnel_code.

In simple terms I'm trying to do the following:-
For all reports, find each personnel member and thier attached incident_types and action codes and then, for each score from the actions and incident_types tables, create the SUM of the 'combined' scores.

I have successfully retrieved the output for the scores individually but I need the TOP(10) of the combined output.....

I'm currently using to seperate queries as follows :--


--This gives me the incident type output...... Creating the 'Volume' column which is the total Score for incidetn_types
SELECT Top (@Number) Personnel_details.personnel_code, Personnel_details.personnel_forename, Personnel_details.personnel_Surname, sum(incident_types.type_score) as 'Volume', avg(incident_types.type_score) as 'Average' INTO 'Incident_Scores' from Report_header

JOIN incident_types on incident_types.type_code = report_header.report_incident_Code

JOIN report_basedon on report_basedon.report_code = report_header.report_code

JOIN personnel_details on personnel_details.personnel_code = report_basedon.personnel_code

WHERE (report_header.report_date >= @fromDate and report_header.report_date <= @toDate)

AND (report_header.report_time >= @fromTime and report_header.report_time <= @toTime)

AND report_basedon.personnel_code <> 0

AND report_header.record_status=@recordStatus

group by Personnel_details.personnel_code, Personnel_details.personnel_forename, Personnel_details.personnel_Surname



-- I then use the following to get the total of all action scores, again in the 'Volume' column
SELECT Top (@Number) Personnel_details.personnel_code, Personnel_details.personnel_forename, Personnel_details.personnel_Surname, sum(actions.action_score) as 'Volume', AVG(actions.action_score) as 'Average' from profile

JOIN actions on actions.action_code = profile.action_code

JOIN report_header on report_header.report_code = profile.incident_ID

JOIN personnel_details on personnel_details.personnel_code = profile.personnel_code

WHERE (report_header.report_date >= @fromDate and report_header.report_date <= @toDate)

AND (report_header.report_time >= @fromTime and report_header.report_time <= @toTime)

AND personnel_details.personnel_code <> 0

AND report_header.record_status=@recordStatus

AND profile.record_status=@recordStatus

group by Personnel_details.personnel_code, Personnel_details.personnel_forename, Personnel_details.personnel_Surname

So my question is - How can I get the sum(incident_types.type_score) + sum(actions.action_score) and then get the TOP(10) rows?


Is it possible to output these 2 result to a new table and then join the new tables?

Thanks for any assistance, this is really draining me at the moment..... :-/

View 8 Replies View Related

How Can I Retrieve Nth Record Only?

Jul 6, 2001

Could you help me out?

I am interested in retrieving certain record among outputs.

For example, if I use the following sql,

select * from info order by name asc
====================================

then I can retrieve 25 rows from info table.

What I want to do is that I want to retrieve 15th record only among possible 25 records.

How can I solve this problem?

Thanks in advance.

View 2 Replies View Related

How To Retrieve One Record

May 23, 2006

I have a question, one user made mistake that she delete one record from a database. How can i retrieve this only one record. I just know how to restore the database.

Thanks.

View 3 Replies View Related

How To Retrieve MAX Record

Jul 9, 2013

I have retrieved the data using CTE . But still need the retrieve the latest row number record from my result.

;with cte as
(
Select ROW_NUMBER() over ( PARTITION by [T7S1_PRODUCT_CDE_original],[T7S1_BR_NO_original] order by [sql_updated] ) rn , [sql_updated]
,[T7S1_TYP_CDE]
,[T7S1_PRODUCT_CDE_original]
,[T7S1_BR_NO_original] from [interface_i084].[dbo].[tb_i084_ds_CeresTLStageFileDocDetail](nolock)
)
Select * from cte

My Query result:

rnsql_updatedT7S1_TYP_CDET7S1_PRODUCT_CDE_originalT7S1_BR_NO_original
12012-06-26 00:17:32.007703A0200030OOO 00066
22012-06-27 12:30:21.803703A0200030OOO 00066
32012-07-13 01:15:36.073703A0200030OOO 00066
12012-06-27 12:45:30.653703A0200030OOO 00083
12012-06-25 07:45:33.907703A0200030OOO 00090
22012-08-16 12:45:22.227703A0200030OOO 00090

Now Expecting:

rnsql_updatedT7S1_TYP_CDET7S1_PRODUCT_CDE_originalT7S1_BR_NO_original
32012-07-13 01:15:36.073703A0200030OOO 00066
12012-06-27 12:45:30.653703A0200030OOO 00083
22012-08-16 12:45:22.227703A0200030OOO 00090

I want to retrieve the MAX rn record..

View 1 Replies View Related

Retrieve The Record.

Nov 9, 2006

I'm trying to compare the fields if they are equal, retrieve it.
Because null <> null.
i cant retrieve the record. Is there anyway to retrive the records by comparing all the fields?

declare @table table(
ad_num int null,
ad_str1 varchar(50) null,
ad_num_suffix_a varchar (10) null,
ad_num_suffix_b varchar (10) null,
ad_unit varchar(10) null,

ad_num_test int null,
ad_str1_test varchar(50) null,
ad_num_suffix_a_test varchar (10) null,
ad_num_suffix_b_test varchar (10) null,
ad_unit_test varchar(10) null,
passed bit)

insert @table (ad_str1, ad_str1_test)
select 'apple road orad RD' , 'apple road orad RD'

select ad_num , ad_num_test,
ad_str1 , ad_str1_test,
ad_num_suffix_a , ad_num_suffix_a_test ,
ad_num_suffix_b , ad_num_suffix_b_test ,
ad_unit , ad_unit_test,
passed from @table

select * from @table
where ad_num = ad_num_test
and ad_str1 = ad_str1_test ad_num_suffix_a = ad_num_suffix_a_test
and ad_num_suffix_b = ad_num_suffix_b_test
and ad_unit = ad_unit_test

View 2 Replies View Related

How To Retrieve Last Updated Record

Dec 11, 2006

I have some set of records in my table.
The same set of records will be updated often. Now I have a column as "lastupdated"
While i am displaying the records in a datagrid, The LAST UPDATED record should only be displayed.
Means, the recently updated records should be displayed in datagrid.
Pls give me the sql code / i am also in need of a Stored procedure for this.
 I am working in SQL 2005

View 2 Replies View Related

Retrieve The ID Of The Record Just Added

Dec 12, 2003

I would like to retreive the identity field value of a record that was just added to the table.

In other words, I have a form and on submission, if it is a new record, I would like to know the identity value that the SQL Server has assigned it.

This may be overkill, but here is my code to process the form:

Protected Sub processForm(ByVal thisID As String, ByVal myAction As String)
Dim sqlConn As New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
sqlConn.Open()
Dim sql As String
Select Case myAction
Case "save"
If thisID > 0 Then
sql = "update INCIDENT set " & _
"RegionID = @RegionID, " & _
"DistrictID = @DistrictID, " & _
"DateReported = @DateReported, " & _
..CODE...
"WHERE IncidentID = " & myIncidentID
Else
sql = "insert into INCIDENT(" & _
"RegionID, " & _
"DistrictID, " & _
"DateReported, " & _
...CODE...
") " & _
"values(" & _
"@RegionID, " & _
"@DistrictID, " & _
"@DateReported, " & _
...CODE...
")"
End If
Case "delete"
sql = "delete from INCIDENT where IncidentID = " & myIncidentID
Case Else
End Select

Dim sqlComm As New SqlCommand(sql, sqlConn)
sqlComm.Parameters.Add(New SqlParameter("@RegionID", SqlDbType.NVarChar))
sqlComm.Parameters.Add(New SqlParameter("@DistrictID", SqlDbType.NVarChar))
sqlComm.Parameters.Add(New SqlParameter("@DateReported", SqlDbType.NVarChar))
...CODE...

sqlComm.Parameters.Item("@RegionID").Value = ddRegionID.SelectedValue
sqlComm.Parameters.Item("@DistrictID").Value = ddDistrictID.SelectedValue
sqlComm.Parameters.Item("@DateReported").Value = db.handleDate(txtDateReported.SelectedDate)
...CODE...

Dim myError As Int16 = sqlComm.ExecuteNonQuery
'Response.Redirect("incident.aspx?id=" & )
End Sub

The response.redirect at the end of the sub is where I would like to put the identity field value.

View 6 Replies View Related

How Can I Retrieve The Id Of A New Record Before Update

Oct 14, 2001

Can anyone help with an effective way in retriving the id of the new record before input of any data into a form. We have a form where a few of the controls recordsource requires the new record id before they will display correctly. I have tried various ways to trigger the form afterupdate event in the hope that the id will be returned but get the error message "The data will be added to the database but the data won't be displayed in the form because it doesn't satisfy the criteria in the underlying recordsource"

Thanks in advance

View 1 Replies View Related

How To Retrieve Last Record In A Table

Aug 19, 2013

I have a bulk of employee records, i want to retrieve 1st record and last record in employee table how to retrieve the record

View 14 Replies View Related

Retrieve The Last Record Of A Table

Jul 10, 2007

Hi!
I needto find the last record that has been inserted on a table.
If I perform a SELCT * FROM mytable , will I receive the data based on the inserted order (natural order)? In that case i'll simply need to check the last record of the results I got in my application to find the last inserted one?
(no I am not looking for an identity number ^^)

thank you

View 6 Replies View Related

How Do I Retrieve A Record By Primary Key?

Sep 29, 2006

Visual Basic 2005 Express:

I want to retrieve an SQL DataBase table record whose primary key is 4.

How do I read in that record and how do I pick up data from it?

View 6 Replies View Related

Retrieve 1st And Last Record Of Each Customer

Oct 15, 2007

I have to retrieve first and last record of each customer according to the Date. Each customer has 10 - 15 records in the table and there are 3000 customers.
how can I retrieve this data.

regards

View 7 Replies View Related

Retrieve Record From Database Problem

Sep 21, 2006

i m using sql server 2000 with asp.net with c#

i hv 4 customer records in the customer table starting from C1001 to C1004, i wanna ask is that when a new record is add to the table, the record will be placed at the bottom of the table. For example,
CustomerID






Customer ID

C1001

C1002

C1003

C1004

C1005


When i add a new record which is C1005, is it the record will be placed as shown in the table?


if so, that's mean can straight away use the datarow to retrieve the largest number which is C1005, right??? Thx 

View 1 Replies View Related

Retrieve Last Inserted Or Updated Record

Nov 22, 2007

Hi
I have an application which get any change from database using sql dependency. When a record is inserted or updated it will fire an event and my application get that event and perform required operation.
On the event handler I am usin select ID,Name from my [table];
this will return all record from database.
I just want to get the record which is inserted or updated.
Can u help me in that.
Take care
Bye

View 4 Replies View Related

How To Retrieve Identity Of Just Inserted Record???

Jan 30, 2008

Ok I've been researching this for a day now and I'm not coming up with much. I want to store the auto-incrementing ID of the last inserted record in a session variable, so that I may put it in a foreign key column in another table, if the user wishes to fill out a form on another page. I think my stored procedure is correct. But don't know what code to add to my aspx page. Any help will be greatly appreciated.
 
Here is my VB ScriptProtected Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
 
 
 
Dim personalContactDataSource As New SqlDataSource()personalContactDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("DataConnectionString1").ToString()
 
 
personalContactDataSource.InsertCommandType = SqlDataSourceCommandType.StoredProcedure
personalContactDataSource.InsertCommand = "PersonalContactInsert"
 
 personalContactDataSource.InsertParameters.Add("FirstName", FirstName.Text)
personalContactDataSource.InsertParameters.Add("LastName", LastName.Text)personalContactDataSource.InsertParameters.Add("KeyPerson", KeyPerson.Checked)
personalContactDataSource.InsertParameters.Add("DayPhone", DayPhone.Text)personalContactDataSource.InsertParameters.Add("EveningPhone", EveningPhone.Text)
personalContactDataSource.InsertParameters.Add("Fax", Fax.Text)personalContactDataSource.InsertParameters.Add("Email", Email.Text)
personalContactDataSource.InsertParameters.Add("HomeAddress", HomeAddress.Text)personalContactDataSource.InsertParameters.Add("City", City.Text)
personalContactDataSource.InsertParameters.Add("State", State.Text)personalContactDataSource.InsertParameters.Add("Zip", Zip.Text)
personalContactDataSource.InsertParameters.Add("ReqEffectDate", ReqEffectDate.Text)personalContactDataSource.InsertParameters.Add("MRID", MRID.Text)
personalContactDataSource.InsertParameters.Add("CurrentPremium", CurrentPremium.Text)personalContactDataSource.InsertParameters.Add("CurrentCarrier", CurrentCarrier.Text)
personalContactDataSource.InsertParameters.Add("CurrentDeductible", CurrentDeductible.Text)personalContactDataSource.InsertParameters.Add("CurrentCoins", CurrentCoins.Text)personalContactDataSource.InsertParameters.Add("ReasonForQuote", ReasonForQuote.Text)
 
 
End Sub
 
 
And here is my Stored ProcALTER PROCEDURE dbo.PersonalContactInsert

@FirstName varchar(30),@LastName varchar(30),
@DayPhone varchar(14),@EveningPhone varchar(14),
@Fax varchar(14),@Email varchar(60),
@HomeAddress varchar(80),@City varchar(30),
@State char(2),@Zip char(5),
@KeyPerson bit,@ReqEffectDate smalldatetime,
@CurrentCarrier varchar(30),@CurrentPremium smallmoney,
@CurrentDeductible smallmoney,@CurrentCoins smallmoney,
@ReasonForQuote varchar(150),@MRID int,
@ClientNumber int OUT
 
AS
 
INSERT INTO PersonalContact(FirstName, LastName, DayPhone, EveningPhone, Fax, Email, HomeAddress, City, State, Zip, KeyPerson, ReqEffectDate, CurrentCarrier, CurrentPremium, CurrentDeductible, CurrentCoins, ReasonForQuote, MRID, DateTimeStamp)
VALUES(@FirstName,@LastName,@DayPhone,@EveningPhone,@Fax,@Email,@HomeAddress,@City,@State,@Zip,@KeyPerson,@ReqEffectDate,@CurrentCarrier,@CurrentPremium,@CurrentDeductible,@CurrentCoins,@ReasonForQuote,@MRID, GetDate())
SET @ClientNumber = SCOPE_IDENTITY()
RETURN
 

View 8 Replies View Related

Hard Task To Retrieve A Value From A Record?!

Feb 12, 2008

Hi!I'm desperating here!!! Two questions:1º  Is line 13 realy selecting all the records with the username samurai (in this case)?!2º How do I fill the Boolean SeExiste var with a value from the record?1 Dim UserIDParameters As New Parameter
2
3 UserIDParameters.Name = "ProdUserID"
4
5 UserIDParameters.DefaultValue = "samurai"
6
7 Dim LoginSource As New SqlDataSource()
8
9 LoginSource.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString1").ToString()
10
11 LoginSource.SelectCommandType = SqlDataSourceCommandType.Text
12
13 LoginSource.SelectCommand = "SELECT FROM aspnet_Users (FirstTime) VALUES (@UserIDParameters) "
14
15 Dim SeExiste As Boolean
16
17 SeExiste = LoginSource.SelectParameters("FirstTime").DefaultValue
 I'm a newbye and despite this simple thing that in normal ASP is very easy to do!!! Please help me!Thanks in advance!  

View 4 Replies View Related

Retrieve The GUID For Inserted Record

May 2, 2006

I am using this code to insert a record in my table where i have assigned a guid datatype field to generate an automatic guid for each record. but now i need to retrieve the guid to use it to send a confirmation email to the user.
 
SqlConnection sql_connection = new SqlConnection("Server=xxx.xxx.xx.xxx;uid=xxxxxxxx;password=xxxxxxx;database=xxxxxxx;");SqlCommand sql_command = new SqlCommand("INSERT INTO members (member_sex, member_cpr, member_nationality, member_block, member_gov, member_daaera, member_email, member_mobile, member_created_ip) Values (@member_sex, @member_cpr, @member_nationality, @member_block, @member_gov, @member_daaera, @member_email, @member_mobile, @member_created_ip)", sql_connection);
sql_command.Parameters.Add(new SqlParameter("@member_sex", Session["member_sex"].ToString()));sql_command.Parameters.Add(new SqlParameter("@member_cpr", Session["member_cpr"]));sql_command.Parameters.Add(new SqlParameter("@member_nationality", Session["member_nationality"].ToString()));sql_command.Parameters.Add(new SqlParameter("@member_block", Session["member_block"].ToString()));sql_command.Parameters.Add(new SqlParameter("@member_gov", "GOV"));sql_command.Parameters.Add(new SqlParameter("@member_daaera", 6));sql_command.Parameters.Add(new SqlParameter("@member_email", Session["member_email"].ToString().ToLower()));sql_command.Parameters.Add(new SqlParameter("@member_mobile", Session["member_mobile"].ToString()));sql_command.Parameters.Add(new SqlParameter("@member_created_ip", Request.UserHostAddress.ToString()));
sql_connection.Open();sql_command.ExecuteNonQuery();sql_connection.Close();
 

View 1 Replies View Related

Retrieve Last Record For Each Month Between Two Dates

Oct 10, 2013

I need to retrieve the last record for each month between two given dates from a unique table that contains on record per day.

View 3 Replies View Related

Retrieve Identity Key Of Record Just Inserted?

Aug 21, 2014

Best way to retrieve the identity key of the record just inserted?This question is for discussion purposes; the business process that spurred the question is currently working.Using SQL Server 2008 R2, a record is inserted from a stored procedure. Let's say the sp has something like this:

Code:
BEGIN
BEGIN TRANSACTION
INSERT INTO tblTools
([Desc],CreateDate,Model,CreatedBy,Notes)

[code]....

In Access, when you add a new record to the recordset, the identity field comes "pre-populated" making it east to get the actual, correct identity value assigned to the record you are inserting. In SQL Server, I know options include:

Code:
IDENT_CURRENT('tblX')
SCOPE_IDENTITY
@@IDENTITY
among other methods.

Each has pros and cons, such as user privileges (IDENT_CURRENT requires the user to have Select privileges on the table, and catches records created by other things, such as users and triggers), and the other two give you the last key inserted and don't allow specifying the object (which is a problem if the insert added records to multiple tables, or you have multiple inserts).

View 2 Replies View Related

Retrieve When All Values In Group Have Same Record

Feb 25, 2015

Here is some sample data:

CREATE TABLE
#MyTable
(
Pk INT,
GroupID INT,
Value VARCHAR(10)

[code]...

I am looking to retrieve any GroupID in which every Value of that GroupID is either (a) null, (b) an empty string, or (c) "XYZ". So in the above example, GroupID #1 would not be returned in my query because there is a Value of "ABC", but GroupID #2 would be returned since it consists of only nulls, "XYZ"'s, and empty strings.What would be the most efficient way to write such a query?

View 2 Replies View Related

How To Retrieve Deleted Record In Table?

Feb 20, 2008



Hi,

i have deleted 5 to 10 records in a table. is there any way to retrieve the deleted records?

please help me in this regards.

Thanks in Advance.

M.ArulMani

View 9 Replies View Related

Retrieve Good Records From A Bad Record Table

May 17, 2006

I have a situation where I need a table if bad items to match to. Forexample, The main table may be as:Table Main:fd_Id INT IDENTITY (1, 1)fd_Type VARCHAR(100)Table Matcher:fd_SubType VARCHAR(20)Table Main might have a records like:1 | "This is some full amount of text"2 | "Here is half amount of text"3 | "Some more with a catch word"Table Matcher:"full""catch"I need to only get the records from the main table that do not haveanything in the match table. This should return only record 2.

View 1 Replies View Related

How To: Retrieve A Limited Number Of Records From A Record Set

Apr 24, 2008

I€™m working on a database project that will ultimately contain millions of records for each lot. In addition, each lot will have up to 96 corresponding serial number records.

I would like to add a SQL parameter that would tell the database engine to only return X number of records.

For Example:
If table TBL_LOTS contains one million records I would like to limit the return set to 100 for example.

What would I need to add to the SQL command to below to restrict the data set to the first 100 records in the set of one million?

SELECT [LOT NUMBER]
FROM TBL_LOTS
WHERE [STATMENTS]

View 3 Replies View Related

SQL Server Everywhere - Retrieve Identity Column After Insert Record

Jun 23, 2006

Hello

Using Visual Studio 2005 Prof and SQL Server everywhere.

How do get the identity column value after insert record.

With SQL Server 2005, its quite easy to get by creating and insert statement on the tabledapter ( Insert statement followed by a select statement where identitycolumn = scope_identity())



How do this is sql everywhere??



regards

View 1 Replies View Related

Adding A Value &#043; 1 To A Record

Nov 29, 2007

Hello

I wish to add some records to my database but I am having problems asking the SQL commands to add 1 to the previous number.

I'll explain what I mean....!

The database automatically increases the communication_number once each time a record is added. However I'd like to amend the command below to say "add 1 to the current communcation_number" rather than input a number manually as I have done below:-

insert into "communications"
(address_number, contact_number, device, ex_directory, dialling_code, std_code, number, extension, notes, amended_by, amended_on, cli_number, communication_number)
values (105, NULL, 'WW', 'N', NULL, 'WW', 'W', NULL, 'www.abc.co.uk', 'Jon', 2007-11-29, NULL, '30001');

Any help would be much appreciated.

Thanks,

Jon

View 10 Replies View Related

Transact SQL :: Retrieve Latest Record Of Serial Number With Multiple Entries

Sep 30, 2015

I work for an organization that repairs serialized devices. Each time a device is repaired it's serial number is recorded in a database table along with the date it was repaired along with other information about the device. There are multiple cases where a unit has been repaired more than once.

I am trying to write a query that will return the serial only once and that record will be the record of the latest repair date. To sum it up,

Return a list of serials where if a serial exists more than once in the table, return only the instance of the serial record(s) with the max(created_dt). The end result will be a list of distinct serial numbers.

Here is my Query. The problem I believe is in my sub-query but I am not sure how to structure it.

SELECT
S.Id
, RMA
, PinSerial
, L4Serial
, L4Model

[Code] ....

View 3 Replies View Related

Problem With Adding Record Into Database

Feb 3, 2004

When I try to build my solution, it tells me that "SQLCommand" is not defined.

What's the problem?

Sub submitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
'If Page.IsValid Then
Try
Dim MySQL = "addCustomerSQL"
Dim cmd As New SQLCommand("addCustomerSQL", dbConn)
cmd.Commandtype() = CommandType.StoredProcedure
cmd.Parameters().Item("@username").Value = userText.Text
cmd.Parameters.Item("@password").Value = passText.Text
dbConn.Open()
cmd.ExecuteNonQuery()
dbConn.Close()


Catch ex As Exception

End Try
End Sub

View 5 Replies View Related

Adding Record To Multiple Categories

Jun 16, 2006

I am pretty new to the DB part of this but have built an asp.net web appplication with 2 tables:
FORMS and UNITS
I have created a web page that will allow users to add forms and associate a unit with that form. I now need to be able to allow users to associate the form with multiple units.
I can change the web page list box to allow multiple selections but that doesn't solve the problem. This seems like a pretty simple task but I can't seem to find anything on it.
any help???
below is the stored procedure I was using:
CREATE PROCEDURE dbo.USP_AddForm

@UNIT_IDint,
@F_TYPE varchar(20),
@Titlevarchar(100),
@Keywords ntext = NULL,
@Descriptionntext = NULL,
@FileNamevarchar(50)


AS
BEGIN

SET NOCOUNT ON
DECLARE @NewFOrmID INT
INSERT FORMS

(
UNIT_ID,
F_TYPE,
Title,
Keywords,
Description,
FileName,
RevDate
)

VALUES
(
@UNIT_ID,
@F_TYPE,
@Title,
@Keywords,
@Description,
@FileName, GetDate()
)

SELECT @newFormID = @@IDENTITY
SELECT newFormID = @newFormID
END


GO

View 1 Replies View Related

Adding B Record To Output File

Apr 9, 2014

I'm not sure if I can explain this properly, but I'll try. I need to create an output file with a detailed record. I've been able to create a query that will give me the format and fields of what I need. However, the file layout calls for an additional "B" record if certain criteria is met in the detail immediately following the detail record. For example, if the PaymentMethodID = 10, then I need to add a "B" record that displays the PayeeName. I'm not sure if this would be a separate Select or a Union or maybe an Insert? All of our current layout are just Detail records and a Control Record.

Here is my current Select for the Detail:

SELECT DISTINCT
CONVERT(CHAR(10), ba.AccountNumber)
+ (REPLICATE('0', 10 - LEN(p.CheckNumber)) + CONVERT(VARCHAR(10), p.CheckNumber)) + REPLACE(CONVERT(VARCHAR(6), p.CheckDate, 1), '/', '')

[Code] ....

What I would need to add a separate B record?

View 1 Replies View Related

Difficulty Adding A Record In SSMSE

Aug 21, 2006

I'm new to SQL Server and I'm using 2005 Express with SSMSE, and having trouble adding a record to a table "manually" by typing in the data.

I find I can change most of the fields by viewing the table in SSMSE and just clicking on the field and editing it then clicking "execute SQL" but for some reason the changes don't "take" when a date field is involved.

Is there a special or proper way to enter a date that I'm not aware of? I'm not having much success figuring out this online help stuff from within SSMSE, I keep getting to help on the help system itself (oops).

TIA!

View 3 Replies View Related

Adding Image Or Picture To A Database Record

Jun 17, 2007

Hi,

I am new to SQL Server and I have got this problem and I am wondering if anyone could provide me with a solution, please.

I created a Product database table using Visual Basic 2005 Express and SQL Server 2005 Express. I have just added a new column [Picture] with IMAGE datatype to the database table, which of course, should store an image or picture of a product. I am writing to kindly ask you guys for help.

i) How do I store a picture or image for each record of this column [Picture] of database table? I have tried and all that I can see is < binary data > in the picture column, and when I start the VB 2005 Express form is a blank picture box!

ii) How do I get this image to display on Visual Basic 2005 Express form, so that when a product is selected the product image is displayed too? All text data appears but not the picture!

Your help much appreciated. Thanks.

Paul

View 3 Replies View Related

Need Help With Adding A Duplicate Record Count Column To Query

Jul 23, 2005

I am attempting to create a simple recordset that would return thenumber of duplicates that exist in a table with a single column. Forexample if I had a table like the following:ID Reference Amount1 123456 1.002 123456 2.003 123 1.00I would like to get the following result:ID Reference Amount RecCount1 123456 1.00 22 123456 2.00 23 123 1.00 1Please help!Thanks,Shawn

View 2 Replies View Related







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