SQL Server Job

Technical Article

RE: How to execute Dynamic SQL inside SP ?????

  • Reply

You need to put everything inside a string, including the cursor stuff and execute this. See http://www.sommarskog.se/dynamic_sql.html May I add that dynamic sql + a cursor + a UDF are very likely to kill performance. Also, master.dbo.spt_values isn't fully documented. You'd better use your own number table.

You rated this post out of 5. Change rating

2005-02-07

Technical Article

RE: Dynamic Select

  • Reply

I hope this helps you CREATE PROCEDURE GetFacilities  @userID NVARCHAR(100),  @language NVARCHAR(100) AS DECLARE @sql_str VARCHAR(1000) SET @sql_str = 'SELECT Name, (SELECT ' + @language + ' FROM lkpfacilitytype WHERE ID = Type) AS Type, Address1,  Address2,  City,  State,  ZIP,  Country,  Phone,  Fax,  WebSite FROM tblFacilities WHERE userID = ''' + @userID + '''' EXEC (@sql_str) GO […]

You rated this post out of 5. Change rating

2004-02-28

Blogs

Creating a Test Pipeline in Azure DevOps using a Windows Agent

By

A customer was having some trouble getting started with Azure DevOps (AzDO) and building...

Building Studio in Public: Maintaining High Performance in Our Local Development App for Enhanced UX

By

In this post, we share the strategies and techniques we've implemented to ensure our...

Monday Monitor Tips: Changing the Fragmentation Alert

By

I had a customer that was concerned about the fragmentation alert for indexes and...

Read the latest Blogs

Forums

7 sept, scheduled book

By philip.scott

Comments posted to this topic are about the item 7 sept, scheduled book

7 sept, schedlued article

By philip.scott

Comments posted to this topic are about the item 7 sept, schedlued article

6 sept, published book

By philip.scott

Comments posted to this topic are about the item 6 sept, published book

Visit the forum

Question of the Day

Azure Data Lake Storage Gen 2

Azure Data Lake Storage Gen 2 is built on ...?

See possible answers