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.
| Author |
Topic |
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2007-03-16 : 11:30:20
|
| Hello,I have the following:SELECT * FROM dbo.Blogs WHERE BlogId = @BlogIdI need to check if such a record exist but not now. Later in my code.I suppose I should create a BIT variable.Could someone tell me how to do this?Thanks,Miguel |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-16 : 11:33:02
|
you can use existswhere exists (SELECT * FROM dbo.Blogs WHERE BlogId = @BlogId) KH |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2007-03-16 : 11:51:09
|
| Yes I know that.But that's not the question. In VB.NET would be something like this:Dim aBIGGERb As Boolean = (a>b)Dim cBIGGERb As Boolean = (c>b)... Then later on my code I would do:If aBIGGERb AND cBIGGERb Then Response.Write("c is bigger than a")You see?I need to create various variables in SQL which will hold information as if certain records exist. Then later on my code I will test various combinations.Any idea?Thanks,Miguel |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-16 : 11:54:28
|
| if exists (SELECT * FROM dbo.Blogs WHERE BlogId = @BlogId) set @param1 = 1else set @param1 = 0if exists (SELECT * FROM dbo.Blogs WHERE BlogId = @BlogId2) set @param2 = 1else set @param2 = 0select *, case when @param1 > @param2 then 'ewrnrew' else 'wereljn' end as statusfrom tablePeter LarssonHelsingborg, Sweden |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2007-03-16 : 13:11:43
|
| It's a vb question...which in and of itself is the wrong forum, however, the way it's presented is incorrect...the process is flawedLet us know what you need to do instead of trying to force a tech solution to a process that needs to be alteredBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
|
|
|