Showing posts with label include. Show all posts
Showing posts with label include. Show all posts

Sunday, March 25, 2012

A couple of questions

Well, I had a questions, but I figured I'd include all of the things I've been trying to figure out.

I remember reading in books online about transformnig the data returned by a SQL query. For example, the database has a boolean 1 or 0, but I want to return a Yes / No or True / False. You could even doa number mapping for example, 1 becomes "one", 2 becomes "two" etc. Can anyone point me in the right direction?

Is there a way to check a data field for a specific format? SELECT IDNumber from table WHERE IDNumber is not 6 numberic digits. (IDNumber is nvarchar with a length of 50 and stores IDNUmbers that also contain letters and special characters)

Query returns 123456789, 12345678, 2-0152, A5487, but not 123456 or 101254, etc.

How do I insert several lines if I have the data as text? I can insert multiple lines from another table, but how do I insert multiple lines if I want to type in the data?

How do I insert the same line into several SQL database on different computers using query analyzer? I basically have to enter a line for each user into the user table. I can do it with osql, but I don't know haw to change the server in query analyzer. With query analyzer I can create a script and just substitute the variables defined at the beginning.

Thanks,

Cory

1. To 'transform' data, use the CASE structure.

Code Snippet


SELECT Gender = CASE Sex

WHEN 1 THEN 'M'

WHEN 0 THEN 'F'

END

FROM MyTable.

2. To check for specific format, i.e., 6 character number, something like this 'should' work for you (it's not perfect, but I think it may give you what you desire):


Code Snippet


SET NOCOUNT ON


DECLARE @.MyTable table
( IDNumber varchar(50) )


INSERT INTO @.MyTable VALUES ( '123456789' )
INSERT INTO @.MyTable VALUES ( '12345678' )
INSERT INTO @.MyTable VALUES ( '2-0152' )
INSERT INTO @.MyTable VALUES ( 'A5487' )
INSERT INTO @.MyTable VALUES ( 'A54871' )
INSERT INTO @.MyTable VALUES ( '123456' )
INSERT INTO @.MyTable VALUES ( '101254' )


SELECT IDNumber
FROM @.MyTable
WHERE ( len( IDNumber ) <> 6
OR isnumeric( IDNumber ) = 0
)

IDNumber
--
123456789
12345678
2-0152
A5487
A54871

3.

How do I insert several lines if I have the data as text?

I don't understand what you want to do here, please give more information.

4. Click on [File], [Connect], to connect to a different server. Open your script file, or cut/paste from the previous connection window.

(OR)

Set the additional Servers up as 'linked servers'. Refer to Books Online, Topic: 'Linked Server', sp_addlinkedserver.

Then you can use four object part naming to designate the server.

|||

Hi Arnie,

May be we can use following statement for point number 2.

select

*

from

@.MyTable

where

IDNumber notlike'[0-9][0-9][0-9][0-9][0-9][0-9]'

AMB

|||

Thank you for your quick reply.

For #3. In your example you used 7 insert statements to insert the rows into the table. Is there a way to insert them using one statement?

For #4. Is there a way to do it without adding linked servers? In osql, I type

osql -S 192.168.1.123 -E -d databasename -Q "INSERT INTO USERS(username, password) VALUES ("name", "pw")

osql -S 192.168.1.124 -E -d databasename -Q "INSERT INTO USERS(username, password) VALUES ("name", "pw")

osql -S 192.168.1.125 -E -d databasename -Q "INSERT INTO USERS(username, password) VALUES ("name", "pw")

osql -S 192.168.1.126 -E -d databasename -Q "INSERT INTO USERS(username, password) VALUES ("name", "pw")

Is there a way to do it in query analyzer without linked servers.

Thanks,

Cory

Thursday, February 9, 2012

3GB switch in boot ini

I have a server which has 4gig of memory. I have
modified the boot.ini file to include the /3GB switch. I
have looked at the process work set for SQLServer and it
still appears to be using only 2gig's of memory. This
server does have WIN2K Advance server and is also SQL
Server 200 Enterprise.
How can I find out if SQL Server is using the 3 gig I
have available?
thanksPerformance Monitor Counter:
SQL Server: Memory Manager:Total Server Memory
Kevin Connell, MCDBA
----
The views expressed here are my own
and not of my employer.
----
"Kevin" <anonymous@.discussions.microsoft.com> wrote in message
news:00b501c39fc8$debf2410$a101280a@.phx.gbl...
> I have a server which has 4gig of memory. I have
> modified the boot.ini file to include the /3GB switch. I
> have looked at the process work set for SQLServer and it
> still appears to be using only 2gig's of memory. This
> server does have WIN2K Advance server and is also SQL
> Server 200 Enterprise.
> How can I find out if SQL Server is using the 3 gig I
> have available?
> thanks|||"Kevin" <anonymous@.discussions.microsoft.com> wrote in message
news:00b501c39fc8$debf2410$a101280a@.phx.gbl...
> I have a server which has 4gig of memory. I have
> modified the boot.ini file to include the /3GB switch. I
> have looked at the process work set for SQLServer and it
> still appears to be using only 2gig's of memory. This
> server does have WIN2K Advance server and is also SQL
> Server 200 Enterprise.
> How can I find out if SQL Server is using the 3 gig I
> have available?
Performance monitor (Perfmon.exe) would be one way...
Steve|||That is what I used and it still only shows 1700544. The
Process:Work Set counter for SQLServr shows 1.7gig also.
I have SQL set to dynamic allocation. Seems the the
switch made no difference.
thanks
>--Original Message--
>Performance Monitor Counter:
>SQL Server: Memory Manager:Total Server Memory
>
>--
>Kevin Connell, MCDBA
>----
>The views expressed here are my own
>and not of my employer.
>----
>"Kevin" <anonymous@.discussions.microsoft.com> wrote in
message
>news:00b501c39fc8$debf2410$a101280a@.phx.gbl...
>> I have a server which has 4gig of memory. I have
>> modified the boot.ini file to include the /3GB
switch. I
>> have looked at the process work set for SQLServer and
it
>> still appears to be using only 2gig's of memory. This
>> server does have WIN2K Advance server and is also SQL
>> Server 200 Enterprise.
>> How can I find out if SQL Server is using the 3 gig I
>> have available?
>> thanks
>
>.
>|||Something in the back of mind is reminding me that you actually need more
than 4GB of RAM to take advantage of >2GB memory, and that that docs are
either wrong or misleading, but I may be thinking about PAE/AWE. Try to
enable /PAE and AWE and see where that leads you.
--
Kevin Connell, MCDBA
----
The views expressed here are my own
and not of my employer.
----
<anonymous@.discussions.microsoft.com> wrote in message
news:00c601c39fe7$b63eb310$a601280a@.phx.gbl...
> That is what I used and it still only shows 1700544. The
> Process:Work Set counter for SQLServr shows 1.7gig also.
> I have SQL set to dynamic allocation. Seems the the
> switch made no difference.
> thanks
> >--Original Message--
> >Performance Monitor Counter:
> >
> >SQL Server: Memory Manager:Total Server Memory
> >
> >
> >--
> >Kevin Connell, MCDBA
> >----
> >The views expressed here are my own
> >and not of my employer.
> >----
> >"Kevin" <anonymous@.discussions.microsoft.com> wrote in
> message
> >news:00b501c39fc8$debf2410$a101280a@.phx.gbl...
> >> I have a server which has 4gig of memory. I have
> >> modified the boot.ini file to include the /3GB
> switch. I
> >> have looked at the process work set for SQLServer and
> it
> >> still appears to be using only 2gig's of memory. This
> >> server does have WIN2K Advance server and is also SQL
> >> Server 200 Enterprise.
> >>
> >> How can I find out if SQL Server is using the 3 gig I
> >> have available?
> >>
> >> thanks
> >
> >
> >.
> >