Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Problem in Dynamic sql Expand / Collapse
Author
Message
Posted Monday, April 29, 2013 8:55 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, November 27, 2013 4:28 AM
Points: 21, Visits: 98
Hi all,
When i try to add the '+@pDatabase+'.dbo. with the tablename in line 98,99,100 AM getting error like Msg 103,Msg 102,Msg 105 With out that Query running fine PLZ help me out on this.

Query in Attachment.

Regards,
Basee



  Post Attachments 
New Q.txt (25 views, 14.63 KB)
Post #1447575
Posted Monday, April 29, 2013 9:08 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:56 PM
Points: 13,082, Visits: 12,545
baseehkhan (4/29/2013)
Hi all,
When i try to add the '+@pDatabase+'.dbo. with the tablename in line 98,99,100 AM getting error like Msg 103,Msg 102,Msg 105 With out that Query running fine PLZ help me out on this.

Query in Attachment.

Regards,
Basee



What is the error you are getting?


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1447588
Posted Monday, April 29, 2013 9:09 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, October 9, 2014 7:34 AM
Points: 2,666, Visits: 4,736
Please post the exact error message that you are getting.


Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1447590
Posted Monday, April 29, 2013 11:07 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 1:11 PM
Points: 12,905, Visits: 32,161
do a find and replace to add QUOTENAME, so you can accommodate weird database names with dashes/spaces

FROM '+@pDatabase+'
--should be
FROM '+ QUOTENAME(@pDatabase) +'



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1447661
Posted Monday, April 29, 2013 9:46 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, November 27, 2013 4:28 AM
Points: 21, Visits: 98
Msg 103, Level 15, State 4, Line 106
The identifier that starts with 'Dir Sales mACHOCodeLatestClear, mAC1CODELATESTCLEAR, mACDICodeLatestClear, mACSTCodeLatestClear, mPR3CodeLatestClear, mPR2CodeLa' is too long. Maximum length is 128.
Msg 105, Level 15, State 1, Line 106
Unclosed quotation mark after the character string 'Dir Sales mACHOCodeLatestClear, mAC1CODELATESTCLEAR, mACDICodeLatestClear, mACSTCodeLatestClear, mPR3CodeLatestClear, mPR2CodeLat'.
Msg 102, Level 15, State 1, Line 106
Incorrect syntax near 'Dir Sales mACHOCodeLatestClear, mAC1CODELATESTCLEAR, mACDICodeLatestClear, mACSTCodeLatestClear, mPR3CodeLatestClear, mPR2CodeLa'.
Post #1447860
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse