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 2008 Forums
 Transact-SQL (2008)
 the maximum number of prefixes

Author  Topic 

CoolMoon2011
Starting Member

31 Posts

Posted - 2011-10-11 : 11:55:44
When I run the query, I got this error below.

Msg 117, Level 15, State 1, Procedure proc_inforcebuild_minival_Step_1to5_LZ_2, Line 71
The object name 'LTCpdb2.valuation.dbo.MonthlyValFile_current' contains more than the maximum number of prefixes. The maximum is 2.

Anyone would like to help me out. How to fix this error. The query that I run is below

select *
into LTCpdb2.valuation.dbo.MonthlyValFile_current
from LTCpdb2.valuation.dbo.MonthlyValFile_' + cast(year(@inforce_date)*100 + month(@inforce_date) as char(6))

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-11 : 12:36:11
you need dynamic sql for this

DECLARE @Sql varchar(5000)

SET @Sql='select *
into LTCpdb2.valuation.dbo.MonthlyValFile_current
from LTCpdb2.valuation.dbo.MonthlyValFile_' + cast(year(@inforce_date)*100 + month(@inforce_date) as char(6))

EXEC (@sql)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

CoolMoon2011
Starting Member

31 Posts

Posted - 2011-10-11 : 14:17:41
Great! It works. That's what I did change. Thank you Visakh16.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-11 : 14:24:54
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-10-13 : 09:38:40
Here is fun with dot
http://beyondrelational.com/blogs/madhivanan/archive/2010/07/12/fun-with-dot.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -