Monday, March 12, 2012

Here is an SQL string

Hello,
Here is the SQL I am using.
SELECT People.*
FROM People INNER JOIN
UserNamePNum ON People.PNum = UserNamePNum.PNum
WHERE (People.PDateDate BETWEEN @.StartPDateDate AND
@.EndPDateDate) AND (UserNamePNum.UserName = N'User!UserID')
ORDER BY People.FName, People.MName, People.LName
UserNamePNum has go UserName and PNum fields. I know
MyDomain\Username is available in UserNamePNum table and
corresponding UserNamePNum.PNum is available in
People.PNum.
I know there are records in People table for my username's
PNum. Why this does not return anything in my report.
Thanks,
Jim.It seems it does not like User!UserID, what can I use
instead of this?
>--Original Message--
>Hello,
>Here is the SQL I am using.
>SELECT People.*
>FROM People INNER JOIN
> UserNamePNum ON People.PNum =>UserNamePNum.PNum
>WHERE (People.PDateDate BETWEEN @.StartPDateDate AND
>@.EndPDateDate) AND (UserNamePNum.UserName = N'User!
UserID')
>ORDER BY People.FName, People.MName, People.LName
>UserNamePNum has go UserName and PNum fields. I know
>MyDomain\Username is available in UserNamePNum table and
>corresponding UserNamePNum.PNum is available in
>People.PNum.
>I know there are records in People table for my
username's
>PNum. Why this does not return anything in my report.
>Thanks,
>Jim.
>.
>|||I used query expression it seems it is working fine.>--
Original Message--
>Hello,
>Here is the SQL I am using.
>SELECT People.*
>FROM People INNER JOIN
> UserNamePNum ON People.PNum =>UserNamePNum.PNum
>WHERE (People.PDateDate BETWEEN @.StartPDateDate AND
>@.EndPDateDate) AND (UserNamePNum.UserName = N'User!
UserID')
>ORDER BY People.FName, People.MName, People.LName
>UserNamePNum has go UserName and PNum fields. I know
>MyDomain\Username is available in UserNamePNum table and
>corresponding UserNamePNum.PNum is available in
>People.PNum.
>I know there are records in People table for my
username's
>PNum. Why this does not return anything in my report.
>Thanks,
>Jim.
>.
>|||Try this:
="SELECT People.* FROM People INNER JOIN UserNamePNum ON People.PNum =UserNamePNum.PNum WHERE (People.PDateDate BETWEEN @.StartPDateDate AND
@.EndPDateDate) AND UserNamePNum.UserName = N'" & User!UserID & "') ORDER BY
People.FName, People.MName, People.LName"
--
Ravi Mumulla (Microsoft)
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
<anonymous@.discussions.microsoft.com> wrote in message
news:6b4901c475aa$9b64ef70$a601280a@.phx.gbl...
> It seems it does not like User!UserID, what can I use
> instead of this?
> >--Original Message--
> >Hello,
> >Here is the SQL I am using.
> >
> >SELECT People.*
> >FROM People INNER JOIN
> > UserNamePNum ON People.PNum => >UserNamePNum.PNum
> >WHERE (People.PDateDate BETWEEN @.StartPDateDate AND
> >@.EndPDateDate) AND (UserNamePNum.UserName = N'User!
> UserID')
> >ORDER BY People.FName, People.MName, People.LName
> >
> >UserNamePNum has go UserName and PNum fields. I know
> >MyDomain\Username is available in UserNamePNum table and
> >corresponding UserNamePNum.PNum is available in
> >People.PNum.
> >
> >I know there are records in People table for my
> username's
> >PNum. Why this does not return anything in my report.
> >Thanks,
> >Jim.
> >
> >.
> >|||Did you cut and past this?
N'User!UserID'
Does not look correct. I am not familiar with ! ever being in an SQL query,
also if you are working in Unicode as I recall you do this: N'UserID (no end
')
Is it possible that UserNamePNum.UserName = N'User
"JIM.H." <anonymous@.discussions.microsoft.com> wrote in message
news:6d8501c475a7$6aaff080$a501280a@.phx.gbl...
> Hello,
> Here is the SQL I am using.
> SELECT People.*
> FROM People INNER JOIN
> UserNamePNum ON People.PNum => UserNamePNum.PNum
> WHERE (People.PDateDate BETWEEN @.StartPDateDate AND
> @.EndPDateDate) AND (UserNamePNum.UserName = N'User!UserID')
> ORDER BY People.FName, People.MName, People.LName
> UserNamePNum has go UserName and PNum fields. I know
> MyDomain\Username is available in UserNamePNum table and
> corresponding UserNamePNum.PNum is available in
> People.PNum.
> I know there are records in People table for my username's
> PNum. Why this does not return anything in my report.
> Thanks,
> Jim.
>|||User!userid is a global variable. You have to create the query string
dynamically (which means you have to use the generic query designer).
Bruce L-C
"Roger Twomey" <rogerdev@.vnet.on.ca> wrote in message
news:eyDIPijdEHA.384@.TK2MSFTNGP10.phx.gbl...
> Did you cut and past this?
> N'User!UserID'
> Does not look correct. I am not familiar with ! ever being in an SQL
query,
> also if you are working in Unicode as I recall you do this: N'UserID (no
end
> ')
>
> Is it possible that UserNamePNum.UserName = N'User
> "JIM.H." <anonymous@.discussions.microsoft.com> wrote in message
> news:6d8501c475a7$6aaff080$a501280a@.phx.gbl...
> > Hello,
> > Here is the SQL I am using.
> >
> > SELECT People.*
> > FROM People INNER JOIN
> > UserNamePNum ON People.PNum => > UserNamePNum.PNum
> > WHERE (People.PDateDate BETWEEN @.StartPDateDate AND
> > @.EndPDateDate) AND (UserNamePNum.UserName = N'User!UserID')
> > ORDER BY People.FName, People.MName, People.LName
> >
> > UserNamePNum has go UserName and PNum fields. I know
> > MyDomain\Username is available in UserNamePNum table and
> > corresponding UserNamePNum.PNum is available in
> > People.PNum.
> >
> > I know there are records in People table for my username's
> > PNum. Why this does not return anything in my report.
> > Thanks,
> > Jim.
> >
>

No comments:

Post a Comment