January 1, 2011 at 11:27 am
I want to get quotes after table1 and table2 using similar sql statement
select +'sp_helpdb'''+name from sys.tables
sp_helpdb 'table1
sp_helpdb 'table2
where should I put quotes to get
sp_helpdb 'table1'
sp_helpdb 'table2'
January 1, 2011 at 11:45 am
SELECT 'sp_helpdb ''' + name + '''' FROM sys.tables
Please also note the added space after sp_helpdb.
January 1, 2011 at 11:58 am
instead of quotes, you could use the builtin QUOTENAME function to get brackets, which would still be syntactically correct:
SELECT 'EXEC sp_helpdb ' + QUOTENAME(name) + ' FROM sys.tables
Lowell
January 1, 2011 at 12:14 pm
A question regarding the logic rather than syntax: what do you want to do with it?
sp_helpdb together with sys.tables doesn't seem to make much sense though...
January 1, 2011 at 12:58 pm
May be he intended for sp_help 'table_name', to get the entire table details, rather than sp_helpdb.
Cheers
John
January 1, 2011 at 1:09 pm
Yes I wanted to do sp_help 'tablename'.
Thanks for the replies.
January 1, 2011 at 1:14 pm
How does four quotes make one quote while execution in this sql stmt after name?
select +'sp_help '''+ name +'''' from sys.tables
January 1, 2011 at 1:31 pm
Hi,
In TSQL, the first and the last single quote marks the starting and ending of the string respectively. And every 2 single quotes, within the aforesaid quotes, represent one quote.
John
January 1, 2011 at 4:17 pm
thank you. that makes sense.
January 1, 2011 at 7:06 pm
Lowell (1/1/2011)
instead of quotes, you could use the builtin QUOTENAME function to get brackets, which would still be syntactically correct:
SELECT 'EXEC sp_helpdb ' + QUOTENAME(name) + ' FROM sys.tables
And, if you want single quotes you can use the second optional parameter for QUOTENAME to specify the character to be used. For example:
SELECT 'EXEC sp_helpdb ' + QUOTENAME(name, char(39)) + ' FROM sys.tables;
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
January 2, 2011 at 4:29 am
the quotename select stmt does not work
January 2, 2011 at 4:51 am
"does not work" is a rather vague statement. Can you post the code you're using and the related error message ?
January 2, 2011 at 5:20 pm
It's just a typo.
SELECT 'EXEC sp_help ' + QUOTENAME(name) FROM sys.tables
MM
select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply