Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
bjornh
Yak Posting Veteran
87 Posts |
Posted - 2002-08-09 : 16:38:07
|
| hi,I've created this table:CREATE TABLE [dbo].[herkomst] ( [id] [int] IDENTITY (1, 1) NOT NULL , [website] [varchar] (50) COLLATE Latin1_General_CI_AS NULL , [url] [varchar] (300) COLLATE Latin1_General_CI_AS NULL ) ON [PRIMARY]GOAnd this SP:create procedure dbo.test @TableName VarChar(100), @website varchar(100), @url varchar(100)ASDeclare @SQL VarChar(1000)SELECT @SQL = 'insert into ' + @tableName + ' (website, url) values ("' + @website + '", "' + @url + '")'SELECT @SQL = @SQL + @TableNameExec ( @SQL)GOAnd I created this query to execute it:exec test 'herkomst', 'http://www.googel.nl/', 'http://www.google.nl/sksdk'gobut I get this error:Server: Msg 128, Level 15, State 1, Line 1The name 'http://www.googel.nl/' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.Can somebody please tell me what I did wrong up here? thanksBjorn |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-08-09 : 16:44:15
|
| You used double quotes (") to delimit a string in SQL Server, which uses single quotes (') to delmit string values:create procedure dbo.test @TableName VarChar(100), @website varchar(100), @url varchar(100) AS Declare @SQL VarChar(1000) SELECT @SQL = 'insert into ' + @tableName + ' (website, url) values (''' + @website + ''', ''' + @url + ''')' Exec ( @SQL) |
 |
|
|
bjornh
Yak Posting Veteran
87 Posts |
Posted - 2002-08-09 : 16:53:50
|
| ha oke, it works, thanks. |
 |
|
|
|
|
|
|
|