Posts Tagged Microsoft

MS SQL – številka tedna (week number)

Sql
V službi sem pri nekem projektu potreboval podatek za poljuben datum, da mi pove kateri teden je takrat. Ker gre za projekt pri katerem se planirajo potrebe v proizvodnji in ker je naša matična firma v nemčiji se vsi roki in planirani datumi govorijo v številkah tedna. Toda kako to številko dobiti direktno iz funkcij v MS SQL-u?

Ko sem pogledal v MS SQL books online sem našel čisto preprosto sintakso:

DATEPART (wk, ’2010-04-12′)

Vendar tukaj dobim napačno številko. Problem je v tem, da se predvsem v evropi uporablja štetje tednov drugače. Sql vzame kot prvi teden dneve, ki so še v zadnjem tednu prejšnjega leta. Po evopskem (ISO) načinu, pa se šteje za prvi teden šele prvi ponedeljek. Primer: 1.1.2010 je bil petek. In MS SQL šteje ta teden že kot prvi teden, pa čeprav je to tudi v bistvu 53.teden prejšnjega leta. ISO štetje, pa vzame kot prvi dan 1 tedna 4.1.2010 – ponedeljek.

Torej pravilna sintaksa je :

select DATEPART (isowk, ’2010-04-12′) as weeknumber

Vendar sem ugotovil, da to deluje šele na MS SQL 2008. Torej sem moral za MS SQL 2000 poiskati drugo rešitev. In sem jo našel. Prav tako je posredovana iz strani Microsofta. Pohvalno.

Na sistemski bazi master sem poiskal User Defined functions in dodal sledeče:

CREATE FUNCTION ISOweek (@DATE datetime)
RETURNS int
AS
BEGIN
DECLARE @ISOweek int
SET @ISOweek= DATEPART(wk,@DATE)+1
-DATEPART(wk,CAST(DATEPART(yy,@DATE) as CHAR(4))+'0104')
--Special cases: Jan 1-3 may belong to the previous year
IF (@ISOweek=0)
SET @ISOweek=dbo.ISOweek(CAST(DATEPART(yy,@DATE)-1
AS CHAR(4))+'12'+ CAST(24+DATEPART(DAY,@DATE) AS CHAR(2)))+1
--Special case: Dec 29-31 may belong to the next year
IF ((DATEPART(mm,@DATE)=12) AND
((DATEPART(dd,@DATE)-DATEPART(dw,@DATE))>= 28))
SET @ISOweek=1
RETURN(@ISOweek)
END

Ko hočemo poklicati to funkcijo uporabimo slednje (primer):

SELECT master.dbo.ISOweek(’2010-04-14′) AS ‘ISO Week’

Tako pa smo rešili še en problem :)

Značke: , , ,

Čas prekinitve mapiranega drive-a

Živjo!

Problem je nastal, ker je povezava na mapirani drive na serverju po določenm času nehala delovati. Da spremenimo čas prekinitve, ko je povezava neaktivna storimo sledeče:

Odpremo MS-DOS prompt okno. V okno vpišemo sledeče:

NET CONFIG SERVER /AUTODISCONNECT:-1

- 1 – unlimited
- 0 par sekund
- lahko, pa vpišemo poljubno število sekund

Preverjeno!

Značke: , , , ,

Microsoft access can’t start because there is no licence for it

Živjo!

Pred časom sem se znašel pred naslednjo napako: Microsoft access can’t start because there is no licence for it!

Zgodba je bila sledeča. Na PC-ju je bil nameščen MS Office 2003 z MS Access-om. Zadeva je delovala normalno. Potem, pa sem ugotovil, da je potrebo namestiti tudi starejši MS Access 97, ker je bilo veliko baz v tem formatu. Konvertiranje baz je odpadlo, ker večina uporabnikov teh baz uporablja še MS Access 97. Namestil sem torej še to starejšo verzijo. Ko sem hotel zagnati katerokoli datoteko za MS Access sem dobil zgornjo napako. In kaj sedaj??

Začelo se je googlanje in našel sem rešitev kar na Microsoftovi strani. Rešitev je v angleščini.

Problems After Installing Access 97 and Access 2000 on the Same Computer
If the procedures described in this article were not followed when the second version of Access was installed on the computer, you may have problems when you try to start Access. Following are descriptions of the error messages or problems that you may encounter, as well as the resolutions.

One error message you may receive is:
Microsoft Access can’t start because there is no license for it on this machine.
To resolve this behavior, follow these steps: 1. Click Start, point to Find, and then click Files or Folders.
2. In the Named box, type Hatten.ttf.
3. In the Look In box, type C:\Windows\Fonts or the path to the Fonts folder on your computer. If you are not sure of the font folder’s location, open Windows explorer and verify the directory where Windows is installed. Note: If you are on Windows NT 4.0, the path may be C:\WINNT\Fonts
4. Click Find Now to start the search.
5. Under Name, right-click the Hatten.ttf file, and on the menu that appears, click Rename.
6. Change the name of the file to Hatten.sav.

NOTE: You can find the Hatten.ttf file in the Fonts folder under the name, Haettenschweiler
7. Insert your Access 97 or Office 97 CD into the CD-ROM or DVD-ROM drive.
8. Click Start, and then click Run.
9. Type the command to run the Microsoft Access Setup program and use the /y switch to reregister Access 97. For example, type:

D:\Setup.exe /y
10. In the Installation Maintenance Program dialog box, click Reinstall. The Setup program updates the system registry for Access. When Setup is finished, start Access.

NOTE: Following the steps in this procedure has the side effect of changing all the Start menu shortcuts to point back to the Office 97 programs. If you want to have the shortcuts point to the Office 2000 programs, run Office 2000 Setup in maintenance mode, and then click Repair. You can then select to repair the Start menu shortcuts

Preverjeno deluje. Če kdo potrebuje prevod naj pove.

Značke: , , ,