I wonder if I could write a dynamic where statement in a store procedure.
I have a web page that will pass following information to the store procedur
e.
Lets say I have a parameter @.typeid that can be 1 for rent, 2 for sale, 1 or
2 for either. My store procedure looks like this
create select_apartment_details
(
@.typeid nvarchar(50) -- @.typeid ='1' or @.typeid ='2' or @.typeid='1, 2'
)
AS
SELECT * FROM tbl_apartments WHERE typeid IN (@.typeid)
GO
By the way typeid field in the tbl_apartments is integer.
However, this doesnt work. Can anyone help me pls?If the values in the TypeID Column in the tbl_apartments table are indeed
limited to
1 or 2, then I suggest the following
Pass in @.TypeID = 1 When you want only the 1s,
@.TypeID = 2 When you want only the 2s,
and @.TypeID = 3, when you want 1s and 2s
Then in your where clause, you can do this
Where TypeID ^ @.Type <> 0
This will do a bitwise And comparison such that
Database TypeID
@.TypeID | 1 2
-- | -- --
1 | 1 0
2 | 0 2
3 | 1 2
"regaliel" wrote:
> I wonder if I could write a dynamic where statement in a store procedure.
> I have a web page that will pass following information to the store proced
ure.
> Lets say I have a parameter @.typeid that can be 1 for rent, 2 for sale, 1
or
> 2 for either. My store procedure looks like this
> create select_apartment_details
> (
> @.typeid nvarchar(50) -- @.typeid ='1' or @.typeid ='2' or @.typeid='1, 2'
> )
> AS
> SELECT * FROM tbl_apartments WHERE typeid IN (@.typeid)
> GO
> By the way typeid field in the tbl_apartments is integer.
> However, this doesnt work. Can anyone help me pls?
>|||Sorry Memory tricked me... The bitwise operator yu want is bitwise AND, and
the operator symbol is an Ampersand as in
Where TypeID & @.TypeID <> 0
"regaliel" wrote:
> I wonder if I could write a dynamic where statement in a store procedure.
> I have a web page that will pass following information to the store proced
ure.
> Lets say I have a parameter @.typeid that can be 1 for rent, 2 for sale, 1
or
> 2 for either. My store procedure looks like this
> create select_apartment_details
> (
> @.typeid nvarchar(50) -- @.typeid ='1' or @.typeid ='2' or @.typeid='1, 2'
> )
> AS
> SELECT * FROM tbl_apartments WHERE typeid IN (@.typeid)
> GO
> By the way typeid field in the tbl_apartments is integer.
> However, this doesnt work. Can anyone help me pls?
>|||Try this:
SELECT * FROM tbl_apartments WHERE CHARINDEX(CAST(typeid AS CHAR(1)), @.test)
> 0
"regaliel" <regaliel@.discussions.microsoft.com> wrote in message
news:9B49F533-89B9-492D-B556-96B2199585C9@.microsoft.com...
>I wonder if I could write a dynamic where statement in a store procedure.
> I have a web page that will pass following information to the store
> procedure.
> Lets say I have a parameter @.typeid that can be 1 for rent, 2 for sale, 1
> or
> 2 for either. My store procedure looks like this
> create select_apartment_details
> (
> @.typeid nvarchar(50) -- @.typeid ='1' or @.typeid ='2' or @.typeid='1, 2'
> )
> AS
> SELECT * FROM tbl_apartments WHERE typeid IN (@.typeid)
> GO
> By the way typeid field in the tbl_apartments is integer.
> However, this doesnt work. Can anyone help me pls?
>
Showing posts with label store. Show all posts
Showing posts with label store. Show all posts
Monday, March 26, 2012
Monday, March 12, 2012
Formatted Text Data in DB
Can anyone tell me if SQL Server can store formatted text like words in
bold, italic, different font size, etc. ?
Researching and trying to find the answer to anything on microsoft sites is
impossible!
TIA
JeffThis is a multi-part message in MIME format.
--=_NextPart_000_004A_01C368C3.7A69EEA0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
You could create a Word document and then save it as an image datatype =in a table.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com.sql
.
"Jeff Reed" <thebigvalbosky@.hotmail.com> wrote in message =news:OJwvLROaDHA.2572@.TK2MSFTNGP12.phx.gbl...
Can anyone tell me if SQL Server can store formatted text like words =in
bold, italic, different font size, etc. ?
Researching and trying to find the answer to anything on microsoft =sites is
impossible!
TIA
Jeff
--=_NextPart_000_004A_01C368C3.7A69EEA0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1226" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#c0c0c0>
<DIV><FONT size=3D2>You could create a Word document and then save it as =an image datatype in a table.</FONT></DIV>
<DIV><BR>-- <BR> Tom<BR>---<BR>Thomas A. Moreau, =BSc, PhD, MCSE, MCDBA<BR>SQL Server MVP<BR>Columnist, SQL Server Professional<BR>Toronto, ON Canada<BR><A href=3D"www.pinnaclepublishing.com=/">http://www.pinnaclepublishing.com.sql">www.pinnaclepublishing.com=
.sql</A><BR>.<BR></DIV>
<BLOCKQUOTE style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Jeff Reed" <<A =href=3D"mailto:thebigvalbosky@.hotmail.com">thebigvalbosky@.hotmail.com</A>=> wrote in message <A =href=3D"news:OJwvLROaDHA.2572@.TK2MSFTNGP12.phx.gbl">news:OJwvLROaDHA.2572=@.TK2MSFTNGP12.phx.gbl</A>...</DIV>Can anyone tell me if SQL Server can store formatted text like words =in<BR>bold, italic, different font size, etc. ?<BR><BR>Researching and trying to =find the answer to anything on microsoft sites =is<BR>impossible!<BR><BR>TIA<BR><BR>Jeff<BR><BR></BLOCKQUOTE></BODY></HTM=L>
--=_NextPart_000_004A_01C368C3.7A69EEA0--
bold, italic, different font size, etc. ?
Researching and trying to find the answer to anything on microsoft sites is
impossible!
TIA
JeffThis is a multi-part message in MIME format.
--=_NextPart_000_004A_01C368C3.7A69EEA0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
You could create a Word document and then save it as an image datatype =in a table.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com.sql
.
"Jeff Reed" <thebigvalbosky@.hotmail.com> wrote in message =news:OJwvLROaDHA.2572@.TK2MSFTNGP12.phx.gbl...
Can anyone tell me if SQL Server can store formatted text like words =in
bold, italic, different font size, etc. ?
Researching and trying to find the answer to anything on microsoft =sites is
impossible!
TIA
Jeff
--=_NextPart_000_004A_01C368C3.7A69EEA0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1226" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#c0c0c0>
<DIV><FONT size=3D2>You could create a Word document and then save it as =an image datatype in a table.</FONT></DIV>
<DIV><BR>-- <BR> Tom<BR>---<BR>Thomas A. Moreau, =BSc, PhD, MCSE, MCDBA<BR>SQL Server MVP<BR>Columnist, SQL Server Professional<BR>Toronto, ON Canada<BR><A href=3D"www.pinnaclepublishing.com=/">http://www.pinnaclepublishing.com.sql">www.pinnaclepublishing.com=
.sql</A><BR>.<BR></DIV>
<BLOCKQUOTE style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Jeff Reed" <<A =href=3D"mailto:thebigvalbosky@.hotmail.com">thebigvalbosky@.hotmail.com</A>=> wrote in message <A =href=3D"news:OJwvLROaDHA.2572@.TK2MSFTNGP12.phx.gbl">news:OJwvLROaDHA.2572=@.TK2MSFTNGP12.phx.gbl</A>...</DIV>Can anyone tell me if SQL Server can store formatted text like words =in<BR>bold, italic, different font size, etc. ?<BR><BR>Researching and trying to =find the answer to anything on microsoft sites =is<BR>impossible!<BR><BR>TIA<BR><BR>Jeff<BR><BR></BLOCKQUOTE></BODY></HTM=L>
--=_NextPart_000_004A_01C368C3.7A69EEA0--
Sunday, February 26, 2012
FORMAT ISSUE... what to do?
Hey,
I have a little format issue with Excel 2003:
I am working in reporting services - creating a report. The SQL store
procedure returns a date with the following format:
MM/DD/YYYY HH:MM PM/AM
In my report on that perticular text field I have the following format:
dd/mm/yyyy HH:MM:SS
Because I want it in military time.
It displays fine in the report but when I open it in Excel it brings up
the following ERROR:
"File Error. Some number formats may have been lost"
And it shows the date columns the following way:
"38692.46597"
The document is NOT huge and does't contain more than 2000 rows.
Any ideas on how to solve this?Alright solved this:
Changed the format
"dd/mm/yyyy HH:MM:SS"
to
"dd/mm/yyyy HH:MM:ss"
seems that did it ... weird
regards,
Sorcerdon
I have a little format issue with Excel 2003:
I am working in reporting services - creating a report. The SQL store
procedure returns a date with the following format:
MM/DD/YYYY HH:MM PM/AM
In my report on that perticular text field I have the following format:
dd/mm/yyyy HH:MM:SS
Because I want it in military time.
It displays fine in the report but when I open it in Excel it brings up
the following ERROR:
"File Error. Some number formats may have been lost"
And it shows the date columns the following way:
"38692.46597"
The document is NOT huge and does't contain more than 2000 rows.
Any ideas on how to solve this?Alright solved this:
Changed the format
"dd/mm/yyyy HH:MM:SS"
to
"dd/mm/yyyy HH:MM:ss"
seems that did it ... weird
regards,
Sorcerdon
Format in SP
Hi,
I am quering a table that has a bit field. The bit field is used to store a
boolean and I want to display this value in a data grid. Can I format(i do
not want a -1 or 0 displayed in the datagrid) this value before I return the
resultset?
ThanksWell, first off, a BIT cannot be -1. You must be thinking of Access or VB.
SELECT CASE bitColumn WHEN 1 THEN 'True' ELSE 'False' END FROM table
"jake" <jp@.broncos.com> wrote in message
news:uhRdKH20FHA.1252@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I am quering a table that has a bit field. The bit field is used to store
> a boolean and I want to display this value in a data grid. Can I format(i
> do not want a -1 or 0 displayed in the datagrid) this value before I
> return the resultset?
> Thanks
>|||While you can use a CASE statement to transform the values, you are mingling
the data layer and the presentation layer. You can just as easily perform
the same action in your client code and maintain the tier integrity. (What
if you or someone else want to call this same query in another place and kee
p
the bit values?)
Just something to consider.
John Scragg
"jake" wrote:
> Hi,
> I am quering a table that has a bit field. The bit field is used to store
a
> boolean and I want to display this value in a data grid. Can I format(i d
o
> not want a -1 or 0 displayed in the datagrid) this value before I return t
he
> resultset?
> Thanks
>
>|||> (What if you or someone else want to call this same query in another place
and > keep the bit values?)
The 'wtf-way' would be to convert the values back and forth as needed. :)
I whole-heartedly agree - things like these belong on the presentation layer
.
ML
I am quering a table that has a bit field. The bit field is used to store a
boolean and I want to display this value in a data grid. Can I format(i do
not want a -1 or 0 displayed in the datagrid) this value before I return the
resultset?
ThanksWell, first off, a BIT cannot be -1. You must be thinking of Access or VB.
SELECT CASE bitColumn WHEN 1 THEN 'True' ELSE 'False' END FROM table
"jake" <jp@.broncos.com> wrote in message
news:uhRdKH20FHA.1252@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I am quering a table that has a bit field. The bit field is used to store
> a boolean and I want to display this value in a data grid. Can I format(i
> do not want a -1 or 0 displayed in the datagrid) this value before I
> return the resultset?
> Thanks
>|||While you can use a CASE statement to transform the values, you are mingling
the data layer and the presentation layer. You can just as easily perform
the same action in your client code and maintain the tier integrity. (What
if you or someone else want to call this same query in another place and kee
p
the bit values?)
Just something to consider.
John Scragg
"jake" wrote:
> Hi,
> I am quering a table that has a bit field. The bit field is used to store
a
> boolean and I want to display this value in a data grid. Can I format(i d
o
> not want a -1 or 0 displayed in the datagrid) this value before I return t
he
> resultset?
> Thanks
>
>|||> (What if you or someone else want to call this same query in another place
and > keep the bit values?)
The 'wtf-way' would be to convert the values back and forth as needed. :)
I whole-heartedly agree - things like these belong on the presentation layer
.
ML
Sunday, February 19, 2012
format = yyyy/mm/dd h:m:s ?
How can i store the dates in a DateTime Columns in format = yyyy/mm/dd h:m:s --> 2005/01/21 18:40:21 ?
I have tried to write it in the formula field but it doesn't work .. it works in access 2000
for MS SQL 2000 database
thank youYou don't. You can retrieve datetimes in a particular format, but you can't (and don't have to) tell SQL Server how to store them.|||ok ! thank you|||...which is the same as in Access...
I have tried to write it in the formula field but it doesn't work .. it works in access 2000
for MS SQL 2000 database
thank youYou don't. You can retrieve datetimes in a particular format, but you can't (and don't have to) tell SQL Server how to store them.|||ok ! thank you|||...which is the same as in Access...
Subscribe to:
Posts (Atom)