SS64 Discussion Forum

You are not logged in.

#1 2008-06-27 04:47:46

gr8.jain
New Shoes
Registered: 2008-06-27
Posts: 4

getting error in creating and inserting table

hi all
i have a query
can any one tell me that when i create table in sql server 2005, it accept Colon  ':'  and dash  '-' in tablename.
but when i try this create table with VBdotNet programm i got error
'syntex error near <table name>:'


Very Curious To See Your Replies
wall
gr8.jain
Mumbai, India

Offline

#2 2008-06-27 04:59:13

gr8.jain
New Shoes
Registered: 2008-06-27
Posts: 4

Re: getting error in creating and inserting table

i got this error at
myConnObj.Open()
myCommand = New SqlCommand("create table abc:xyz(myColumn1 varchar2(30) Not Null,myColumn2 numeric(10,2) Not Null",myConnObj)
myCommand.ExecuteNonQuery()               -----error during debug

please help me how to use command for create table, insert into table and update table with table name contains special character like ":", "/", <blank space> " " or "-"

thanks in advance

????


Very Curious To See Your Replies
wall
gr8.jain
Mumbai, India

Offline

#3 2008-06-27 05:00:36

gr8.jain
New Shoes
Registered: 2008-06-27
Posts: 4

Re: getting error in creating and inserting table

yikes  sad  neutral  cool  neutral  mad  mad


Very Curious To See Your Replies
wall
gr8.jain
Mumbai, India

Offline

#4 2008-06-27 06:03:14

Simon Sheppard
Super Administrator
Registered: 2005-08-27
Posts: 506
Website

Re: getting error in creating and inserting table

You will have to do something like create table "abc:xyz"

but I would recommend against it, having strange characters in tablenames is making a lot of work for yourself

See here for more naming conventions:
http://vyaskn.tripod.com/coding_conventions.htm

Offline

#5 2008-06-27 08:39:38

gr8.jain
New Shoes
Registered: 2008-06-27
Posts: 4

Re: getting error in creating and inserting table

Thanks Simon for your reply

but i have to do this actually i am importing data from database which already containing this type of table name which having (: /  - and space ) in their table name

i need to import table with same name in sql server and then getting all the data containg that table in sql server (that is some kind of synchronizing of database - you may be say)

i am able to create table with out these special character but then i have to get error  in fetching data becuase table name is differ
for that i use in VBdotnet - myVar = db.tablename.replace(":","")
so table like abc:Xyz is created as abcXyz


i think you got my point that now i am facing problem in import data

so better if i create table with same name

please try  to give any solution

thanks


Very Curious To See Your Replies
wall
gr8.jain
Mumbai, India

Offline

#6 2008-10-09 03:29:30

georgev
Just Registered
Registered: 2008-10-09
Posts: 1

Re: getting error in creating and inserting table

You need to use identifiers when using reserver words, words with spaces or funny characters in them:

http://doc.ddart.net/mssql/sql70/8_con_03_1.htm

CREATE TABLE [table:with,funny!characters] (...

Offline

Board footer

Powered by FluxBB