Retireve The Uniqueidentification Field After Insert

Mar 14, 2006

Hey

 

Just wondering how to get the uniqueidentifier when you do an insert....I know how to do the @@Identity one but not sure how to get the guid back?

is it even possible...I just prefer to use the guid at this point due to security concerns of identity eg they increase it by 1 and get some where they shouldnt...

 

if i have to do a vb.net guid then insert how do I garentee a unique guid...eg i got a catch exception so if it catches that it already there then I would prefer it to try again is it possible?

 

thanks again

View 9 Replies


ADVERTISEMENT

Can I Insert/Update Large Text Field To Database Without Bulk Insert?

Nov 14, 2007

I have a web form with a text field that needs to take in as much as the user decides to type and insert it into an nvarchar(max) field in the database behind.  I've tried using the new .write() method in my update statement, but it cuts off the text after a while.  Is there a way to insert/update in SQL 2005 this without resorting to Bulk Insert? It bloats the transaction log and turning the logging off requires a call to sp_dboptions (or a straight-up ALTER DATABASE), which I'd like to avoid if I can.

View 6 Replies View Related

Get The Field Value After INSERT

Jul 23, 2005

Hi,Problem:I need to get the value of auto-incremented field from just insertedrecordIn Oracle this is INSERT .. RETURNING command.In SQL Server there are @@IDENTITY, IDENT_CURRENT, SCOPE_IDENTITY- @@IDENTITY returns the value from the very LAST insert on any tableinvolving in the insert process ( including triggers ) ,so this value may have nothing to do with my table- IDENT_CURRENT returns the last identity value generated for aspecific table in any session and any scope,so this value may come not from my session- SCOPE_IDENTITY returns the last identity value generated for anytable in the current session and the current scope , but from the veryLAST insert command ( that may be some INSERT in the audit tables)so it may have nothing to do with my tableQuestion :- Is there any trusted way I can get the value of auto-incrementedfieldin my table and in the scope of my session?Thanks, Eugene

View 2 Replies View Related

SQL Insert With Select And Specify Value For A Field

Oct 24, 2007

Hi,
Can someone tell me if it is possible to do an SQL insert with a select (to copy specific records) query and specify the value for a specific field to insert in the new records instead of using the value in the field in the select statement.
If so can you provide me with a simple example.
 Cheers
Mark :)

View 4 Replies View Related

Insert Into Sequence Field

Mar 25, 2002

What I want to do is: insert into newtable (field1, field2, sequence) select
(fielda, fieldb, #) from oldtable and have the sequence field "re-seed" to 1 every time the value in fielda/field1 changes. This added requirement makes this not an identity field problem, if I understand identity fields. This is a data conversion problem, so I'm converting 1000's of rows from oldtable to newtable and want the sequence to re-seed at every change in value of the fielda/field1 data; in fact fielda/field1 is a simplification as there could be multiple controlling fields forcing a re-seed.

TIA...Al

View 2 Replies View Related

Insert Text Field

Apr 3, 2001

Hellow, Everyone,

I am having a problem in Inserting a text field into another Text field on another table. each record in the field might be more than 255 charactors.

Any help would be appreciated.

Thanks,

View 1 Replies View Related

SQL 2012 :: Get ID And Set To Another Field On Insert

Feb 21, 2015

I want to learn if its possible to get ID in trigger and set it to another field.

I can do it by using scope_identity and using update command but I dont want to run another update command.

This is a very heavy loaded system that runs maybe 10-30 transactions on every second and I cannot afford that. I come up with a solution by using sequences but if I could use ID would be better.

View 1 Replies View Related

Insert Into A Table With Only One Field (ID)

Nov 25, 2007

Hello,
I would like to know the sql-query to insert a new row into a table which has only one column (ID) which is the primary key.

Thanks a lot for any suggestion !

Regards,
Fabianus

my favorit hoster is ASPnix : www.aspnix.com !

View 4 Replies View Related

How Can I Insert # In A Character Field

May 2, 2006

Hello,I wonder how I can insert a string which contains #, as # is a specialcharacters in sqlThanks

View 1 Replies View Related

Insert Multiple Values Into One Field

Jul 24, 2006

i can't believe my situation is unique, but my searches for answers have proven fruitless, so please bear with me.i have a date field in my database, and have previously used a simple textbox to allow users to insert a date.  i want to make this a little step a little nicer, however, and have added a dropdown for the month, a textbox for the date (i'm not "good" enough to dynamically change this around for a dropdown list), and a dropdown list for the next few years.what "insert" statement would allow me to accomplish this?  what i currently have doesn't blow up, but neither does it actually insert anything.  here's my statment:<asp:SqlDataSource ID="sdsVersion" runat="server" ConnectionString="<%$ ConnectionStrings:DB %>"    InsertCommand="INSERT INTO [Version] ([Major], [Minor], [Sub], [Rev], [Date]) VALUES (@Major, @Minor, @Sub, @Rev, @Month + '-' + @Day + '-' + @Year)">    <InsertParameters>        <asp:Parameter Name="Major" Type="Int32" />        <asp:Parameter Name="Minor" Type="Int32" />        <asp:Parameter Name="Sub" Type="Int32" />        <asp:Parameter Name="Rev" Type="Int32" />        <asp:ControlParameter ControlID="ddlMonths" Name="Month" PropertyName="SelectedValue" Type="Int32" />        <asp:ControlParameter ControlID="tbDate" Name="Day" PropertyName="Text" Type="Int32" />        <asp:ControlParameter ControlID="ddlYears" Name="Year" PropertyName="SelectedValue" Type="Int32" />    </InsertParameters></asp:SqlDataSource>

