开发者

I have a problem creating stored procedure when I put a field with /

I have a field [Product/Ser开发者_如何转开发vices] in my table in sql server 2005. Now I want to create a stored procedure for that table, but it keep giving an error and when I put only Product in my table than stored procedure is working fine. Now I want to put [Product/Services] in my table so how can I do that?????


it is always a bad idea to try to include special characters in a column/variable/parameter/table/view/procedure/etc names. All of your code will have to dance around this bad decision forever.

Without any detail on your particular code and/or error message, all I can provide are these links on the the rules for naming things in SQL Server:

Identifiers

Delimited Identifiers

from the second link:

Microsoft SQL Server does not recognize variable names and stored procedure parameters that are delimited. These types of identifiers must comply with the rules for regular identifiers.

Your best bet is to just name the column something like Product_Services or ProductServices and you can have local variables and parameters named @Product_Services or @ProductServices.

Your next best bet is to leave the table alone and just names the local variables as @Product_Services or @ProductServices even though the table column is named [Product/Services].


Make sure you are properly quoting the name Product/Services as [Product/Services] whenever you are referring to it or using it of redefining it. [] are the quote characters in MS SQL Server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