Insert New Empty Record??

Oct 30, 2007

Is there a way to INSERT a new empty record without having to designate a field?

I tried the obvious but they issue errors.

--PhB

View 11 Replies


ADVERTISEMENT

How To Know If A Record Is Empty Or Not, Without Using QueryString?

May 18, 2007

Hi,I wrote two queries to search in three tables mp_parent, mp_page and mp_parentThe first one is: SELECT mp_page.PID, mp_page.PageID, mp_page.PageContent, mp_page.ParID, mp_page.ChiID,  mp_parent.ParentName FROM mp_page INNER JOIN mp_parent ON mp_page.ParID = mp_parent.ParentID The second one is:SELECT mp_page.PID, mp_page.PageID, mp_page.PageContent, mp_page.ParID, mp_page.ChiID, mp_child.ChildName FROM mp_page INNER JOIN mp_child ON mp_page.ChiID = mp_child.ChildID  I used this way to display the records in a FormView    public HttpContext context = HttpContext.Current;    public void Page_Load(object sender, EventArgs e)    {        if (!Page.IsPostBack)        {            ViewState["srch"] = context.Items["srch"];        }        FormView1.DataSource = GetTable();        FormView1.DataBind();    }      private DataTable GetTable()    {        SqlConnection SqlCon = new SqlConnection("Data Source=AJ-166DCCD87;Initial Catalog=mp;Integrated Security=True;Pooling=False");        String SQL1 = "select mp_page.PID, mp_page.PageID, mp_page.PageContent, mp_page.ParID, mp_page.ChiID, mp_parent.ParentID, mp_parent.ParentName from  mp_page INNER JOIN mp_parent ON mp_page.ParID = mp_parent.ParentID where PageContent like '%" + Convert.ToString(ViewState["srch"]) + "%'";        SqlDataAdapter Adptr = new SqlDataAdapter(SQL1, SqlCon);        SqlCommandBuilder CB = new SqlCommandBuilder(Adptr);        DataTable Dt = new DataTable();        Adptr.Fill(Dt);        return Dt;        SqlCon.Close();    } the question is how can I check if one record is empty to witch to another query ??Is it possible to know without using QueryString?Thank you 

View 5 Replies View Related

Show One Record If Table Is Empty

Apr 25, 2014

I have a query

select salesId,count(*) from salesline group by salesid

Result will be

salesid Nos
----- ---
SO001 2
SO002 4

I want to display single record like below if there is no record available in the table

salesid Nos
So00? 0

View 1 Replies View Related

TOUGH INSERT: Copy Sale Record/Line Items For Duplicate Record

Jul 20, 2005

I have a client who needs to copy an existing sale. The problem isthe Sale is made up of three tables: Sale, SaleEquipment, SaleParts.Each sale can have multiple pieces of equipment with correspondingparts, or parts without equipment. My problem in copying is when I goto copy the parts, how do I get the NEW sale equipment ids updatedcorrectly on their corresponding parts?I can provide more information if necessary.Thank you!!Maria

View 6 Replies View Related

How To Create An Copy Of A Certain Record Except One Specific Column That Must Be Different && Insert The New Record In The Table

Sep 1, 2006

Hi
I have a table with a user column and other columns. User column id the primary key.

I want to create a copy of the record where the user="user1" and insert that copy in the same table in a new created record. But I want the new record to have a value of "user2" in the user column instead of "user1" since it's a primary key

Thanks.

View 6 Replies View Related

Lookup && Update Record && Insert Record

Mar 26, 2008

Hi All,

I am trying to create package something like that..

1- New Customer table as OleDB source component
2- Lookup component - checks customer id with Dimension_Customer table
3- And if same customer exist : I have to update couple fields on Dimension_Customer table
4- if it does not exist then I have insert those records to Dimension_Customer table

I am able to move error output from lookup to Dimension_Customer table using oledb destination
but How can I update the existing ones?
I have tried to use oledb command but somehow it didnt work
my sql was like this : update Dimension_Customer set per_X='Y', per_Y= &Opt(it should come from lookup)

I will be appreciated if you can help me...

View 3 Replies View Related

Do Not Keep NULLS Using SSIS Bulk Insert Task - Insert Empty Strings Instead Of NULLS

May 15, 2008

I have two SSIS packages that import from the same flat file into the same SQL 2005 table. I have one flat file connection (to a comma delimited file) and one OLE DB connection (to a SQL 2005 Database). Both packages use these same two Connection Managers. The SQL table allows NULL values for all fields. The flat file has "empty values" (i.e., ,"", ) for certain columns.

The first package uses the Data Flow Task with the "Keep nulls" property of the OLE DB Destination Editor unchecked. The columns in the source and destination are identically named thus the mapping is automatically assigned and is mapped based on ordinal position (which is equivalent to the mapping using Bulk Insert). When this task is executed no null values are inserted into the SQL table for the "empty values" from the flat file. Empty string values are inserted instead of NULL.

The second package uses the Bulk Insert Task with the "KeepNulls" property for the task (shown in the Properties pane when the task in selected in the Control Flow window) set to "False". When the task is executed NULL values are inserted into the SQL table for the "empty values" from the flat file.

So using the Data Flow Task " " (i.e., blank) is inserted. Using the Bulk Insert Task NULL is inserted (i.e., nothing is inserted, the field is skipped, the value for the record is omitted).

I want to have the exact same behavior on my data in the Bulk Insert Task as I do with the Data Flow Task.

Using the Bulk Insert Task, what must I do to have the Empty String values inserted into the SQL table where there is an "empty value" in the flat file? Why & how does this occur automatically in the Data Flow Task?

From a SQL Profile Trace comparison of the two methods I do not see where the syntax of the insert command nor the statements for the preceeding captured steps has dictated this change in the behavior of the inserted "" value for the recordset. Please help me understand what is going on here and how to accomplish this using the Bulk Insert Task.

View 2 Replies View Related

Insert Empty String Or Null To Sql Db

Jan 12, 2008

Hi:
Trying to insert null value into sql table, but not working, if I use:
 if (strMyText.Length == 0)        command.Parameters.Add("@Text", DBNull.Value); // or using:("@Text", null), or using:("@Text", DBNull) else         command.Parameters.AddWithValue("@Text", strMyText); 
When I go back to table, I see the value is: 'NULL', has single quotation mark, suppose to be: NULL
Where is the problem?
Thanks a lot.
Jt

View 3 Replies View Related

Cannot Insert Rows Into Empty Table

Mar 3, 2008

When i try to insert new rows using SSIS into an emty table in my database, SSIS freezes. The same happens when i use a lookup on an empty table.

The only solution i have found is to manualy insert a row and remove it afterwards. When i have done this SSIS works without a glitch.

I start off by taking a script of a existing database and applying this script on a new database. So that i create an empty duplicate of my current database.

Any ideas why SSIS freezes? Do i have to initialize something first in my database? It is really annoying that i have to insert a row and delete a row into every table i want to use.

View 9 Replies View Related

How Do I Insert Data From An Access Db To A Empty SQL Database

Jul 11, 2007

Hi,

I'm new to VS2005 (vb.net) and here my situation



I have form with a dataset1 (tbl1, tbl2, tbl3, tbl4) pulling data from a Access db. and showing it on the form1(databound)

I need to write what is on form1 to the empty dataset2 in SQL 2005 db

I have created a new DB in SQL 2005 with a Table SQL1 which has the same fields as on form1. Please can some one show me how do I do this. Please



Thanks in advance for your response.

-NM

View 3 Replies View Related

Database Insert Question - Best Practices For Empty Data

Apr 17, 2007

I am making a form that takes input for 1 to 5 students using VWD.  With the help of previous posts I have been able to make the database insert query work properly.  In my form I have a radio list that has the user select if they are entering information for 1, 2, 3,4, or 5 children.  Depending on how many children are selected on the radio list, I am displaying the proper number of textboxes and validating the data using the handy RequiredFieldValidator.  Now I am at the point where I want to perform the instert to the database depending on the selected number of children in the family.  What is the general rule for best  practices. Please keep in mind that it is my understanding that ALL fileds in a SQL insert statment must have data. Should I ...1) create alternative SQL statements depending on the textboxes displayed OR2) is it more common to insert a standard string or integer, depending on the datatype, into the unused textboxes to populate the unused fields? Sincerely,Mike 

View 2 Replies View Related

Insert Query Fails (if Form Fields Left Empty)

Aug 13, 2007

Dear All,
I have created a table in my SQL server database, the problem i am facing is my insert query fails if i leave any form field empty (leave it blank). On my back-end table, only one field is mandatory, and others have been set with the constraint "allow null".
As per our business requirement, except one value is complusory while others are optional. If I enter all values in the form it works perfectly fine. Can you see in the code below - where am i possibly going wrong ?
<script language="VB" runat="server" >      Sub Page_Load(Src As Object, e As EventArgs)                      If Page.IsPostBack Then                        Dim ConLath As SqlConnection            Dim comLath As SqlCommand            Dim insertcmd                        conLath = New SqlConnection("Data Source=SQLas;Initial Catalog=settle;User ID=sa;Password=password")            ConLath.Open()            insertcmd = "Insert into His_set values (@t_d,@s_p,@p_s,@v_oq,@i_oq,@v_qn,@i_qn,@v_qw,@i_qw)"                        comLath = New SqlCommand(insertcmd, ConLath)                                    comLath.Parameters.Add(New SqlParameter("@t_d", SqlDbType.DateTime, 12))            comLath.Parameters("@t_d").Value = trade_date.Text            comLath.Parameters.Add(New SqlParameter("@s_p", SqlDbType.Decimal, 8))            comLath.Parameters("@s_p").Value = sett_price.Text            comLath.Parameters.Add(New SqlParameter("@p_s", SqlDbType.Decimal, 8))            comLath.Parameters("@p_s").Value = post_close.Text            comLath.Parameters.Add(New SqlParameter("@v_oq", SqlDbType.Int, 8))            comLath.Parameters("@v_oq").Value = vol_oq.Text            comLath.Parameters.Add(New SqlParameter("@i_oq", SqlDbType.Int, 8))            comLath.Parameters("@i_oq").Value = oi_oq.Text            comLath.Parameters.Add(New SqlParameter("@v_qn", SqlDbType.Int, 8))            comLath.Parameters("@v_qn").Value = vol_qn.Text            comLath.Parameters.Add(New SqlParameter("@v_qw", SqlDbType.Int, 8))            comLath.Parameters("@v_qw").Value = vol_qw.Text            comLath.Parameters.Add(New SqlParameter("@i_qn", SqlDbType.Int, 8))            comLath.Parameters("@i_qn").Value = oi_qn.Text            comLath.Parameters.Add(New SqlParameter("@i_qw", SqlDbType.Int, 8))            comLath.Parameters("@i_qw").Value = oi_qw.Text
                        Try                comLath.ExecuteNonQuery()                            Catch ex As SqlException                If ex.Number = 2627 Then                    Message.InnerHtml = "ERROR: A record already exists with " _                       & "the same primary key"                Else                    Message.InnerHtml = "ERROR: Could not add record, please " _                       & "ensure the fields are correctly filled out"                    Message.Style("color") = "red"                End If            End Try
            comLath.Dispose()            ConLath.Close()                                                        End If   End Sub
</script>
 

View 6 Replies View Related

SQL Server 2012 :: Insert Empty String In A Decimal Field?

Jul 13, 2015

I have a requirement where i have to insert empty string in column whose datatype is decimal.

I have to replace the column value if it is null then insert it as ' '.

Obviously its generate error msg for conversion, is there any workaround for this. I cannot add 0 or other value as this column is used to generate some output value.

IIF(Column1 IS NULL, ' ', Column1))

I used TRY_PARSE but it insert null value if there is conversion error.

View 3 Replies View Related

INSERT New Record Help

Feb 24, 2006

Ok this is a simple question but i cant seem to find out how since i had the access of a query builder for web matrix.I have the following:A Table called Customer, with Cust_Name, Cust_phoneI have modified my CreateUserWizard to accomodate mroe text boxes which would finally store to vales for  Cust_Name, Cust_phone.Question is how can i perform an INSERT query? or rather i noticed that the query builder doesnt allow me to, instead the query  builder is towards inserting new records thur GridView and FormView.I've designed a query to handle wildcards i.e  @Cust_Nameso i'm thinking if i can have a working insert statment i can do something liketbCust_name.txt = @Cust_Namethen finally perform the insert queryAny ideas? thanks

View 2 Replies View Related

Insert A New Record

Dec 29, 2006

Hi,

I would like to know is it possible to combine these 2 statements into 1, as I want to insert a single record set in tblRefLockers.

statement 1:

INSERT INTO tblRefLockers (Locker_No)

SELECT Locker_No from tblLockersInfo

WHERE MemberNo = 1234

statment 2:

UPDATE tblRefLockers

SET Locker_Condition = 'BAD'

WHERE MemberNo = 1234

Can I do that?

Thanks,

KNVB

View 6 Replies View Related

Append Query To Insert 80000 From One Table To Empty Table

Jul 22, 2012

All, Using access 2003 frontend and sql server 2008 backend. I have an append query to insert 80000 from one table to an empty table. I get an error:

"Microsoft Office Access set 0 field(s) to Null due to a type conversion failure, and didn't add 36000 record(s) to the table due to key violations, 0 record(s) due to lock violations, and 0 record(s) due to validation rule violations."

I know this error normally comes if there are dups in a field that doesnt allow.

View 1 Replies View Related

Exception - Insert Record Into DB

Aug 4, 2007

 Hello I’m using express edition to create my trail test
application. Below is the code that I have and I’m trying to insert data to the
database table named “Coin�.







Protected Sub
btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnview.Click



       
Dim s As
String = txtCname.Text

       
'Dim myConnection As New
SqlConnection(myConnString)

       
Dim desc As
String = txtCDesc.Text

       
Dim ConStr As
New SqlClient.SqlConnection

       
ConStr.ConnectionString = "server=testsqlinstance;
Integrated Security=True"

       
Response.Write("Connection string:  " & ConStr.ConnectionString)





       
Try

           
Dim SelectQuery As
String = "SELECT
max(coinid) from coin"

           
Dim idval As
Integer = 0

           
Dim command As
New SqlCommand(SelectQuery, ConStr)

           
ConStr.Open()

           
idval = command.ExecuteScalar()

           
Console.WriteLine(idval)

           
idval = idval + 1

           
Dim InsertQuery As
String = "INSERT
INTO COIN(coinname, coinid, ebayid, ebaymember, ebaymemid , amount , coindesc)
VALUES('1992-Proof'," & idval & ",'eewerwer','sp6937','serwryana',67.70,'Matt
Proff of 1992- Mint Set')"

           
Dim command1 As
New SqlCommand(InsertQuery, ConStr)

           
command1.ExecuteScalar()

           
Dim S1 As
String = "Record
insert - Successful!"

           
Console.WriteLine(S1)

 

       
Catch ex As
Exception

            Label2.Text = ex.ToString

       
Finally

           
ConStr.Close()

       
End Try

End Sub





 This program is
throwing an exception (mentioned below) 

Exception --->  System.Data.SqlClient.SqlException:
Invalid object name 'coin'. at
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean
breakConnection) at
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception,
Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject stateObj) at
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at
System.Data.SqlClient.SqlDataReader.get_MetaData() at
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,
RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult
result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at
System.Data.SqlClient.SqlCommand.ExecuteScalar() at _Default.btnview_Click(Object
sender, EventArgs e) in C:Documents and SettingsarshaMy DocumentsVisual
Studio 2005WebSitesWebSite1Default.aspx.vb:line 92



“Coin� is the table name – which is in SQL server. Kindly
help me to handle and overcome this exception.



Thanks

 

 

View 2 Replies View Related

Insert New Record - Primary Key

Jan 12, 2008

Hi
I have a table in sql server with a numeric field as Primary Key. When i insert a new record i need that primary key increments automatic (like access  auto increment) because i want avoid the possibility of duplicate Primary Keys.
Is that possible?
Thank you

View 2 Replies View Related

How To ID When I Have Insert The New Record Immediately

Jan 29, 2006

hi all,i have a question that how to get id afer insert  a new record.i just read from the following article, but still can't get the meaning:http://forums.asp.net/1008337/ShowPost.aspx
and my code             Dim sql_3 As String            sql_3 = "insert into paper_type (name, enable,creation_date,lastupdate,user_id) values "            sql_3 += "('" & name & "','" & enable & "', getdate() ,getdate ," & user_id & ")"            Call OpenRs(sql_3)            ' I want to get the id immediately, but how?? (i am using sql server)   can somebody help me to solve the problem??thanks a lot

View 9 Replies View Related

Help! Insert A Record Into SQL Database With ASP.net And C#

May 29, 2006

I'm trying to make a website that people can upload file to the server, then the webpage will automatically insert the username and the file name into the database. I have thought about this for couple days but still got nothing. can some one help me?
can some one post a very simple aspx file that can insert a record to the sql database with C#? Not the code that generated by ASP.net 2.0!
I want to see how to access the database manually.
Thank you.

View 2 Replies View Related

Multiple Record Insert

Dec 9, 2002

I am trying to do an update to a database with the code below, the code will work in generating a single record (if i exclude the IF statement) but i need it to create multiple new records based on the IF statement (or something similar) i have in the code. It needs to create updates for every record that has a parentguid that matches the one specified in the code.
the idea is, the hierachy structure in the tables are:

Location1
--> Part1
--> part2 etc
Location2
--> part1 etc

i want it so that when i input a new part it updates to all the locations. The locations all have the same parentguid (the one specified in the code)
With regards to the stored procedure it executes, this stored procedure creates the entry. I don't really want to change the stored procedure because other functions reference and use it.

My code:

DECLARE @PREFIX VARCHAR(6)
DECLARE @CODE VARCHAR(8)
DECLARE @GUID UNIQUEIDENTIFIER
DECLARE @PARENTGUID UNIQUEIDENTIFIER
DECLARE @PARENTGUID2 VARCHAR(50)
select @parentguid2 = parentguid from dsdba.itemgroups

if @PARENTGUID2 = '8CF850AD-2026-411B-AABE-BF1584624EB3'
BEGIN

SET @PREFIX = 'JUST'

SELECT @PARENTGUID = GUID FROM DSDBA.iTEMGROUPS WHERE CODE = @PREFIX

SET @CODE = @PREFIX + '02'
SELECT @GUID = NEWID()

EXEC DSDBA.usp_ItemsDB_InsertGroup @GUID, @CODE, 'JMB', @PARENTGUID, 1

END

:confused:

View 1 Replies View Related

Why Won't This Record Insert At End Of Table?

Oct 3, 2003

Given the following code, why won't the information that I have at the end of my WHILE loop insert at the end of the table?

For some reason (there are over 7000) records being written to this table, the row that I am trying to insert is always included at row 73.

Any ideas? All I want to do is have it insert at the end of this script at the end of the table.

Thanks,
Steve

ALTER procedure sp_Cigna_build_export
as

Declare CignaExport Cursor
For
Select
exprectype,
expssn,
expfiller,
expbody

From cigna_employee_sort

Declare
@RecordType char(2),
@SSN char(11),
@Filler char(20),
@Body char(867),
@Counter int,
@CountLength int,
@RecordCount char(9)

select @counter = 0

Open CignaExport
Fetch Next from CignaExport

Into
@RecordType,
@SSN,
@Filler,
@Body

While @@fetch_status = 0

Begin
select @counter = @counter + 1
insert into cigna_export_table
(exportfield)
select
@recordtype + @SSN + @Filler + @Body

Fetch next from CignaExport
Into
@RecordType,
@SSN,
@Filler,
@Body
End


-- Adding two here accounts for the header/trailer records
select @recordtype = '99'
select @counter = @counter + 2
select @RecordCount = '000000000'
select @CountLength = len(@counter)
print @counter
insert into cigna_export_table
(exportfield)
select
@recordtype + stuff(@recordcount,10-@countlength,@countlength,@counter)

View 5 Replies View Related

Insert Multiple Record

Mar 3, 2004

can anyone help to explain how to insert multiple record into one/two table?

ex:lets say when user specify start date and end date, then we need to created and insert the record on that duration.

and how to do with insert the record weekly or monthly?until the end of the date!

View 1 Replies View Related

Insert Record If None Exists

Oct 6, 2003

Hello folks,

I am new to msSQL and ASP, I need some help writing an SQL statement that will first check to see if a combination or record exists, if none found thant it will add it. I am working a section of a site that adds favorites to the database. Each user can have more that one favorite hence it has to check for that unique combination of the fields, UserID and FavID

My Code:
Dim objConnection, objRecordset, strSQL
Dim strFavID, strUserID
strFavID = request.Form("favid")
strUserID = request.Form("userid")

Set objConnection = Server.CreateObject("ADODB.Connection")
Set objRecordset = Server.CreateObject("ADODB.Recordset")
objConnection.Open Application("ConnectionString")

strSQL = "INSERT INTO FAV (UserID,FavID) (SELECT DISTINCT " & strUserID & " AS UserID " & _
strFavID & " AS FavID" & " FROM FAV)" & _
" WHERE " & strUserID & " & " & strFavID & " NOT IN (SELECT UserID, FavID FROM FAV)"
response.Write(strSQL)
'response.End()

If strFavID <> "" Then
On Error Resume Next
objConnection.Execute(strSQL)

objConnection.Close
Set objConnection = Nothing
End If


This code is giving me a syntax error, how do I write the correct statement. I am using MS Access 2k

Thanks for your help

View 9 Replies View Related

Don't Insert If Record Exists

Jun 21, 2004

/*if key values exist don't insert new record*/
SELECT

/*if exists don't insert*/
CASE
WHEN ISNULL(gradeId, -1) = -1 THEN
INSERT INTO tblScores
(gtStudentId, assignmentId, score)
VALUES (@nStudent, @nAssignment, 0)
END

FROM tblScores
WHERE gtStudentId = @nStudent AND assignmentId = @nAssignment


tblScores has two fields comprising its primary key (gtStudentId, assignmentId) and the gradeId field is a required filed in this table.

I'm getting syntax errors when I click check syntax (near keywords insert from and end).

one other note: this CASE END is nested inside a BEGIN END loop, is this the problem? Is the 'End" of the 'Case' closing the 'End' of the 'Begin'?

thanks

View 6 Replies View Related

Can't Insert New Record To Database.

Mar 22, 2006

SOS
I am working with SQL 2000 located on a Networksolutions server and I have a Test record I inserted manually, but I am unable to insert a new record and get this error "can't insert new record to database".
No doubt this is a no brainer, but I can't solve it.
Many Thanks
Who ever you are.

View 7 Replies View Related

Insert Record From Another Database

Jan 31, 2007

hi. we have 1 production database and a 2nd backup database. one of our users accidentally deleted a case and we would like to get it back. our production database is updated nightly so none of the case's information would've changed.

how can i insert the data from the backup database to the production database? i need to copy one row. thanks for your help!

View 1 Replies View Related

INSERT Record Through A View

Apr 20, 2004

Is is possible to insert a record through a view. If so, how?

USE Northwind

GO

CREATE TABLE tbForms (
FormID INT IDENTITY (1,1) NOT NULL,
Form varchar (100) NOT NULL
)

GO

ALTER TABLE tbForms
ADD CONSTRAINT tbForms_pk PRIMARY KEY (FormID)
GO

CREATE TABLE tbDoubleTeeForms (
fkFormID INT NOT NULL,
Form varchar(100) NOT NULL,
Width FLOAT,
Height FLOAT,
Flange FLOAT,
Leg FLOAT,
LegCount INT
)

GO

ALTER TABLE tbDoubleTeeForms
ADD CONSTRAINT tbDoubleTeeForms_pk PRIMARY KEY (fkFormID)
GO

ALTER TABLE tbDoubleTeeForms
ADD CONSTRAINT tbDoubleTeeForms_fk FOREIGN KEY (fkFormID)
REFERENCES tbForms (FormID)
GO

CREATE TABLE tbFlatPanelForms (
fkFormID INT NOT NULL,
Form varchar(100) NOT NULL,
Width FLOAT,
HEIGHT FLOAT
)

GO

ALTER TABLE tbFlatPanelForms
ADD CONSTRAINT tbFlatPanelForms_pk PRIMARY KEY (fkFormID)
GO

ALTER TABLE tbFlatPanelForms
ADD CONSTRAINT tbFlatPanelForms_fk FOREIGN KEY (fkFormID)
REFERENCES tbForms (FormID)
GO

CREATE VIEW MyProducts AS
SELECT fkFormID, Form FROM tbDoubleTeeForms UNION ALL
SELECT fkFormID, FOrm FROM tbFlatPanelForms

GO

-- How can I insert a new record, the pk of the forms table is identity.
-- Can this be done?
INSERT INTO MyProducts (Form)
VALUES ('My First Entry')
GO

SELECT * FROM MyProducts
GO

DROP VIEW MyProducts
GO

DROP TABLE tbFlatPanelForms
GO

DROP TABLE tbDoubleTeeForms
GO

DROP TABLE tbForms
GO

Mike B

View 13 Replies View Related

Update Record After Insert

May 30, 2008

Using trigger
want to update a field being inserted from another record in the same table.

the record being inserted I want to pull the bkjrcode from another record where the account = 1040 that also has the same ord# and inv# as the record being inserted.

Here is what I've tried with no luck.

create trigger [updategbkmut] on [dbo].[gbkmut]
after insert
as

update g1
set g1.bkjrcode = g2.bkjrcode
from gbkmut g1
inner join inserted i
on i.ord_no = g1.ord_no and i.inv_no = g1.inv_no
inner join gbkmut g2
on i.ord_no = g2.ord_no and i.inv_no = g2.inv_no
where i.freefield3 = 'Rebate' and g1.account = '1040'

View 2 Replies View Related

Insert Child Record

Mar 22, 2006

George writes "SQL server 2005 Express, Windows XP Pro SP2

I want to create a stored procedure that will insert a record in a child table (tblcontproj)propulating two columns with columns from the parent (InterestListoriginal)and two columns with user selected values. I created an insert select statement that looks like ..

" INSERT INTO tblcontproj(proj_rpt_id, proj_name) SELECT proj_rpt_id, project_name FROM InterestListoriginal WHERE (proj_rpt_id = @proj_rpt_id)"

This works great! Now can I add two columns to the INTO clause for projcontshortname and projconttye and use a VALUE clause that sets tblcontproj.projcontshortname and tblcontproj.projconttype to @projcontshortname and @projconttype which are user selected values from a downdownlist.

Or add an UPDATE query?

Thanks "

View 1 Replies View Related

Insert A Record In A Particular Place

May 27, 2006

i have a table name is HH tableit has two columns 'hhno' and hhname'HH tabelehhno hhname100 suresh101 baba103 rami want to insert a one record(102 , chandra) in HH table between(101,baba) and( 103 ,ram).how can i insert them please help ,me thanks

View 10 Replies View Related

INSERT - One Record At A Time

May 2, 2007

Hi everyone:Using Sql Server SQL 8I'm trying to INSERT records into a "can software package" batchtable. I have a work-table that mimics the batch table. Aftermanipulating the records in the work-file I want to INSERT them intothe batch table.The problem is the batch table in the can software has a trigger onthe batch table which is going to force me to INSERT one record at atime. I've always been able to do an INSERT with no problem.The batch table has pretty basic columns:BatchIDBatchDateSeqNumberThese three fields are the key and then just some miscellaneouscolumns. Any easy way to loop thru my work-file to insert theserecords. Never done a loop in SQL so an example would be reallyreally appreciated. I have a sequence number so I was hoping to do aWhile loop but I really don't know enough about creating a loop tomake that call. Thanks in advance for any help.

View 6 Replies View Related

ASP: Error When Trying To Insert Record

Jul 6, 2007

I receive the following error when trying to INSERT INTO; am using Access db.



Microsoft OLE DB Provider for ODBC Drivers error '80040e07'[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.


The code is as follows:



<%
Dim dbConn
set dbConn = server.CreateObject("adodb.connection")
dbConn.open("connect")
dbConn.Execute("INSERT INTO tbl_country (region, countryName, population, country_currency, description, imageURL, imageALT) VALUES ('" & Request.Form("region") & "', '" & Request.Form("countryName") & "', '" & Request.Form("population") & "', '" & Request.Form("country_currency") & "', '" & Request.Form("description") & "', '" & Request.Form("imageURL") & "', '" & Request.Form("imageALT") & "'),")
Response.Redirect("admin_master.asp")
%>



I would greatly appreciate any help you can give me.

View 7 Replies View Related







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