View 7 Replies View Related

How Can I Insert ' (Apostrophe) Into Sql Table Field ?

May 30, 2007

How can I insert ' (Apostrophe) into sql table field ?
Insert Into Table(Field) Values(?)
After executing sql statement above, I want to see ' (apostrope) in field.
Thanks

View 3 Replies View Related

Insert Null In A Numeric Field

Jul 2, 2007

I need to insert a null valvue when the user does not impute any text.
here is my code
If cell_phone.Text = "" Then
cell_phone.Text = "dbnull.value"
End IfDim mySqlConnection As New SqlConnection
mySqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings("Call_ListConnectionString").ConnectionString
Dim strSQL As String = "INSERT INTO Employees(Clock_ID, Last_Name, First_Name, Cell_Phone, Home_Phone, Work_Phone, Email, Primary_Day_Phone, Primary_Night_Phone, Blackberry_Number) VALUES ('" & clock_id.Text & "','" & last_name.Text & "','" & first_name.Text & "','" & work_phone.Text & "','" & home_phone.Text & "','" & cell_phone.Text & "','" & email.Text & "','" & prime_day_lst.SelectedValue & "','" & prime_night_lst.SelectedValue & "','" & blackberry.Text & "')"Dim mySqlCommand As New SqlCommand(strSQL, mySqlConnection)
mySqlConnection.Open()
mySqlCommand.ExecuteNonQuery()
mySqlConnection.Close()
THanks
Mike
 

View 4 Replies View Related

How To Insert Null Into Date Field?

Dec 11, 2007

hi all!I have a task, for example, to create a record for bill. I have table which represents this bill entity (Bill_ID, Amount,  CreationDate, ExposureDate, PaymentDate)In table definition date fields allow null. I would like to create bill, which means insert record:  (new_bill_id, 1000, 2007.12.11, null, null) But it couses exception. Smth like: System.Data.SqlTypes.SqlTypeException, date should be not null.  How could I do it?Please advice!    

View 5 Replies View Related

Trying To Append A Field If An Insert Happens To Contain A Duplicate

Jan 9, 2004

I deliberately intend to add some duplicates to one of my tables. For eg

Job User IsAdmin

JobID 235User ID 1
JobID 235User ID 5
JobID 235User ID 9
JobID 235User ID 5
JobID 235User ID 2
JobID 235User ID 9
JobID 235User ID 10
JobID 235User ID 1

I know its bad practice to do such a thing but there is a genuine reason. What I need to do is to be able to have a SQL statement that appends true to the IsAdmin field whenever it encounters the next UserID thats happens to be a duplicate. Hence the above would look like:

Job User IsAdmin

JobID 235User ID 1
JobID 235User ID 5
JobID 235User ID 9
JobID 235User ID 5 True
JobID 235User ID 2
JobID 235User ID 9 True
JobID 235User ID 10
JobID 235User ID 1 True

Thanks

View 1 Replies View Related

