Quote:
quote:Originally posted by manudutt
Chandru your problem is only due to enter key character (char(13)), if you use any return key withing @SQL string , only that part of string that comes before enter (char(13)) is taken by SELECT statement and this way '> D:\sql.txt' is also trimmed out ..
if there is no return key in @SQL string , your CREATE statement will be logged to system file easily ...
|
manudutt, You are wrong. That is not the case...
Try this out in your system... and open sql.txt file.
Code:
DECLARE @TableName varchar(100)
DECLARE @SQL varchar(2000)
SET @TableName = 'testtbl'
SET @SQL = 'CREATE TABLE ' + @TABLENAME + char(13) + '(' + char(13) + 'col1 int' + char(13) + ')'
print @SQL
SELECT @SQL = 'echo ' + @SQL + ' > C:\SQL1.txt'
SELECT @SQL 'SQL'
EXEC master..xp_cmdshell @SQL
carumuga,
Unless you post the complete code, we wouldn't be able to point out what you are missing. How about posting the complete code here?
Cheers
_________________________
- Vijay G
Strive for Perfection