Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 check if select returns data

Author  Topic 

wolfje
Starting Member

1 Post

Posted - 2010-07-15 : 08:58:23
I'm working on a stored procedure where I can extract transaction data, I have a table where the last download is stored with the last transaction number.

Now the problem is that if I can't get the last transaction number, the stored procedure won't work.

How do I write a check to see if data is returning, and else start with number 1?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-15 : 09:55:32
I assume that you are taking a @variable to hold the transaction number - right?
Then you can check that @variable before using it.

... code to get the last/next transaction number ...

if @variable is null
begin
set @variable=1
end

... code that is using the transaction number ...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -