Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 11th, 2007, 08:28 PM
Registered User
 
Join Date: Sep 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to insert these string into database

hai all,

can any one teach me how to insert the string like below into sqlserver

'1001','1002','1003','1004','1005'

thanks

 
Old September 11th, 2007, 10:02 PM
Authorized User
 
Join Date: Jul 2007
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vksingh24
Default

if you are inserting them into different columns then

1) Open the SQL Query Analyzer

2) use the following syntax

USE <dataBase_Name>
INSERT INTO <TABLE_NAME> (COLUMN_NAME1,COLUMN_NAME2,COLUMN_NAME3,COLUMN_NAM E4,COLUMN_NAME5) VALUES('1001','1002','1003','1004','1005')

3) Press F5

__________________
Vikash Kumar Singh
 
Old September 11th, 2007, 10:10 PM
Registered User
 
Join Date: Sep 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

no, i trying to insert the string into 1 column, but the single quotes inside the string maked the query become a error

 
Old September 22nd, 2007, 07:05 AM
Authorized User
 
Join Date: Dec 2006
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Guys,

Do Like this.

Add two quotes ('') insted of single quotes(') at each place in input
string. And this string will also take in single quoted.

Your original String is :
'1001','1002','1003','1004','1005'

you have to change in this format
  '''1001'',''1002'',''1003'',''1004'',''1005'''

Try This.
Best of luck.









Similar Threads
Thread Thread Starter Forum Replies Last Post
Using INSERT INTO with a string Variable Suspect Access VBA 2 January 6th, 2015 11:25 AM
String to DateTIme for Insert plymnet Classic ASP Databases 1 August 21st, 2005 11:09 PM
Insert HTML at certain point in string. interrupt Javascript How-To 1 June 13th, 2005 07:21 AM
insert concatinate string problem :( meemee SQL Server 2000 2 February 11th, 2004 09:05 PM
INSERT string into a Microsoft Access Database gsolis Classic ASP Databases 1 December 31st, 2003 05:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.