Inserting Values Into A Column By Selecting Value From Different Table

May 5, 2004

Hi, I have a question regarding how to insert one column values into a table by selecting from different table..Here is the syntax..
------------
insert into propertytable values (select lastvalue+incrementby from agilesequences where name='SEQPROPERTYTABLE', 13926, 0, 4, 1, 451, 1, 8, 1)

the first column in the propertytable will be... select lastvalue+incrementby from agilesequences where name='SEQPROPERTYTABLE'
How do I do that..Help PLZ..

View 3 Replies


ADVERTISEMENT

Selecting Records From One Column In A Table And Inserting..

Feb 16, 2006

Godwin writes "Hello,
Heres my question..
I have 2 tables.2 paticular columns exist in both the tables.
I want to be able to select those 2 columns on the 1st table and insert them on to the same 2 columns on the 2nd table.

Now,this 2nd table has another 3 columns that exist in another table.I would like to take those 3 column values from that 3rd table and insert it into the 2nd table by modifying those existing records in the 2nd table.In the 3rd table,there will be around 5 records...I want to copy the existing records 5 times in the 2nd table and insert the 3rd tables rows inside the 2nd table in that respective column for 5 rows.

I hope you understand what I mean...Im sorry for really confusing..
Please help me
Thanks
Godwin"

View 1 Replies View Related

Inserting Values From Multiple Tables To Only One Column Of A Seperate Table

Dec 11, 2004

Hi all,

I want to produce some output for Mainframe application. For that I want to insert values from multiple table as source to a single column (huge in size)of a different table (Destination table). There may be same related records in all of the source tables with the primary key. When I export values from the source tables , each related records should be insterted to the destination table's field (multiple entries for each table). Please advise.

Thanks

View 5 Replies View Related

Selecting From One Table Inserting Into Another

Feb 18, 2007

hi, i am sure this is very simple, but its just got me stuck! i have a table which i use for inserting products, now its not very exciting to see the cat_id so i wanted to put a dropdown box on there which would show the cat_description from tbl_cat and then put the tbl_cat.cat_id into tbl_products.cat_id
any help would be greatful
 Jez

View 1 Replies View Related

Selecting From One Table, Inserting Into Another

Jul 3, 2007

