Hi,
the table 'l0382_project1' exists in sql server. I can see it.
Now in asp.net, i want to check whether it exists but i get "invalid column
name":
1st attempt:
comd.CommandText = "SELECT COUNT(*) FROM sys.tables WHERE [name] =
[l0382_project1]"
connection.Open()
nr = comd.ExecuteScalar()
Invalid column name 'l0382_project1'.
2nd attempt:
comd.CommandText = "SELECT COUNT(*) FROM sys.tables WHERE [name] =
['l0382_project1']"
connection.Open()
nr = comd.ExecuteScalar()
Invalid column name 'l0382_project1'.
Could somebody tell me the right syntax, please?
Thanks
Mich
Pawel Potasinski - 15 Aug 2007 21:21 GMT
comd.CommandText = "SELECT COUNT(*) FROM sys.tables WHERE [name] =
N'l0382_project1'"

Signature
Regards
Pawel Potasinski
[http://www.potasinski.pl]
> Hi,
>
[quoted text clipped - 21 lines]
> Thanks
> Mich
Tibor Karaszi - 15 Aug 2007 21:26 GMT
The name of the table in the context of your query is just a regular string, so the query should be:
WHERE [name] = 'l0382_project1'

Signature
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
> Hi,
>
[quoted text clipped - 21 lines]
> Thanks
> Mich
Mich - 15 Aug 2007 21:38 GMT
Thanks for replying. It works now.
> The name of the table in the context of your query is just a regular
> string, so the query should be:
[quoted text clipped - 26 lines]
>> Thanks
>> Mich