Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in SQL Server only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
SQL Server
Is it possible to rename table to datetime?
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
Newb Mac
New Member
Join Date:
Dec 2010
Posts:
5
#1
Is it possible to rename table to datetime?
Dec 21 '10, 03:03 AM
is it possible to rename table to datetime?
if yes, can anyone show me how?
thanks..
somdutt
New Member
Join Date:
May 2010
Posts:
3
#2
Dec 21 '10, 06:46 AM
Yes, it can be done.
I assume your table name as mytable1 -
create table [mytable1] ( id int )
go
declare @stmt varchar(100)
declare @old_name sysname , @new_name sysname
set @old_name = 'mytable1'
select @new_name=repla ce(replace(repl ace ( replace(convert (varchar, getdate() ,121) ,' ', '_'),'-', '_') ,':', '_'),'.','_')
set @stmt='exec sp_rename ''' + @old_name + ''', ''' + @new_name + ''''
print 'Executing Statement - ' + @stmt
exec (@stmt)
Comment
Post
Cancel
Newb Mac
New Member
Join Date:
Dec 2010
Posts:
5
#3
Dec 21 '10, 06:55 AM
i found the way already..Thanks ..
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment