Click here to Skip to main content
15,896,539 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
--First run this below script to insert a duplicate column of DATE--
alter table lsPRICE add DATE1 datetime null


--Next Run this below script to convert the existing data to DATETIME data type--
update lsPRICE set [DATE]=convert(datetime,[DATE],104)

--Next Run this below script to copy the data of old [DATE] column to new [DATE1] column--
update lsPRICE set DATE1=[DATE]

--Next Run this below script to delete the old [DATE] column--
alter table lsPRICE drop column [DATE]

--Next Run this below script to rename the newly created column to [DATE]--
SP_RENAME 'lsprice.DATE1','DATE','column'

--this script will help to work the Last selling price to work accurately--

I want to run this script using C# in Sql

I don't want to run this at a time i want to run it by step by step

I got error Incorrect syntax near 'SP_RENAME'. while running it single time.
Posted
Comments
[no name] 30-Jul-15 7:02am    
http://www.codeproject.com/Questions/1014128/How-to-run-the-next-line-in-sql-when-the-previous?arn=9
TarunKumarSusarapu 30-Jul-15 7:22am    
Thanks for ur information Actually That has been posted by me That is different from this one can u pls solve this
ZurdoDev 30-Jul-15 7:23am    
Put it all into one stored procedure and then call that stored procedure from C#.
TarunKumarSusarapu 30-Jul-15 7:33am    
Not working bro I tried that also
virusstorm 30-Jul-15 12:57pm    
How are you executing this script? You say C# in SQL, but there are many ways this can occur. To solve your error, you can't run the "ALTER TABLE" and then execute a stored procedure, they need to be separate calls. To achieve this in Management Studio, we use the "GO" keyword. This might solve your issue, but it will depend on how you are actually executing the SQL.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900