I need to create a stored procedure that has quite a few statements.
I did some research and found that SQL Server doesn't allow statements to be combined in one batch. (You can combine them when using the GO keyword and executing from SQL Query Analyzer or another tool, but not from within code.)
CREATE PROCEDURE usp_PoliticalProcessing
SET sPhone = RTrim(LTrim(Convert(varchar(30), Convert(numeric(20, 1), phone))))
SET sPhone = Substring(sphone, 1, patindex('%.%', sphone)-1)
SET sphone = replace(replace(replace(replace(replace(replace(sphone,'.',''),',','' ),'-',''), ' ',''), '(', ''), ')', '')
ALTER TABLE dbo.list_staging ADD [iList_StagingID] INT IDENTITY(1,1)
ALTER TABLE dbo.list_staging ADD [sFailedValidation] char(1)
SET sFailedValidation = 'X'
WHERE(Len(RTrim(LTrim(sPhone))) <> 10)"
UPDATE a "
SET a.sFailedValidation = 'X' "
FROM dbo.list_staging a "
INNER JOIN dbo.list_staging b "
ON a.sPhone= b.sPhone "
WHERE(a.iList_StagingID > b.iList_StagingID)
Having said all that, how can I create this proc from within VB.NET?
Is this even possible?