Sunday, March 25, 2012
Check NT login existance
server itself) in a script that uses sp_grantlogin?You can use SUSER_SID:
IF SUSER_SID('MyDomain\MyAccount') IS NULL
PRINT 'account does not exist'
ELSE
PRINT 'account exists'
Happy Holidays
Dan Guzman
SQL Server MVP
"Steve Morris" <SteveMorris@.discussions.microsoft.com> wrote in message
news:FB40D121-995B-42DE-B735-7597C4793404@.microsoft.com...
> How do you check for the existance of an NT login (in the domain not on
> sql
> server itself) in a script that uses sp_grantlogin?
Check NT login existance
server itself) in a script that uses sp_grantlogin?
You can use SUSER_SID:
IF SUSER_SID('MyDomain\MyAccount') IS NULL
PRINT 'account does not exist'
ELSE
PRINT 'account exists'
Happy Holidays
Dan Guzman
SQL Server MVP
"Steve Morris" <SteveMorris@.discussions.microsoft.com> wrote in message
news:FB40D121-995B-42DE-B735-7597C4793404@.microsoft.com...
> How do you check for the existance of an NT login (in the domain not on
> sql
> server itself) in a script that uses sp_grantlogin?
Sunday, March 11, 2012
Check data Availbility between two table in Sqlserver 2005 using C#
I have Two table.One is MainTable and other is Temporary table.Both have Same Field
Before entering data into main table I want to check weather these data's are already there or not.
Here i am checking only three column of temporary table to the MainTable.
INSERT INTO MailTable(A, B, C)
SELECT (A, B, C) FROM TemporaryTable WHERE TemporaryTable.A NOT IN (SELECT A FROM MailTable)
|||
Thank you Thank you Thank you Thank you Very Much
Thursday, March 8, 2012
Check condition and wait
Hi,
I have a data-flow-task that imports data to sqlserver.
Now I want to check, if a special column of an imported record is null.
If yes, I have to wait 10 minutes and jump to the data-flow-task again. (Cjeck and wait).
How can I do this with the integration services?
Thanks
Gerd
You can do timer style loops, so this could be extended for your loop on the 10 minute, and maybe use some extra variables to keep track.
For Loop Container Samples
(http://www.sqlis.com/310.aspx)
You could have an Exec SQL Task inside your loop as the first task. Query the column and assign a variable value using the query result to indicate if the column is true. Then have a Data Flow Task linked from the Exec SQL Task and use an Expression on the constraint such that it is satisfied only when the variable in indicates that the Exec SQL Task found a value.
The final thing would be to extend the loop EvalExpression such that if it would not wait/loop if the Exec SQL Task assigned variable indicate data had been found.
The principal seems sound, though you may want to adjust the expressions and variables used to fit exactly with what you want.
Friday, February 24, 2012
Chart lists different builds of SQL Server and MDAC needed
Server 2000 and 2005.
Also, are all the keywords listed in the link below supported by all the
MDAC used for SQL Server 2000 and 2005? Are the acceptable values for the
keywords same for both 32bit and 64bit driver? For example, is the name of
the network library for tcp and named pipes same for both 32bit and 64bit?
http://msdn2.microsoft.com/en-us/library/aa177865(SQL.80).aspx
Thanks.Hi,
I've done some research but I couldn't find any document that ties the
keywords to MDAC specifically. I'm using the internal MS databases so
it's probably quite safe to say that no such document(s) exist(s). I
believe that the keywords are listed per SQL Server version rather than
per MDAC version.
What I would suggest you do is to test your applications against the
different MDAC versions. Alternatively, instead of testing all your
applications, you could also build a dummy application that does nothing
more than use the different keywords/functions specifically for testing
against the multiple MDAC versions efficiently and quickly.
The following link gives you a SQL Server 2005 version of the document
you included in your posting -
http://msdn2.microsoft.com/en-us/library/ms130822.aspx.
As far as any difference in acceptable keyword values between 32 and 64
bit platforms are concerned, I do not believe there would be a
difference. From my perspective portability between platforms should be
a high priority for any developer so I don't see why MS would introduce
such a big headache for itself and its customers. Again testing is your
safest option here.
Regarding the question of which MDAC build is required by different
builds of SQL Server I cannot find any MDAC updates being released as
part of a SQL Server build. To me this means that builds are not
dependent on any specific MDAC version otherwise MS would have no option
but to include the MDAC update as part of the SQL Server update. So I
would say that MDAC requirements are placed at a version level rather
than a build level unless any KB article specifically indicates
otherwise. My research uncovered no such KB articles.
Jonathan
Peter wrote:
> I want to find out which build of MDAC is required by different build of S
QL
> Server 2000 and 2005.
> Also, are all the keywords listed in the link below supported by all the
> MDAC used for SQL Server 2000 and 2005? Are the acceptable values for the
> keywords same for both 32bit and 64bit driver? For example, is the name of
> the network library for tcp and named pipes same for both 32bit and 64bit?
> http://msdn2.microsoft.com/en-us/library/aa177865(SQL.80).aspx
>
> Thanks.
>
>
Tuesday, February 14, 2012
Character set, Sort Order, Unicode Collation
Server (Character set, Sort Order, Unicode Collation), I
was looking for them at Knowledge Base, but couldn't find
anything.
ThanksHi,
Add on , Execute the below procedure to get the charecter set and sort
order. This procedure will work for all versions.
sp_helpsort
Thanks
Hari
MCDBA
"Robert Duval" <r.duval@.discussions.microsoft.com> wrote in message
news:1ddf001c45512$bfedc6e0$a601280a@.phx
.gbl...
> Please, a command/script to see how I installed my Sql
> Server (Character set, Sort Order, Unicode Collation), I
> was looking for them at Knowledge Base, but couldn't find
> anything.
> Thanks
Character set, Sort Order, Unicode Collation
Server (Character set, Sort Order, Unicode Collation), I
was looking for them at Knowledge Base, but couldn't find
anything.
Thanks
Hi,
Add on , Execute the below procedure to get the charecter set and sort
order. This procedure will work for all versions.
sp_helpsort
Thanks
Hari
MCDBA
"Robert Duval" <r.duval@.discussions.microsoft.com> wrote in message
news:1ddf001c45512$bfedc6e0$a601280a@.phx.gbl...
> Please, a command/script to see how I installed my Sql
> Server (Character set, Sort Order, Unicode Collation), I
> was looking for them at Knowledge Base, but couldn't find
> anything.
> Thanks
Sunday, February 12, 2012
Char or varchar for a primary key?
I'm planning the structure of a SqlServer 2005 database for a new
application.
The requirement is that primary keys must be "natural"; i.e. in the table
Customers the primary key will be a max. 10 characters string (but the
string may be filled i.e. with only 5 charachters).
Should I define these primary keys as char[5] or varchar[5]?
I'm interested in your opinion in particular about performace issue, because
there will be tables with millions of records...
Thanks,
Davide.>
Quote:
Originally Posted by
Should I define these primary keys as char[5] or varchar[5]?
Sorry, I intended char[10] or varchar [10]|||D. (d@.d.com) writes:
Quote:
Originally Posted by
I'm planning the structure of a SqlServer 2005 database for a new
application.
The requirement is that primary keys must be "natural"; i.e. in the table
Customers the primary key will be a max. 10 characters string (but the
string may be filled i.e. with only 5 charachters).
>
Should I define these primary keys as char[5] or varchar[5]?
I'm interested in your opinion in particular about performace issue,
because there will be tables with millions of records...
char(10) would make sense if key values are almost always 10 characters
long, but if the distribution varies with, say, 5 as the average varchar
would be better.
What sort of strings do you expect? If the values will be digits and upper-
case characters, you way want to consider a binary collation for the column,
at least if your default collation is a Windows collation.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||"D." wrote:
Quote:
Originally Posted by
>
Hi,
I'm planning the structure of a SqlServer 2005 database for a new
application.
The requirement is that primary keys must be "natural"; i.e. in the table
Customers the primary key will be a max. 10 characters string (but the
string may be filled i.e. with only 5 charachters).
>
Should I define these primary keys as char[5] or varchar[5]?
I'm interested in your opinion in particular about performace issue, because
there will be tables with millions of records...
>
Thanks,
Davide.
Assuming you will not change existing primary key values often (or
ever), the performance between CHAR and VARCHAR comes down to the space
requirements.
VARCHAR claims two bytes for the string length, plus the actual number
of characters in the string. So if the average primary key length
exceeds 8, you are better off with CHAR(10), otherwise you could use
VARCHAR(10).
Because of some other considerations (the 'first' VARCHAR column will
cost an additional 5 bytes per row), when in doubt, I would choose CHAR
over VARCHAR. In your case, I would choose VARCHAR(10) if the average
length is 6 or smaller. Otherwise I would choose CHAR(10).
Gert-Jan|||>
Quote:
Originally Posted by
What sort of strings do you expect? If the values will be digits and
upper-
case characters, you way want to consider a binary collation for the
column,
at least if your default collation is a Windows collation.
>
It sounds good!
Yes, my keys will be only uppercase and digits (some other symbols are
allowed, like dot and hyphen)
How do I set binary collation on a single column?
Do you think that this will improve performance on lookups?
Do you think that having a single column with a different collation will not
decrease performance?
Davide.|||>
Quote:
Originally Posted by
Because of some other considerations (the 'first' VARCHAR column will
cost an additional 5 bytes per row), when in doubt, I would choose CHAR
over VARCHAR. In your case, I would choose VARCHAR(10) if the average
length is 6 or smaller. Otherwise I would choose CHAR(10).
>
Usually the key is fully filled, so I think I'll try to change varchar to
char.
Davide.|||D. (d@.d.com) writes:
Quote:
Originally Posted by
How do I set binary collation on a single column?
With the COLLATE clause:
CREATE TABLE mytable (
col char(10) COLLATE Latin1_General_BIN2 NOT NULL,
...
Quote:
Originally Posted by
Do you think that this will improve performance on lookups?
Yes, since comparison is a straight byte-comparison you gain some cycles,
particularly if your default collation is a Windows collation. It's
diffiuclt to say exactly how much you will gain, because there is a lot
of if depends. For a simple lookup, it's may be only 5-10%. For an
operation as "col LIKE '%str%' it may be drastic as a factor of seven.
If your default collation is an SQL collation (one there the name starts
with SQL), the gain is likely to be so small, that it's not worth the
pain. Note that this only applies if you use char/varchar. For
nchar/nvarchar there is no difference between SQL and Windows collations.
Quote:
Originally Posted by
Do you think that having a single column with a different collation will
not decrease performance?
It will not, but there will be more hassle with programming. And it
would not be the only column with that collation, if there are other
tables with foreign keys to this table.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Without more specs, I would go with CHAR(n) and a CHECK() constraint
that uses a regular expression to validate it.