How To INSERT INTO [Table] ([Field]) VALUES('I Have A ' In Value')

Jun 2, 2004

Hi, I want to INSERT INTO [Table] ([Field]) VALUES('I Have a ' in value')

please teach me how to

xxx

View 2 Replies View Related

Insert TIME Only In DateTime Field

Jun 23, 2004

I am doing a temporary retro-upgrade right now. So, I know this isn't exactly in the scope of ASP.Net. Ordinally my posts are. However, I need a VBScript example of how to insert the Date only into the DateTime field of an SQL 2000 Server. By default, if you try to, the server automatically adds the date "1/1/1900". Can anyone help me please?

View 2 Replies View Related

Concatinating Two Field And Insert The Result

Aug 20, 2005

Hii,I need to concatinate two field and insert the result into each record. So far I managed to display the concatination but how do I insert it?use northwind
select city, region,([city]+ +[region]) as uniqefrom customerswhere region is not nullThe resulting records in Quary Anchorage AK AnchorageAKTsawassen BC TsawassenBCVancouver BC VancouverBCSan Francisco CA San FranciscoCA
 

View 1 Replies View Related

Cant Insert NULL To DateTime Field

Jun 5, 2006

Hi I'm using DetailView and I have a text box which show the date. I have formated the date as shortDate {0:d} format. I want to insert/update null if that text box is empty.
I have tried putting null value in my Update statement in sqlDataSource. And I'm getting error saying can't convert varchar to smalldatetime.
If I don't set null value as above, some large date (01/01/2033) has been inserted in my database.
Can anyone help me?
Moe

View 5 Replies View Related

SQL Insert Statement That Returns The ID Field

Sep 7, 2000

I'm fairly new to SQL, so this might be simple question:

I am adding records to an SQL7 database by using the INSERT statement. The table has an IDENTITY field which is auto-incremented, so a value is not needed for the field in the query.

Is there any parameters for INSERT that returns to me the value of the IDENTITY field for the record I just created?...

Any help or suggestions would be appreciated.

View 2 Replies View Related

Insert Time Into DateTime Field

Apr 5, 1999

I would like to be able to insert a time value only into a SQL 7 table colum which has been set as a datetime datatype. When I insert '12:34:44 PM' into the colum it actually inserts '1900-1-1 12:34:44 PM'. An Access table will allow you to insert the time value without adding the '1/1/1900' date value. Can this be done in SQL7?

Thanks for any help.

View 1 Replies View Related

Select The Insert Value Into Field In Another Table!!!!!!

May 24, 2002

i have tbl_location which includes userid, building, room. i combine the building and room into one feild called mailstop

SELECT Userid, Building +'/'+Room AS mailstop
FROM tbl_Location

i then want to take this recordset and insert it into a field called mailstop in my employee table. but they must based upon the userid of the location table and the userid of the employee table.

so the userid of the location table must match the userid of the employee table and insert that mailstop value into the mailstop feild in employee table. i want to get this right the first time. any help would be greatly appreciated.

View 1 Replies View Related

How Can I Insert Picture In Image Field

Feb 6, 2001

I try with textcopy but I did'n do nothing. Please help me

View 1 Replies View Related

SOS!!!can Not Insert The Field Of Smalldatetime With NULL

Jan 8, 2005

Hello everyone,
I am using DTS to transform data from foxpro.when it meets the date of NULL,it fails and says"Insert Error , column 4( 'Coloumn_name ',DBTYPE_DBTIMESTAMP), Status 6 data overflow ".
And then i try to open the DTS Transform Data task and do a preview of the data from the 'Source' side.The Null values are treated as "1899-12-30".
After reading something ,i try to write an ActiveX scripting Task to solve this problem using the function of "IsDate()",but it fails with exceptions.
Now I don't know what to do.could anyone give me some suggestion?Anything will be appreciated!ThankX in advance!

View 8 Replies View Related

Problem To Insert A Key Field In Another Table

Apr 16, 2008

hi everybody I have this case which I couldn't solve and need badly your help

table1

id1 field1 field2
1 a b
2 a c


table2

id1 field1 field2
a b
a c

I need to update table2 on the (id1) if the value of field1 and field2 in table 1 is equal to field1 and field2 in table 2 and inserting null when there is no match:::

I'm trying with this code but couldn't get thru

UPDATE table2
SET id1= COALESCE(table2.id1, 0)
from table1
left outer Join table2
ON
table1.id1=table2.id1


thanks

View 1 Replies View Related

Insert A Field (IDENTITY) Into Table

Apr 25, 2007

Hi,

I have a table with 1000000 records i try to add a field with following`spec.

[mkey] [int] IDENTITY(1,1) NOT NULL

I get the following meassage:-

yearly' table
- Saving Definition Changes to tables with large amounts of data could take a considerable amount of time. While changes are being saved, table data will not be accessible.

Then I Have the following error:-
Time out error

- How is the best way to copy a large table from one to anther.

regards

View 2 Replies View Related

Insert Values In Primary Key Field

May 15, 2006

Hi,

Does anyone know how should I create a table in order that I can insert values(numbers) in the primary key field, using insert statements. I also would like to know if there are any differences between SQL 2k and SQL 2k5.

Thanks in advance for any reply.

View 1 Replies View Related

Insert Data Into Table (one Field Is A PK)

Apr 1, 2008



hey all

I am new to this side of the sql and just testing some statements

what I want to do

insert one line into a table that already has data in it

KBCopy = Database name
KBStatusID = (PK, tinyint, not null)
KBStatusName = (varchar(100) not null)

the following is what I have tried.



use KBCopy

go

insert into KBStatus ("KBStatusID", "KBStatusName") Values ("4", "Archived")


the error I receive


Msg 128, Level 15, State 1, Line 2

The name "4" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables.
Column names are not permitted.

I presume this is to do with the ID?

thanks
jewel

View 4 Replies View Related

How To Insert A Zero Length String Into A Field Using SqlDataSource?

Jul 25, 2006

I have a few columns in table with default value defined as zero length string (''). I want to insert record from DetailsView which uses SqlDataSource as DataSource. In the ItemInserting event, if the data is not valid, I want to use zero length string for the column. But I always get Null instead of zero length string. The code in ItemInserting event looks like this:
If objddl.SelectedIndex > 0 Then        e.Values("myFld") = objddl.SelectedItem.ValueElse        e.Values("myFld") = ""End If
The line: e.Values("myFld") = "" put Null in the column.
How can I set a column as zero length string using the SqlDataSource?
Any help is appreciated.
Thanks.

View 3 Replies View Related

Insert Statement With Today's Date In One Of The Field

Nov 20, 2006

How do I write an Insert SQL statement with a default today's date inserted into one of the field?
 Help is apreciated.

View 9 Replies View Related

Retrieving Identity Field From Table On INSERT

Feb 29, 2008

 I have 2 tables - tblOrders and tblOrderDetails. Every time an order is placed, 2 INSERT statements are executed. The first one enters the general order and customer information in the tblOrders table:INSERT INTO tblOrders (custname, custdetails, orderdate) VALUES (@custname, @custdetails, @orderdate)The primary key in this table is OrderID which is an Identity column. This is the foreign key in the tblOrderDetails table.I'm trying to get the Identity value from the first INSERT statement to use in the second INSERT statement:INSERT INTO tblOrderDetails (orderid, productid, productcost) VALUES (@orderid, @productid, @productcost)  How do i obtain this value and how would I supply it to the second INSERT statement? 

View 3 Replies View Related

How To Insert Null Values Into A DataBase Field

May 9, 2005

I have a function that updates a table in sql server
If a field is left blank I want the database field set to Null. I use:sqlCmd.Parameter.Add("@somefield, someintvalue) to pass all my values to the database.
if someintvalue is null I want to set @somefield to dbnull
How can I do this? I get errors if I submit a null integer when there is a foreign key constraint. What is the best way to handle this? should I just make all parameters objects? so that I can set them to DBNull.Value?
Also on a side note, when you are populating fields from a datatable, is there a better way to set the values (i.e. of a textbox) than cheking for DBNull before assigning?

View 2 Replies View Related

Insert Number With Comma Into SQL Database 'int' Field

Feb 8, 2006

How can I allow users to input numbers with commas into a database field with an 'int' datatype without getting this error, 'Input string was not in a correct format'?

View 3 Replies View Related

Conditional Insert Based On MAX Number Of Field

Dec 15, 2005

Hi!

I have a table called DB1 that contains this:

MID
IIN
NUM_EVENTS
DATE

MID, IIN and NUM_EVENTS are composite keys. and only NUM_EVENTS get incremented. All records start with NUM_EVENTS = 1.How can I create a query that only displays those records that only NUM_EVENTS = 1 meaning their still on the first stage of processing?

View 6 Replies View Related







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