I hope someone can help me with this. I have a table in which I need to add new columns. The data is dynamic and the number of columns I have to add will depend on a count of some other data. I've got that count and have, so far, written but not tested this:
SELECT @maxoldSSN = max(cnt) FROM LFRD_Old_SSN_Counter;
SET @countoldSNN = 0;
WHILE @countoldSNN < @maxoldSSN
ALTER TABLE LFRD
ADD old_SSN varchar (15);
SET @countoldSNN = @countoldSNN + 1
My question is how do I add the count part into the new column names? I want them to be old_SSN1, oldSSN2 and so on. I realise I can use the value in @countoldSSN but don't know how to concatenate it into a column name.
Hopefully, this won't be too difficult :-).
As an aside, and I hope it's OK to ask this as part of my question, when I had 2012, I had a watch window so that I could see the variables changing when I stepped through. I can't find that in 2014! I have looked it up but I don't have the options under the menus that Microsoft seem to think I should. Does anyone know how to get this to show?
All you need now is to comment the print commands and uncomment the EXEC line so it will actualy perform the action like this:
declare @maxcnt int;
declare @crtcnt sysname;
declare @sqlstr varchar(max);
Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.