hi there, i have a page where on my button click i need to select address, pcode from tbl_person where person_id = querystring and update or insert those values into tbl_del where order_ID = querystring 2 below is the code i am using, although im stuck on the sql stringSqlConnection objConnAddy = new SqlConnection(sConnectionStringCustInfo);using (objConnAddy)
{
objConnOID.Open();
// insert values into delivery table, second line updates price + VAT
string sqlAddy = "?????";
SqlCommand objCmdAddy = new SqlCommand(sqlAddy, objConnAddy);
objCmd1.ExecuteNonQuery();
i had a look on the net and here but i cant seem to find exactly what i want, any help would be great!
Cheers Jez

View 2 Replies View Related

Selecting One Row And Inserting It Into Another Table One By One

Feb 14, 2008

i ve a table named "Employee" in wh i ve fields "Emp_Id","Name" and "Email". i want to select each employee "Emp_Id" one by one from "Employee" table and insert it into another table named "Concerned_Department". like if i ve three rows in "Employee" table with "Emp_Id" 1,2 and 3 respectively,in this case i want to first select "Emp_Id"=1 then "Emp_id"=2 and lastly "Emp_id"=3 and insert them into "Concerned_Department"table.
 after that the process starts again like inserting "Emp_Id"=1 in "Concerned_Department" and so on.
plz note that i want to insert "Emp_Id" one by one not all the fields together.
 can u plz tell me the query for that wh i ve to write in SQL
Thanks and happy valentine day to all of u
 regards
Ahmed Bilal Jan

View 3 Replies View Related

Regarding Stored Procedure For Selecting A Value From One Table And Inserting It To Another

Sep 19, 2007

Hi iam Prameela,
I want to select some dynamic values from a table and store them to another table.
Let me give u an example,its like:
I have UID,QID,Option1,Option2,Survey Name in one table called Survey Answers and i must select these values and insert them into Surevy Count table which contains some fields as QID,Opt1Cnt,Opt2Cnt,Survey Name. this is an online survey and when ever an user participate in the survey then values will be changed in Survey Answers like:
Surevy Answers Table:
UID   QID        Option1             Option2          Survey Name---------These are the fields
1         1             1                       0                    Articles
1          2            0                       1                    Articles
2           1            1                        0                      Articles
2           2             0                       1                       articles
I need to add all these Options of particular QID and store them in Survey Count table,like
QID          Opt1Cnt          Opt2Cnt          Survey Name
1                 2                     0                     Articles
2                  0                      2                   Articles
When ever the user participate in survey then there will be change in Survey answers table i.e the option count will be increased
So this count should be modified in Survey Count Table,like:
If another user participated in survey and if he voted for Option1 of QID1,Option1 of QID2 then the survey count table should be modified as:
QID           Opt1Cnt                Opt2Cnt             Survey Name
1                   3                         0                            Articles
2                   1                          2                             Articles
I need a Stored Procedure for this.
Please help me with this query.
 

View 7 Replies View Related

SQL Question About Selecting Values Dependent On Another Column

Mar 10, 2003

I have a table with one row for each test a user has taken, with columns for userid, score, and test date. I have a query that gets the highest score and the date of the latest test for each user. Easy. But how can I also get the score achieved on the latest test for each agent?

Thanks,
John

(By the way, I've been looking for a good SQL mailing list to ask this question and have been unsuccessful. If there's a better forum than this for this type of question, please let me know).

View 6 Replies View Related

Inserting Multiple Values Into One Column

May 1, 2001

Is there a way to insert multiple values into a single column based on various "tests".
For example, I want to check a sales_order table and flag all new orders coming in against previous orders placed that were determined to be fraudulent. If I were to set up i.e. five different tests(i.e. check email, credit_card number etc. against previous fraud orders), then there would be the possibility that any given order can be flagged 1 to 5 times. I want to record all of these tests within the same column if possible. Therefore the output may look something like the following:

order_number fraud_score
1234567890 a,b,d
5432109876 e
2345678901 null
3455607983 a,b,c,d,e

I was considering adding five additional columns to the table and running five different update steps, but this doesn't appear very scalable. Any suggestions would be greatly appreciated!
thanks in advance-
trevorb

View 3 Replies View Related

Inserting Values From Column Datatype XML

Dec 20, 2013

I am having Test table with (id int , DataDescription xml) . I need to read the values from DataDescription column and insert into one table.

View 2 Replies View Related

How To Delete All The Values In A Table Before Inserting New Values.

Jun 9, 2008

Gurus,
I have two list boxes, user can move items back n forth, from second listbox I am inserting values into a table. So far everything is working fine.
Now I want to delete all the existing  values from the table before inserting evertime..Please help me in this I dont know what to do.
thanks
 kalloo
 

View 8 Replies View Related

Checking To See If Values Are In A Table Or Not -- If Not Then Inserting The Values.

Jun 22, 2005

I'm trying to checking my production table table_a against a working table table_b (which i'm downlading data to)Here are the collumns i have in table_a and table_bDescription | FundID (this is not my PK) | Money I'm running an update if there is already vaule in the money collumn.  I check to see if table_a matches table_b...if not i update table a with table b's value where FundID match up.What i'm having trouble on is if there is no record in table_a but there is a record in table_b.  How can I insert that record into table_a?  I would like to do all of this (the update and insert statement in one stored proc. if possible.  )If anyone has this answer please let me know.Thanks,RB

View 3 Replies View Related

I Have Created A Table Table With Name As Varchar And Id As Int. Now I Have Started Inserting The Rows Like, Insert Into Table Values ('arun',20).

Jan 31, 2008

I have created a table Table with name as Varchar and id as int. Now i have started inserting the rows like, insert into Table values ('arun',20).Yes i have inserted a row in the table. Now i have got the values " arun's ", 50.                 insert into Table values('arun's',20)  My sqlserver is giving me an error instead of inserting the row. How will you solve this problem? 
 

View 3 Replies View Related

Inserting Varchar Values Which Is Int Value In Int Column In Server

Aug 6, 2015

IF I have a table like the below one and i have to insert a number value which is inserted as varchar in an int column  then what is expected behavior of this statements .

create
table stud
(id
int)
insert
into stud
values ('1').

I thought it should fail but it succeeds...

View 4 Replies View Related

Selecting Multiple Values From One Table

Apr 29, 2008

I have a sql select query that I'm pulling from a "Years" table to link to 3 columns in an Items table.ZCValuesYear table has two colums: YearID and YearYearID        Year1            20042            20053            20064            20075            2008...I want to bind the "Year" value to the three colums in the ZCItem table:     ItemUseFirstYearID     ItemUseLastYearID     ItemYearIDThe query below will pull all the "ID's" for each of the colums, but how would I make it pull the "Year" value (instead of record 4, it would pull 2007 instead)?<asp:SqlDataSource ID="sqlItemSelect" runat="server"         ConnectionString="<%$ ConnectionStrings:MyConnString %>" SelectCommand="SELECT ZCPartVault.PartVaultID, ZCPartVault.PartVaultItemID, ZCValuesYear.Year, ZCItem.ItemName, ZCItem.ItemUseFirstYearID, ZCItem.ItemUseLastYearID         FROM ZCPartVault     FULL OUTER JOIN ZCItem ON ZCPartVault.PartVaultItemID = ZCItem.ItemID     FULL OUTER JOIN ZCValuesYear ON ZCItem.ItemUseLastYearID = ZCValuesYear.YearID AND ZCItem.ItemUseFirstYearID = ZCValuesYear.YearID AND ZCItem.ItemYearID = ZCValuesYear.YearID" >        </asp:SqlDataSource>       

View 2 Replies View Related

Selecting From Table And Adding Ur Own Values

May 19, 2008

Hey all

This is probably the wrong category to post my question in. Apologies if it is.

I have got a Data Flow Task that has an OLE DB Source and a Flat file destination.

Is there a way to do the following:

SELECT id,'31809','C:LCImportDataImages' & id & '.jpg', '1' FROM table1

This obviously doesn't work but I want to insert the id from the table, followed by the value '31809', followed by 'C:LCImportDataImagesid.jpg', followed by '1'

So, the id in 'C:LCImportDataImagesid.jpg' is the same as the id from the table.

I want the file to look like:

1, 31809, C:LCImportDataImages1.jpg, 1
2, 31809, C:LCImportDataImages2.jpg, 1
5, 31809, C:LCImportDataImages5.jpg, 1
etc...

I would really appreciate it if someone could point me to the right direction.

I am trying to work on it..will put up a solution if I find one myself.

Many thanks,

Rupa

View 12 Replies View Related

Inserting Values Intoto Only Column Based On A Condition

Sep 21, 2007



Hi,
I have at table as foolows
Table Cat3
{

ID,
Update datetime
}


and also have a master table as follows

Table Master
{

ID,
Cat1 Datetime,
Cat2 datettime
}


My requirement is to alter themaster table schema i.e to add a column with the name as of the table name i.e Cat3 and will lok lie as foolows
Table Master
{

ID,
Cat1 Datetime,
Cat2 datettime,
Cat3 Datetime
}

I would like to insert the data to this column. The sample output is as follows

Before insertng the data of table ;Cat3' into the Master table
Table Master
{

Id Cat1 Cat2
---------------------------------
1 D1 D2
2 D2 NULL
3 D3 D4
}


And The Cat3 table data is as follows

Table Cat3
{
ID Update
--------------------------
1 D5
3 D6
4 D7

}

The final putput of the master table should be as follows

Table Master
{

Id Cat1 Cat2 Cat3
------------------------------------------------------
1 D1 D2 D5
2 D2 NULL NULL
3 D3 D4 D6
4 NULL NULL D7
}



Can any one please let me know the query to achieve this

Thank you very much for your time and support

~Moahn

View 10 Replies View Related

Inserting A Column Filled With Unique Incremental Values

Jan 8, 2008

Hi all,

I've got a large table (3mil records) with a number of columns, but currently no way to refer to any individual column. I therefore need a primary key, but does anyone know of a SQL statement I can use that will create a column (say, ID) that is automatically filled with an incrementing 'counter'? Or, instead, how can I set unique incremental values after first creating the column?

Many thanks,

Graham

View 7 Replies View Related

SQL 2012 :: How To Check Existing Values In A Column For Duplicates Before Inserting

Aug 12, 2014

I have the following objective:

1. I want to check a column to see if there are values (to Eliminate dups)
2. Once checked the values in a column, if not found insert the new value

Here is my code for this:

ALTER TRIGGER DUPLICATES ON AMGR_User_Fields_Tbl
-- When inserting or updating
AFTER INSERT, UPDATE AS

-- Declare the variables
DECLARE @AN varchar(200)

[Code] ....

View 1 Replies View Related

Transact SQL :: Selecting Rows As Column Name And Other Column Values As Rows

Jun 25, 2015

I have questions and answers from one table, I need to select questions as column names and answers column values as the results for the questions column.

View 28 Replies View Related

Inserting Multiple Values From Another Table

Oct 2, 2007

Hi,
I am trying to insert multiple values from another table as well as an addition value defined by me. Here's my code which is obviously incorrect at the AND statement:
Insert Into table_1 (ID, Col_1, Col_2)Select ID, Col_A, Col_B From table_A  AND  table1.Col_3 = 'XYZ'
Where table_A.Col_A IS NOT NULL
 
Pls advise on the correct way of constructing this statement.
Many Thanks

View 8 Replies View Related

Inserting Values In A Table In A Sequence

Apr 10, 2008

i have a table whose Primary Key is "UserID". the sample "UserID"  are M1,M2,M3,M4,B1,B2,B3 .
i want that when i insert a valuse "M4" in the table ,by pressing Submit Button.
it should not be at the end or at the start of table.
Rather it should be next to  M3. like the following
M1
M2
M3
M4
M5
B1
B2
B3
i need the C# code of how to do that !!!!
Thanks

View 7 Replies View Related

Need Help Inserting Data Into Table With Sql Insert Into Using Textbox Values

Oct 6, 2007

the error message I get is
{"Object reference not set to an instance of an object."}
and it points to <  Tickr As String = CType(FindControl("TickerTextbx"), TextBox).Text >   
 this is my code":
 Protected Sub TickMastBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TickMastBtn.Click
REM Collect variablesDim Tickr As String = CType(FindControl("TickerTextbx"), TextBox).Text
Dim Comp As String = CType(FindControl("CoTextbx"), TextBox).TextDim Exch As String = CType(FindControl("ExchTextbx"), TextBox).Text
REM Create connection and command objectsDim cn As New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataVTRADE.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")Dim cmd As New SqlCommand
cmd.Connection = cn
REM Build our parameterized insert statementDim sql As New StringBuilder
sql.Append("INSERT INTO TickerMaster ")sql.Append("(Ticker,Company,Exchange,) ")sql.Append("VALUES (@Tickr,@Comp,@Exch,)")
cmd.CommandText = sql.ToString
REM Add parameter values to command
REM Parameters used to protect DB from SQL injection attacksWith cmd.Parameters
.Add("Tickr", SqlDbType.Int).Value = Tickr.Add("Comp", SqlDbType.VarChar).Value = Comp
.Add("Exch", SqlDbType.VarChar).Value = Exch
End With
REM Now execute the statement
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
End Sub

View 3 Replies View Related

SQL Server 2014 :: Inserting Distinct Values From One To Another Table

May 28, 2015

I have the following table

Table A

Col1

0118F
0118R
5678
0118F
0118R
5678
5678
5678
0118F
0118R

I want to insert only distinct values of Col1 from table A to another table

Insert into TableB

(
UserName, ProjectName, processdate, Recordprocess, Comments, RecordProcessExt
)
values(@UserName, 'Test Project', getDate(), distinct Col1 from Table1, 'Test Comments', distinct col1+ 'TR' from TableA)

How can I accomplish the above. I need to insert distinct column from TableA to RecordProcess and col1+'Tr' to recordprocessExt.I can do it with cursor. I don't know any other way.

Also, there are other columns in Table A. I am using sql server 2005.

View 1 Replies View Related

Inserting Few Recordsets Into Temp Table Containing NULL Values

Jul 20, 2005

HiI need some help on achieving the following:I wrote a querie which collects Data out of three Tables, the Resultlooks like this:SET NOCOUNT ONDECLARE @ROWINTDECLARE @CURPTNO CURSORSET @CURPTNO = CURSORFORSELECT * FROM TEMPOPEN @CURPTNOFETCH NEXT FROM @CURPTNOINTO @ROWWHILE (@@FETCH_STATUS = 0)BEGINSELECT ONE.CYNO, ONE.ROLE, ONE.ROL_BEZ, ONE.PTNO, ONE.NOCY, TWO.TEXTAS NOCY_TEXTFROM(SELECT CY.CYNO,RE.CYNO AS RECYNO, RTRIM(RE.ROLE) AS ROLE, RTRIM(V_ROLE.TEXT) ASROL_BEZ,RE.PTNO AS PTNO, RTRIM(RE.NAME) AS SACHBEARBEITER, RE.NOCYFROM CYRIGHT OUTER JOINRE ON RE.CYNO = CY.CYNOINNER JOINV_ROLE ON RE.ROLE = V_ROLE.CODEWHERE (RE.PTNO IN(SELECT PT.PTNOFROM PTWHERE PT.PTNO IN(@ROW)AND V_ROLE.LANGUAGE = PT.CLANG))) AS ONELEFT JOIN(SELECT V_NOCY.CODE, V_NOCY.TEXTFROM V_NOCYINNER JOINPT ON PT.CLANG = V_NOCY.LANGUAGEAND PT.PTNO IN (SELECT PT.PTNOFROM PTWHERE PT.PTNO IN(@ROW))) AS TWOON ONE.NOCY = TWO.CODEFETCH NEXT FROM @CURPTNOINTO @ROWENDCLOSE @CURPTNODEALLOCATE @CURPTNOThe Result looks like this:RS1:6313,1300,Architekt,99737505,NULL,NULL2392762,100,Bauherr,99737505,NULL,NULLRS2:2693265,100,Bauherr,99756900,NULL,NULLNULL,1,Planer,99756900,2,Bauherr macht Pläne selberRS3:2691919,100,Bauherr,99755058,NULL,NULL2691962,6000,Kontakt,99755058,NULL,NULLMy Problem is, that I need to have all the Resultsets in one Table atthe end.So my further undertaking was to create a Temp Table with theexpectation to receive all the resultsets in one Step.The TSQL for this looks like that:SET NOCOUNT ONCREATE TABLE #CYRE_TEMP(CYNOINT NULL,ROLEINT NULL,ROL_BEZVARCHAR (60) NULL,PTNOINT NULL ,NOCYINT NULL,TEXTVARCHAR (60) NULL)GODECLARE @CYNOINT,@ROLEINT,@ROL_BEZVARCHAR (60),@PTNOINT,@NOCYINT,@TEXTVARCHAR (60),@ROWINT,@CURPTNOCURSORSET @CURPTNO = CURSOR FORSELECT PTNO FROM TEMPOPEN @CURPTNOFETCH NEXT FROM @CURPTNOINTO @ROWWHILE (@@FETCH_STATUS = 0)BEGININSERT INTO #CYRE_TEMP (CYNO, ROLE, ROL_BEZ, PTNO, NOCY, TEXT)VALUES(@CYNO,@ROLE ,@ROL_BEZ ,@PTNO ,@NOCY ,@TEXT)SELECT @CYNO = ONE.CYNO,@ROLE = ONE.ROLE,@ROL_BEZ = ONE.ROL_BEZ,@PTNO = ONE.PTNO,@NOCY = ONE.NOCY,@TEXT = TWO.TEXTFROM(SELECT CY.CYNO, RTRIM(RE.ROLE) AS ROLE, RTRIM(V_ROLE.TEXT) ASROL_BEZ,RE.PTNO AS PTNO, RTRIM(RE.NAME) AS SACHBEARBEITER, RE.NOCYFROM CYRIGHT OUTER JOINRE ON RE.CYNO = CY.CYNOINNER JOINV_ROLE ON RE.ROLE = V_ROLE.CODEWHERE (RE.PTNO IN(SELECT PT.PTNOFROM PTWHERE PT.PTNO =@ROWAND V_ROLE.LANGUAGE = PT.CLANG))) AS ONELEFT JOIN(SELECT V_NOCY.CODE, V_NOCY.TEXTFROM V_NOCYINNER JOINPT ON PT.CLANG = V_NOCY.LANGUAGEAND PT.PTNO IN (SELECT PT.PTNOFROM PTWHERE PT.PTNO =@ROW)) AS TWOON ONE.NOCY = TWO.CODEFETCH NEXT FROM @CURPTNOINTO @ROWENDCLOSE @CURPTNODEALLOCATE @CURPTNOSELECT * FROM #CYRE_TEMPDROP TABLE #CYRE_TEMPGOAnd the Output looks like this now:Q1:NULL,NULL,NULL,NULL,NULL,NULL2392762,100,Bauherr,99737505,NULL,NULLNULL,1,Planer,99756900,2,Bauherr macht Pläne selberCan someone help me getting all the 6 Rows into one Table as Output?I appreciate any available Help on this..Ssscha

View 1 Replies View Related

Transact SQL :: Inserting Values Into Table - Conversion Failed

Apr 26, 2015

Simple table created but unable to insert values into it due to the above error

CREATE TABLE Ingredient(
ingredientCode CHAR(10)
PRIMARY KEY NOT NULL,
name VARCHAR(20),
ingreType VARCHAR(20),

[Code] .....

--always received this error: Conversion failed when converting date and/or time from character string

View 6 Replies View Related

Inserting Global Variables Storing Values In A Table

Oct 5, 2006

Hi,

I need a resolution of the following issue:

Following SQL is to be inserted in an audit table :

INSERT INTO GLOBAL_VARIABLE_LOAD

([LOAD_ID]

,[LOAD_STATUS]

,[START_TIME]

,[END_TIME])

VALUES

(@P_LOAD_ID

,@P_LOAD_STATUS

,@P_START_TIME

,@P_END_TIME)

@P_LOAD_ID, @P_LOAD_STATUS, @P_START_TIME, @P_END_TIME are the 4 parameters mapped to global variables (At package Level) which store values mapped in a previous SQL Task in my control flow.

Following Error Message is thrown on executing the SQL Task:

Invalid object name 'GLOBAL_VARIABLE_LOAD'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

Can anyone guide me as to how should I go about saving values in global variables and inserting them in a table.

Thanks in advance.

Regards,

Aman

View 4 Replies View Related

Inserting Into Table With One Column 1,2,3,4...

Jan 14, 2005

Hi,

I have a temporary table into which I insert bulk data from a stored procedure output. It will be easy for me if the temptable can have a column with sequential numbers 1,2,3,4,. I could not figure out a way to do it. This is the stripped down sql what I have in the stored procedure.
insert into temptable select name, email, date from usertable where condition = xyz.
I tried auto increment column with seed 1, increment 1. But if I delete and insert again it does not start from 1. Is there any way to accompolish this? It will make the front-end code very simple.

Thank you

View 3 Replies View Related

Selecting Rows From A Table Based On First 2 Characters Of 12 Char Column

Oct 21, 2013

I have to select rows from a table

if the first 2 characters of a 12 char column are
'GB'

Select BFKEYC from table where

I have a hokey way of doing it but it looks embarrassing:

BFKEYC GT 'GA9999999999'
AND BFKEYC LT 'GC'

View 8 Replies View Related

Inserting A Column In An Existing Table

Mar 5, 2004

I have an existing table (see below).

-----------
[FormCode] [varchar] (4) NULL ,
[FiscalYear] [char] (4) NULL
-----------

I want to add the column below after the [FormCode] when my SPROC runs.
-----------
[FiscalMonth] [char] (2) NULL
-----------

Any ideas would be a big help?
TIF

View 7 Replies View Related

Millisecond Values Missing When Inserting Datetime Into Datetime Column Of Sql Server

Jul 9, 2007

Hi,
I'm inserting a datetime values into sql server 2000 from c#

SQL server table details
Table nameate_test
columnname datatype
No int
date_t DateTime

C# coding
SqlConnection connectionToDatabase = new SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=testdb;Integrated Security=SSPI");
connectionToDatabase.Open();
DataTable dt1 = new DataTable();
dt1.Columns.Add("no",typeof(System.Int16));
dt1.Columns.Add("date_t", typeof(System.DateTime));
DataRow dr = dt1.NewRow();
dr["no"] = 1;
dr["date_t"] = DateTime.Now;
dt1.Rows.Add(dr);
for(int i=0;i<dt1.Rows.Count;i++)
{
string str=dt1.Rows["no"].ToString();
DateTime dt=(DateTime)dt1.Rows["date_t"];
string insertQuery = "insert into date_test values(" + str + ",'" + dt + "')";
SqlCommand cmd = new SqlCommand(insertQuery, connectionToDatabase);
cmd.ExecuteNonQuery();
MessageBox.Show("saved");
}
When I run the above code, data is inserted into the table
The value in the date_t column is 2007-07-09 22:10:11 000.The milliseconds value is always 000 only.I need the millisecond values also in date_t column.
Is there any conversion needed for millisecond values?

thanks,
Mani

View 3 Replies View Related

Reporting Services :: Selecting Multiple Parameters Values For Comma Separated Values In SSRS?

Jun 17, 2012

I am SSRS user, We have a .net UI from where we want to pass multi select values, but these values are comma separated in the database. how can I write a sql query such that when I select multi values on my UI, the comma separated values are take care of.

View 5 Replies View Related

Inserting Data Into Table - Column Does Not Allow Nulls

Sep 26, 2013

I'm inserting data from a c# webservice into a table via a stored procedure, but I get a Column does not allow nulls on the @alert_id column/field. It is set as int and allow nulls is not ticked.

Here's the sql:

USE [aren]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [aren1002].[ArenAlertInsert]

[Code] ....

View 7 Replies View Related







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