USE [DB]
GO
/****** Object: StoredProcedure [dbo].[GetBLogAlertDetails] Script Date: 02/28/2012 18:08:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create PROCEDURE [dbo].[GetCommentAlertDetails]
@userid bigint
AS
select Users.FirstName,Users.Email,br.* from Blogs b (NOLOCK) inner join Users on Users.UserID=b.UserID where BlogID in ( select BlogID from BlogReplies br (NOLOCK) where UserID = '17059' )
but i m get errer is=The column prefix 'br' does not match with a table name or alias name used in the query.
select Users.FirstName,Users.Email,br.* from Blogs b (NOLOCK)
inner join Users on Users.UserID=b.UserID
inner join BlogReplies br on BlogID = br.BlogID and br.UserID = '17059'
Marked as answer by srinanthuram on Feb 28, 2012 12:47 PM
select Users.FirstName,Users.Email,br.*,Blogs.BlogTitle from BlogReplies br (NOLOCK) inner join Users on Users.UserID=br.UserID
where BlogID in
(
select BlogID from Blogs (NOLOCK) where UserID = '17059'
)
but this time i get new error =The multi-part identifier "Blogs.BlogTitle" could not be bound.
Sorry Mate, u r doing the same again..the Blogs table isn't in the main query now
Just use the below query
select Users.FirstName,Users.Email,br.*, b.BlogTitle from Blogs b (NOLOCK)
inner join Users on Users.UserID=b.UserID
inner join BlogReplies br on BlogID = br.BlogID and br.UserID = '17059'
select br.*,Users.FirstName,Users.Email,b.BlogTitle from BlogReplies as br (NOLOCK) inner join Users on Users.UserID=br.UserID
inner join Blogs b on b.BlogID = br.BlogID and b.UserID = '17059'
srinanthuram
Contributor
6800 Points
1549 Posts
The column prefix 'br' does not match with a table name or alias name used in the query.
Feb 28, 2012 12:09 PM|LINK
hi all
my Stored Procedure is below...
USE [DB] GO /****** Object: StoredProcedure [dbo].[GetBLogAlertDetails] Script Date: 02/28/2012 18:08:58 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create PROCEDURE [dbo].[GetCommentAlertDetails] @userid bigint AS select Users.FirstName,Users.Email,br.* from Blogs b (NOLOCK) inner join Users on Users.UserID=b.UserID where BlogID in ( select BlogID from BlogReplies br (NOLOCK) where UserID = '17059' )duzi
Member
355 Points
90 Posts
Re: The column prefix 'br' does not match with a table name or alias name used in the query.
Feb 28, 2012 12:13 PM|LINK
I think that the table Users makes you troubles. Put the [] brackets around the table users like this: [Users].UserId and so on...
Ramesh T
Contributor
5111 Points
827 Posts
Re: The column prefix 'br' does not match with a table name or alias name used in the query.
Feb 28, 2012 12:18 PM|LINK
Hello Mate,
There is no match for column prefix 'br' in the main query, the alias name u used ('br') is an alias of table in sub query.
Column prefix should be a table name or an alias of a table in the main query (in any query actually)
Cheers,
R
srinanthuram
Contributor
6800 Points
1549 Posts
Re: The column prefix 'br' does not match with a table name or alias name used in the query.
Feb 28, 2012 12:20 PM|LINK
thanks mr.duzi
i alredy check u r way.but same error displayed...
ramiramilu
All-Star
95403 Points
14096 Posts
Re: The column prefix 'br' does not match with a table name or alias name used in the query.
Feb 28, 2012 12:23 PM|LINK
where ever you use br, change it to b..becase you initiated an alias with blogs table as b...
thanks,
JumpStart
srinanthuram
Contributor
6800 Points
1549 Posts
Re: The column prefix 'br' does not match with a table name or alias name used in the query.
Feb 28, 2012 12:25 PM|LINK
hi Ramesh T
ya..
alredy its worked fine,but i want BlogReplies table values .how to do?
thanks
Ramesh T
Contributor
5111 Points
827 Posts
Re: The column prefix 'br' does not match with a table name or alias name used in the query.
Feb 28, 2012 12:28 PM|LINK
Just change ur query as below
srinanthuram
Contributor
6800 Points
1549 Posts
Re: The column prefix 'br' does not match with a table name or alias name used in the query.
Feb 28, 2012 12:32 PM|LINK
k boss
i change my query
select Users.FirstName,Users.Email,br.*,Blogs.BlogTitle from BlogReplies br (NOLOCK) inner join Users on Users.UserID=br.UserID
where BlogID in
(
select BlogID from Blogs (NOLOCK) where UserID = '17059'
)
but this time i get new error =The multi-part identifier "Blogs.BlogTitle" could not be bound.
sry Do not know much sql....
Ramesh T
Contributor
5111 Points
827 Posts
Re: The column prefix 'br' does not match with a table name or alias name used in the query.
Feb 28, 2012 12:39 PM|LINK
Sorry Mate, u r doing the same again..the Blogs table isn't in the main query now
Just use the below query
srinanthuram
Contributor
6800 Points
1549 Posts
Re: The column prefix 'br' does not match with a table name or alias name used in the query.
Feb 28, 2012 12:41 PM|LINK
s its worked
All of the answer is correct thanks frnds
i m change my query u r way