Random Insertion
Jun 10, 2008Hi Experts ,
I want to insert datas randomly to all columns of a table.The columns have different datatypes like int,varchar,datetime. What to do??? It is urgent so please help.
TIA
RKNAIR
Hi Experts ,
I want to insert datas randomly to all columns of a table.The columns have different datatypes like int,varchar,datetime. What to do??? It is urgent so please help.
TIA
RKNAIR
Hi Experts ,
I want to insert datas randomly to all columns of a table.The columns have different datatypes like int,varchar,datetime. How to create a procedure for the same??? please help.
TIA
RKNAIR
Hi,I need to extract randomly 5 records from the table "Questions". Now I useSELECT TOP 5 FROM Questions ORDERBY NEWID()And it works. The problem is that I need an additional thing: if SQLextracts record with ID=4, then it should not extract record with ID=9,because they are similar. I mean, I'd like something to tell SQL that if itextracts some questions, then it SHOULD NOT extract other ones.How can I do it?Thanks!Luke
View 1 Replies View RelatedI'm using ASP and SQL Serv 2000. What I need to get from 2 tables (company & customers) is random 10 customers from random 20 comp.
Anyone got an idea how to do this??? I've spent 2 days trying to get stored proc. or T-SQL to work, but nothing good came out of it. I can get 1 comp and 10 cust, but not a grouped list of 20 comp. w/ 10 cust. each.
Help is greatly appreciated.
Please someone help to get out this situation
How to perform bulk insertion in a table for different records
How to bold a value while inserting into the table in SQL 2005?
View 1 Replies View RelatedHow to get information , if there is no insertion of a row in a table within particular span of time.
View 2 Replies View RelatedI am using vs2005 and sqlserver2000
My problem is i have 5 checkboxes and some textboxes.In this user selects the checkbox and textboxes dynamically .In this user selects one or two or three or when user selects header checkbox then all checkboxes are selected.And in my database i mentioned a single column for group of checkboes.So how should i insert the data into database
dim con as new sqlconnection("userid=sa;pwd=; initial catalog=test")
dim cmd as sql command
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
cmd.CommandText = "insert into check values(" what should i write here ....'" & text.text &"','" @ text2.text "'... ")
con.open()
cmd.executenonquery()
con.close()
End Sub
Hi,
I am working on an application that is to read a large number of XML files, take out specific values from each file, and store these in a SQL server so that reports can be generated from these values. There are some 15-20,000 files for each month of the year. I am OK with parsing the files and getting the fields that I need but I don't want to insert one record at a time as I parse the files. I was told that I can create a .exe file that parses the xml files and stores the required values in a csv file and use these csv files to initiate a bulk insert, using Business Intelligence Studio. I have not been able to find any info or article on how to do this. Any help on how I can accomplish this, or alternate solutions is greatly appreciated.
Hi guys,i want to make a scheduled job that inserts 10 user defined row each minute continously in enterprise manager
View 1 Replies View Relatedset ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[usp_World_Ins_data]
-- Add the parameters for the stored procedure here
@UserName nvarchar(50),
@Password nvarchar(15),
@Email nvarchar(100),
@IsChecked bit,
@ReceiveNews bit
AS
BEGIN
SET NOCOUNT ON;
IF EXISTS(SELECT UserName FROM World_Registration WHERE UserName=@UserName)
RAISERROR('Username exists',16,1)
ELSE IF EXISTS(SELECT Email FROM World_Registration WHERE Email=@Email)
RAISERROR('Email exists',16,1)
ELSE
INSERT INTO World_Registration(UserName,Password,Email,IsChecked,ReceiveNews)
VALUES(@UserName,@Password,@Email,@IsChecked,@ReceiveNews)
END
if executed once it works properly like
[usp_World_Ins_data] 'aa','aa','ravinderpal@netbiz.in','1','1'
while if i m trying to execute stored procedure like this three times
i mean more than one time
[usp_World_Ins_data] 'aa','aa','ravinderpal@netbiz.in','1','1'
[usp_World_Ins_data] 'aa','aa','ravinderpal@netbiz.in','1','1'
[usp_World_Ins_data] 'aa','aa','ravinderpal@netbiz.in','1','1'
it gives error:
Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near 'usp_World_Ins_data'.
pls help me
i am new to sql server
i want to insert five rows continously in sql server database.
my problem is like this .
i am inserting user datails. i want to get the userid which is an identity column.with the userid i want to insert userid and roleid in another table.Roleid values 1 to 5. ie constant.
an sql procedure is required.
Hi everyone,I tried to upload my database to my web host. Nevertheless as they donot give me enough permission to perform some DTS thus I have togenerate script to do it myself. The problem is MSSQL scriptgeneration operation can only generate the definitions of the objects,no data insertion sql is created.So is there any method to create insertion script for all the tablesin my database (they have automated increment key as well)Hope for your response!Thank you
View 2 Replies View RelatedI have a table called ACCOUNTS which has 60,000 rows already in it. It has a columns called PolicyNo and PremiumBasisCode. PolicyNo has data inside it whereas Premiumbasiscode is NULL.
Now I have to insert the data inside the PremiumBasisCode Column from Table1 into ACCOUNTS table by joining them on Policy No (Inner Join).
One thing to remember, there are already 60,000 rows for which this insert needs to take place. What will be the best approach.
Chintan
I am working in ASP.Net2.0 and Sql server 2005.Using asp button(FormView) I am trying to insert the data from the form into the database and at the same time want to move on to another page indicating the succes of insertion.My code: <asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"Text="Submit" PostBackUrl="~/ClinicDownload.aspx"></asp:Button> It is moving on to another page, but no insertion is taking place. If I don't give the PostBackUrl then I can insert. I want to do both in one click....Hope someone can help me. Regardspreeshma
View 1 Replies View RelatedHi there,
Is there a way to retrieve the set of primary keys from an inserted record, especially when the primary keys are generated upon insertion (ex. identity, uniqueid)? Basically I need to get the ID of the record I just inserted so that I can use it as a reference to that record in other places.
I'm using MS SQL and raw SQL commands (ie. no database interfacing objects). I'm hoping I can tag some sort of SELECT statement on the end of the INSERT command that will give me the results that I need.
Thanks!
I am using BLL for inserting my data. I have some date filed and I have declare that field in BLL as date only. But still it is giving me error string in wrong format. My database is in SQL Server2005
View 6 Replies View RelatedHi Friends,I have 3 labels Steet,City,Pincode and 3 textboxes related to the labels and one button as nae 'Address'I gave the data for Street:abc,City:xyz,Pincode:123 and have to insert into the table.I created one table in the database with table name Adreess and column address varchar(100)but after giving the values in the textboxes and clicked on the button its throwing the exception i.e System.Data.SqlClient.SqlException: The name "abcxyz123" is not permitted in
this context. Valid expressions are constants, constant expressions, and (in
some contexts) variables. Column names are not permitted.I wrote the code like following protected void Button1_Click(object sender, EventArgs e) { string street = txtStreetNo.Text; string city = txtCity.Text; string pincode = txtPincode.Text; string com = street + city+pincode; conn.Open(); SqlDataAdapter daInsert = new SqlDataAdapter("insert into Address values(" + com.ToString() + ")", conn); daInsert.SelectCommand.ExecuteNonQuery();--->here its giving the exception conn.Close(); Response.Write("the values are inserted"); }Please any one tell me am I did the code write or not if its not please give any suggetionsthanksGeeta
Hey,
I would like to prepare a string variable for SQL insertion. Like, replacing all the single quotes with the HTML code equivilent and such. Has anyone written alything like this? Is there a tutorial on the web for it? A control maybe?
Mike
Hi,
I'm having a small problem inserting japanese text into a ms sql database.
All the fields are of type nvarchar and in my insert statement I use N'the value of the string' to make sure it insert unicode text.
Without the N I get only '??????' in my cells and with the N I see only empty squares.
Anyone have any solution how I can insert japanese text into mssql ?
thanks in advance
Jan
Hi,
I need to insert some registers in a table. These registers have three fileds: field1, field2 and field3. I don't want to insert a register if in the table already exists a row with the field2 and field3 combination of that register. And I don't want to declare these fields as key fields. How can I filter a "destination" table by two fields?
I'll appreciate your answer
Thanks
F.
hello
i want to ask if the insertion of a record into a partion is slower than insertion it into a non partitioned table or not?
cuz sql has to decide to wich partion the record has to insert according to the partitioning key and is this decesion process is making insertion slower ?
I want XML data to be inserted int SQL table but could not figure out. #Currency is my table with assocaite columns and @XMLCurrency is a variable which holds XML string. How can I insert this XML data to my table.
Create table #Currency (CurrencyId int ,ISOCode nvarchar(10),ISONumbricCOde int,ISOName nvarchar(50), IsEnabledForMPV int default 0)
Declare @XMLCurrency nvarchar(max)
Set @XMLCurrency='<R><T><A>0</A><B>USD</B><C>840</C><D>US Dollar</D></T></R>'
Value 840 should insert into column ISONumbricCOde .
value USD should be insert into ISOCode column.
value 0 should insert into column CurrencyId.
values US Dollar should insert into column ISOName .
i am executing this scripts in sql server2000
SELECT
'INSERT into temp values(data1, data2, data3)' +
'SELECT ' +
CONVERT(VARCHAR(20), temp2.data1) + ', ' + CONVERT(VARCHAR(20), temp2.data2) + ', ' + '''' + CONVERT(VARCHAR(20), temp2.data3) + ''''
FROM temp, temp2
order by temp2.data1
now my table temp and temp2 both has folowing fields and data type
data1 int
data2 int
data3 varchar(20)
befor execution i have 0 records in temp and 10 records in temp2.
this scripts supposed to add all 10 records from temp2 to temp but it does nothing. evevn it is not giving error too.
Hi,
i have 4 tables, each consist of app. 10000000 rows.They have same columns (fTime[datetime] and bid[money]).What i wanna do is to collect all of datas into one of the tables, in ascending order by fTime.
PS i wanna do it as fast as possible as well
Hi everyone,
i am self-learner for sql server 2005.
can anybody help me,
currently, i have two tables..called
employee
(eg. empid varchar(10),languageid(10),quaid(10))
unprocesstable
(eg.unid uniqueidentifier, unpname varchar(50),unptablename varchar(50),empid (10) )
how to create another store procedure for other insertion?
eg.. whatever other language is inserted into employee by user which is not in the "language" table ,
it will inserted into (table "unprocesstable") under (column "unpname")
thank you so much!
Rg
Hai,Here is a query that i am creating a tablecreate table test10 (item varchar(10),state bit)now at the time of insertion i will enter like thisinsert into test10 values ('book' ,1)but at the time of display in the table i wantitem statebook truefrom above i want to ask that when i am going to insert 1 i want toget true and 0 as false.I never enter true or false in the insertcommand. please help me in coding.thankyou,lucky.Reply
View 3 Replies View RelatedHi,Env is ms sql server 2000.ddl:create table srchPool(tid int primary key, taid int, s tynyint, uidtynyint);-- and sql server automatically creates a clustered index for the pkdml:insert into srchPool(taid,s,uid)select article_id, 99, 1484from targetTBLwhere article_content LIKE '% presentation %';insert into srchPool(taid,s,uid)select article_id, 55, 1484from targetTBLwhere article_content LIKE '% demonstration %';-- a few more similar queries ...The above insertion query TOOK about 2000ms to execute, too too slow,would be much faster if I insert the data sets into a temp tbl likeselect article_id, 99, 1484 into #srchPool(taid,s,uid)from targetTBLwhere article_content LIKE '% presentation %';-- once its use is finished and drop it?Many thanks.
View 7 Replies View RelatedLooking for some insight from the professionals about how they handlerow inserts. Specifically single row inserts through a storedprocedure versus bulk inserts.One argument are people who say all inserts (and updates and deletionsI guess) should go through stored procedures. The reasoning is thatthe developers that code the client side have no reason to understandHOW the data is stored, just that it is. Another problem is an insertthat deals with multiple tables. It would be very easy for thedeveloper to forget a step. That last point also applies to businesslogic. In my case, adding a security to our SecurityMaster can touch 1to 4 tables depending on the type of security. Also, certain fieldsare required while others are set to null for depending on the type.Because a stored procedure cannot be passed datasets but only scalarvalues, when you need to deal with multiple (i.e. bulk) rows you arestuck using cursors. This post is NOT about the pros and cons ofcursors. There are plenty of those on the boards (some of themprobably started by me and showing my understanding (or morecorrectly, lack of) of the way to do things). Stored procedures alsogive you the ability to abort and/or log inserts that cannot happenbecause of contraints and/or business rule failures.Another approach is to write code (not accessible from outside thedatabase) that handles bulk inserts. You would need to write in rulesto "extract" or "exclude" rows that do not match constraints orbusiness rules otherwise ALL the inserts would fail because of one badrow. I guess you could put the "potential" rows into a temp table.Apply your rules to the temp table and delete / move rows that wouldfail. Any rows left can that be bulk inserted. (You could also use therows that were moved to another temp table for logging why theyfailed.)So that leaves use with two possible ways to get data into the system.A single row based approach for client apps and a bulk based forinternal use. But that leaves use with another problem. You now havebusiness logic in TWO separate areas. You have to remember to modifycode or fix bugs in multiple locations.For those that are still reading my post, my question is...How do you handle this? What is the approach you take?
View 4 Replies View Related
hi frnds,
im very new to DTS package.
i had created the DTS package in SQL Server 2000 to read from the textfile and to populate the values in DB.
Source file is text file(delimited file with | as delimiter), destination is DB.
while inserting the records in DB . im getting the error as :
Transformcopy DTS transformation _ 1 conversion error : conevrsion invalid for datatypeson column pair 1 (Source column 'Col022(DBTYPE_STR),destination column usr_nct_timestp(DBTYPE_DBTIMESTAMP)
but i dont hvae NULL values in any of the cols.
please help me .
thnkx in advance. its urgent.
hi, i'm quite new to sql and would like to ask if there is any way to automatically insert records from a table, for example dailyTransaction, into another table, for example transactionHistory, daily maybe around midnight or something. would also have to delete the records in dailyTransaction after it has been copied over to transactionHistory table i've done a bit of searching around and i think i have to use job to do this but i have no idea how to implement it. looked through the libary in msdn but i'm still not too sure. would really appreciate any help. thanks
View 5 Replies View Related
HI There,
I am using SQL Server 2005 and C#.Net 2005 as a front end.
I have written stored procedure to insert record into table. In that table i have field named 'TARIFF_CODE' with type 'Varchar' and size 15.
I have also written front end code with Sqlcommand object to call this sp and passed all proper required parameter values.
ICDPara = new SqlParameter();
ICDPara.ParameterName = "@Tariff_code";
ICDPara.Direction = ParameterDirection.Input;
ICDPara.SqlDbType = SqlDbType.VarChar;
ICDPara.Value = Tariff_code_act; --------------------> [e.g TR000012].
ICDPara.Size = 15;
ICDCmd.Parameters.Add(ICDPara);
But when i execute it and see it in Database i got only first 5 chars for pass value for field 'TARIFF_CODE'.
Insterestingly, it wont happens when i execute that SP through SSMS.
Please help me out.
Regards And Thanks.
Hi,
Does anyone have any sugestions as to the best way to achieve the following?
I want to display a list of products in a GridView. Against each product I want to place a button which will add the product to a "wish list" table.
I need to be able to check that the product has not already been inserted into the wish list.
Either suggested methods or links to tutorials will be appreciated.
Thanks in advance.