Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Declaring in SP

Status
Not open for further replies.

Steve95

MIS
Nov 3, 2004
265
US
Hi All

Iam new to SQL SPs and have created a SP which starts off with a declare statement referencing a table variable.

In the SP their are are various select and insert statements which manipulates the data and finally the data is inserted in a table.

However I want to test an section of the SP and not run the whole, ideally see the results in the table variable as the results are changing after each select or insert is run.

I keep getting an message 'must declare variable @test', does any one know I can come around this problem? All I want is to see each piece of manuipulation ie. highlight a statement run it and see whats happening before moving on to the next statement.

I hope I have made sense, any questions please ask.

Many Thanks
 
Thanks for that Dennis, my next problem is that my SP has information coming in from different tables which sit on different servers. How do I reference a server before a table.dbo.field and also does this mean I got to create a link server?
 
What I usually do is comment out the declare statements and add create temp table statments and then replace all refernces from @table to #table. Then you can run it one section at a time. Once I've debugged, I comment out the create table statements (cause you know you will need them again at some future date), uncommnet out the declare statments and replace #table with @table.

Questions about posting. See faq183-874
 
\\servername.database.owner.table

If you are querying another server, yes, you need a linked server.

-SQLBill

Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top