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 |
|
kenaman
Starting Member
1 Post |
Posted - 2003-03-20 : 03:53:26
|
| I am running a stored procedure that compares the structure of 2 databases and am encountering an error at the following line. I need some help concatenating this string :set @Sqlstring = ' select distinct table_name from Kenneth.INFORMATION_SCHEMA.tables ' + 'where table_schema = "dbo" ' + 'and table_type = "BASE TABLE" ' + 'and table_name = "' + @TableName1 + '"'I have been trying to get the double quotes out of the equation but to no avail.Any help would be appreciated. |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2003-03-20 : 04:05:43
|
| Try using two single quotesset @Sqlstring = 'select * from INFORMATION_SCHEMA.tables ' + 'where table_schema = ''dbo'' ' + 'and table_type = ''BASE TABLE'' ' + 'and table_name = ''' + @TableName1 + '''' OS |
 |
|
|
JellyRoll
Starting Member
8 Posts |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-03-24 : 12:29:18
|
| I recommend this tool:[url]http://www.red-gate.com/sql_tools.htm[/url]But if you can get your stored procedure to work, then go with that because it's free!Tara |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-03-24 : 14:16:31
|
| How about:Declare @dbname1 sysname, @dbname2 sysname, @SQL varchar(4000)Select @dbname1 = 'PUBS', @dbname2 = 'Northwind'Set @SQL = 'SELECT * FROM '+@dbname1+'.information_schema.tables a ' + 'full join '+@dbname2+'.information_schema.tables b ' + 'On a.table_name = b.table_name and a.table_type = b.table_type'Exec(@SQL)Brett8-) |
 |
|
|
|
|
|