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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Looking for a function to return table variable

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2010-05-18 : 09:13:30
I need to declare a table variable from another existing table.
If I use "Script table as" will create table variable with [], like
CREATE TABLE [dbo].[CLAIM](
[CLAIMNO] [varchar](20) NOT NULL,
[ACCT] [varchar](4) NOT NULL,
....
Is there a function can return script without [ ]?

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2010-05-18 : 09:23:43
Use replace() function

select replace(replace('CREATE TABLE [dbo].[CLAIM](
[CLAIMNO] [varchar](20) NOT NULL,
[ACCT] [varchar](4) NOT NULL,','[',''),']','')

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2010-05-18 : 09:30:29
Is there a function to pass the existing table will return all script without [ ]?
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2010-05-18 : 09:31:42
if you want, write your own function!

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page
   

- Advertisement -