SQL - StoredProc - Data into a variable?
-
Hey everyone, im a little stuck here basically i have a SQL 2000 function like this:
CREATE PROCEDURE GetTaskListForSupervisor as declare @rowcount int set @rowcount = select count(id) from TimeStudy //add logic if rowcount is > 2 GO
Obviously, that doesnt pass the syntex check, but can you see what id like to do? just put the count of all the rows into a locally declared variable? Im a bit out of my depth here so could someone pull me back into shallow waters please :D Cheers Will -
Hey everyone, im a little stuck here basically i have a SQL 2000 function like this:
CREATE PROCEDURE GetTaskListForSupervisor as declare @rowcount int set @rowcount = select count(id) from TimeStudy //add logic if rowcount is > 2 GO
Obviously, that doesnt pass the syntex check, but can you see what id like to do? just put the count of all the rows into a locally declared variable? Im a bit out of my depth here so could someone pull me back into shallow waters please :D Cheers Will"select @rowcount = count(*) from TimeStudy" ;no advantage to count(id) over count(*)...
-
Hey everyone, im a little stuck here basically i have a SQL 2000 function like this:
CREATE PROCEDURE GetTaskListForSupervisor as declare @rowcount int set @rowcount = select count(id) from TimeStudy //add logic if rowcount is > 2 GO
Obviously, that doesnt pass the syntex check, but can you see what id like to do? just put the count of all the rows into a locally declared variable? Im a bit out of my depth here so could someone pull me back into shallow waters please :D Cheers Will -
Hey everyone, im a little stuck here basically i have a SQL 2000 function like this:
CREATE PROCEDURE GetTaskListForSupervisor as declare @rowcount int set @rowcount = select count(id) from TimeStudy //add logic if rowcount is > 2 GO
Obviously, that doesnt pass the syntex check, but can you see what id like to do? just put the count of all the rows into a locally declared variable? Im a bit out of my depth here so could someone pull me back into shallow waters please :D Cheers Willyou may use like this: declare @ROWCOUNT int select @ROWCOUNT = count(id) from syscolumns where id = 1 if @ROWCOUNT > 2 print @ROWCOUNT else print 'Less'
Anshuman Singh [anshumas@rediffmail.com](mailto:Anshuman Singhanshumas@rediffmail.com)