Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 6:56 AM
Points: 15,262, Visits: 15,242
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: Wednesday, February 3, 2016 5:09 AM
Points: 2,804, Visits: 4,807
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 @ 8:22 AM
Points: 13,971, Visits: 36,258
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

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
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